MATLAB实现二重积分计算

MATLAB实现二重积分计算

太原理工大学中外合作办学-数值分析作业题

1. Question 1: (50 marks)

Evaluate the following double integral. Note that the upper y boundary is a function of x

二重积分示例
(a)Manually solve this question by using one Simpson 1/3 rule in the x-direction and two Simpson 1/3 rules in the y-direction. (15 marks)
(It is requested to show the detailed calculation procedure in your report, including the intervals, meshing, function values at each node, and integral for x and y, etc)
(b)Develop a MATLAB M-file based on the Simpson 1/3 rules for evaluation of the double integral of the above function with any number of Simpson 1/3 rules in the x- and y-directions. Note the number of Simpson 1/3 may be different in the x- and y-directions

Then, use the developed code to calculate the above double integral by different numbers of Simpson 1/3 rules until an accurate result is achieved. (25 marks)

(The M-file must be well commented and included in the report, and the developed code must be submitted for checking. You need to try different numbers of Simpson 1/3 rules in x- and y-directions until an accurate result is achieved. And justify why the final result is acceptable).

©Choose a proper MATLAB built-in function and develop an M-file script to calculate the above double integral.
(10 marks)
(The M-file must be well commented and included in the report, and the developed code must be submitted for checking. You are requested to compare the results by built-in function with the data obtained by the developed code. )

  • 问题1解答

(a)Normal dual integration
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
Simpson 1/3rule:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

(b) 解答

The code implementation using matlab is as follows.

% Define the integrand
f = @(x, y) x^2 - 2*y^2 + x*y^3;
 
% Define the integration region
x_start = 0;
x_end = 2;
y_start = -1;
y_end = @(x) 0.5 + 0.5*x;
 
% Define the number of intervals for the Simpson 1/3 rule in the x and y directions
num_intervals_x = 1;
num_intervals_y = 2;
 
% Calculate the step sizes in the x and y directions
h_x = (x_end - x_start) / num_intervals_x;
 
% Initialize the integration result
result = 0;
 
% Perform double integration using Simpson's 1/3 rule
for i = 1:num_intervals_x
    % Calculate the start and end values of the current x interval
    x1 = x_start + (i-1) * h_x;
    x2 = x_start + i * h_x;
    
    % Calculate the number of intervals for the Simpson 1/3 rule in the y direction for the current x interval
    num_intervals_y = 10 + i;
    
    % Calculate the step size in the y direction
    h_y = (y_end(x2) - y_start) / num_intervals_y;
    
    % Use Simpson's 1/3 rule to calculate the double integral for the current x interval
    for j = 1:num_intervals_y
        % Calculate the start and end values of the current y interval
        y1 = y_start + (j-1) * h_y;
        y2 = y_start + j * h_y;
        
        % Calculate the area of the current region
        area = (x2 - x1) * (y2 - y1);
        
        % Calculate the function values at the boundary points
        f_x1y1 = f(x1, y1);
        f_x2y1 = f(x2,<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

VIT19980106

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值