定积分的近似计算97786

上传人:re****.1 文档编号:511806356 上传时间:2023-03-10 格式:DOCX 页数:14 大小:26.13KB
返回 下载 相关 举报
定积分的近似计算97786_第1页
第1页 / 共14页
定积分的近似计算97786_第2页
第2页 / 共14页
定积分的近似计算97786_第3页
第3页 / 共14页
定积分的近似计算97786_第4页
第4页 / 共14页
定积分的近似计算97786_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《定积分的近似计算97786》由会员分享,可在线阅读,更多相关《定积分的近似计算97786(14页珍藏版)》请在金锄头文库上搜索。

1、数学实验报告实验序号:4日期:2012年12月13日实验名称定积分的近似计算问题背景描述:利用牛顿一莱布尼兹公式虽然可以精确地计算定积分的值,但它仅适用于被积函数的原 函数能用初等函数表达出来的情形.如果这点办不到或者不容易办到,这就有必要考虑近似 计算的方法.在定积分的很多应用问题中,被积函数甚至没有解析表达式,可能只是一条实 验记录曲线,或者是一组离散的采样值,这时只能应用近似方法去计算相应的定积分.实验目的:本实验将主要研究定积分的三种近似计算算法:矩形法、梯形法、抛物线法。对于定积 分的近似数值计算,Mat lab有专门函数可用。实验原理与数学模型:1. 矩形法根据定积分的定义,每一个

2、积分和都可以看作是定积分的一个近似值,即2-1在几何意义上,这是用一系列小矩形面积近似小曲边梯形的结果,所以把这个近似计算 方法称为矩形法.不过,只有当积分区间被分割得很细时,矩形法才有一定的精确度.针对不同口的取法,计算结果会有不同。CD左点法:对等分区间x0 = a xi =a + i c = h总,在区间丙一i心上取左端点,即取匚二心-(2) 右点法:同(1)中划分区间,在区间也-1心上取右端点,即取口二丙。丁 _丙_1+丙(3) 中点法:同(1)中划分区间,在区间兀1卫上取中点,即取2 。2. 梯形法等分区间b-a, b-ax0 = a 心 -= a +z xK = b Ax =相应函

3、数值为曲线P = 上相应的点为 吒,珥,(爲=(為= 0,1,川) 将曲线的每一段弧1尺用过点目-1,爲的弦爲-1爲(线性函数)来代替,这使得每个吗-1心 上的曲边梯形成为真正的梯形,其面积为2,心以巴于是各个小梯形面积之和就是曲边梯形面积的近似值,J:了(疋)E乞XT:冥心=等乞g +”)土工(警+戸+耳_1+)即儿22,称此式为梯形公式。3.抛物线法将积分区间也切作加等分,分点依次为b-a,. b-a = & Xi Xj - a +z 使用函数trapz()x=1:1/120:2;y=1./x;trapz(x,y)【调试结果】ans =0.69315152080005Q使用函数quad()

4、quad(1./x,1,2)【调试结果】ans =0.693147199862972:使用函数trapz()x=1:1/120:inf;y=sin(x)./x;trapz(x,y)【调试结果】? Error using = colonMaximum variable size allowed by the program is exceeded.Q使用函数quad()quad(sin(x)./x,O,inf)【调试结果】ans =NaNQ程序法%矩阵法 format long n=inf;a=O;b=inf; syms x fx fx=sin(x)./x;%左点%右点%左点值%右点值%中点值i

5、=1:n; xj=a+(i-l)*(b-a)/n; xi=a+i*(b-a)/n; xij=(xi+xj)/2; fxj=subs(fx,x,xj); fxi=subs(fx,x,xi); fxij=subs(fx,x,xij); f1=fxj*(b-a)/n; f2=fxi*(b-a)/n; f3=fxij*(b-a)/n; inum1=sum(f1) inum2=sum(f2) inum3=sum(f3) integrate=int(fx,O,inf); integrate=double(integrate);fprintf(the relative error between inum1

6、 and real-value is about: %gnn,.abs(inum1-integrate)/integrate)fprintf(the relative error between inum2 and real-value is about: %gnn,.abs(inum2-integrate)/integrate)fprintf(the relative error between inum3 and real-value is about: %gnn,.abs(inum3-integrate)/integrate)? Maximum variable size【调试结果】al

7、lowed by the program is exceeded.使用matlab命令syms x;f=sin(x)/x;I=int(f,0,inf)【调试结果】I = 1/2*pi3:1矩形法:利用求和函数%矩阵法format long n=100;a=0;b=l;syms x fxfx=1/(1+xA2);i=1:n; xj=a+(i-1)*(b-a)/n; xi=a+i*(b-a)/n; xij=(xi+xj)/2; fxj=subs(fx,x,xj); fxi=subs(fx,x,xi); fxij=subs(fx,x,xij); f1=fxj*(b-a)/n; f2=fxi*(b-a

8、)/n; f3=fxij*(b-a)/n;%左点%右点%左点值%右点值%中点值inum1=sum(f1)inum2=sum(f2)inum3=sum(f3)integrate=int(fx,0,1);integrate=double(integrate);fprintf(the relative error between inum1 and real-value is about: %gnn,.abs(inum1-integrate)/integrate)fprintf(the relative error between inum2 and real-value is about: %gn

9、n,.abs(inum2-integrate)/integrate)fprintf(the relative error between inum3 and real-value is about: %gnn,.abs(inum3-integrate)/integrate)【调试结果】inum1 =0.78789399673078inum2 =0.78289399673078inum3 =0.78540024673078the relative error between inuml and real-value is about: 0.00317779the relative error between inum2 and real-value is about: 0.0031884the relative error between

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号