版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、數(shù)學(xué)實(shí)驗(yàn)報(bào)告實(shí)驗(yàn)序號(hào):03 日期:2014年 11 月14日班級(jí)一班姓名學(xué)號(hào)實(shí)驗(yàn)名稱定積分的近似運(yùn)算問(wèn)題背景描述: 利用牛頓萊布尼茲公式雖然可以精確地計(jì)算定積分的值,但它僅適用于被積函數(shù)的原函數(shù)能用初等函數(shù)表達(dá)出來(lái)的情形如果這點(diǎn)辦不到或者不容易辦到,這就有必要考慮近似計(jì)算的方法在定積分的很多應(yīng)用問(wèn)題中,被積函數(shù)甚至沒(méi)有解析表達(dá)式,可能只是一條實(shí)驗(yàn)記錄曲線,或者是一組離散的采樣值,這時(shí)只能應(yīng)用近似方法去計(jì)算相應(yīng)的定積分 本實(shí)驗(yàn)將主要研究定積分的三種近似計(jì)算算法:矩形法、梯形法、拋物線法對(duì)于定積分的近似數(shù)值計(jì)算。實(shí)驗(yàn)?zāi)康模?1加深理解積分理論中分割、近似、求和、取極限的思想方法; 2了解定積分近似
2、計(jì)算的矩形法、梯形法與拋物線法; 3會(huì)用MATLAB語(yǔ)言編寫(xiě)求定積分近似值的程序,會(huì)用MALAB中的命令求定積分實(shí)驗(yàn)原理與數(shù)學(xué)模型: 1 矩形法 根據(jù)定積分的定義,每一個(gè)積分和都可以看作是定積分的一個(gè)近似值,即 在幾何意義上,這是用一系列小矩形面積近似小曲邊梯形的結(jié)果,所以把這個(gè)近似計(jì)算方法稱為矩形法不過(guò),只有當(dāng)積分區(qū)間被分割得很細(xì)時(shí),矩形法才有一定的精確度 針對(duì)不同的取法,計(jì)算結(jié)果會(huì)有不同。 (1) 左點(diǎn)法:對(duì)等分區(qū)間 , 在區(qū)間上取左端點(diǎn),即取。 (2)右點(diǎn)法:同(1)中劃分區(qū)間,在區(qū)間上取右端點(diǎn),即取。 (3)中點(diǎn)法:同(1)中劃分區(qū)間,在區(qū)間上取中點(diǎn),即取。 2 梯形法等分區(qū)間,相應(yīng)函
3、數(shù)值為 ()曲線上相應(yīng)的點(diǎn)為 ()將曲線的每一段弧用過(guò)點(diǎn),的弦(線性函數(shù))來(lái)代替,這使得每個(gè)上的曲邊梯形成為真正的梯形,其面積為,于是各個(gè)小梯形面積之和就是曲邊梯形面積的近似值,即 ,稱此式為梯形公式。3 拋物線法將積分區(qū)間作等分,分點(diǎn)依次為,對(duì)應(yīng)函數(shù)值為(),曲線上相應(yīng)點(diǎn)為()現(xiàn)把區(qū)間上的曲線段用通過(guò)三點(diǎn),的拋物線來(lái)近似代替,然后求函數(shù)從到的定積分:由于,代入上式整理后得同樣也有將這個(gè)積分相加即得原來(lái)所要計(jì)算的定積分的近似值:,即這就是拋物線法公式.實(shí)驗(yàn)所用軟件及版本:Matlab2012b Wps2013主要內(nèi)容(要點(diǎn)):1.實(shí)現(xiàn)實(shí)驗(yàn)內(nèi)容中的例子,即采用矩形法,梯形法,拋物線法計(jì)算,取n=
4、258,并比較三種方法的精確程度。2.分別用梯形法與拋物線法,計(jì)算,取并嘗試直接使用函數(shù)trapz()、quad()進(jìn)行計(jì)算求解,比較結(jié)果的差異3. 試計(jì)算定積分(注意:可以運(yùn)用trapz()、quad()或附錄程序求解嗎?為什么?)4.將的近似計(jì)算結(jié)果與matlab中各命令的計(jì)算結(jié)果相比較,使猜測(cè)matlab中的數(shù)值積分命令最可能采用了哪一種近似計(jì)算方法?并找出其他例子支持你的觀點(diǎn)。5.通過(guò)整個(gè)實(shí)驗(yàn)內(nèi)容和練習(xí),你能否做出一些理論上的小結(jié),即針對(duì)什么類型的函數(shù)(具有某種單調(diào)特性和凹凸特性),用某種近似計(jì)算方法所得結(jié)果更接近于實(shí)際值?6 學(xué)習(xí)fulu2sum.m的程序設(shè)計(jì)方法,嘗試用函數(shù) sum
5、 改寫(xiě)附錄1和附錄3的程序,避免for 循環(huán)。實(shí)驗(yàn)過(guò)程記錄(含基本步驟、主要程序清單及異常情況記錄等):一1.矩形法:format longn=258;a=0;b=1;syms x fxfx=1/(1+x2);i=1:n;xj=a+(i-1)*(b-a)/n; %左點(diǎn)xi=a+i*(b-a)/n; %右點(diǎn)xij=(xi+xj)/2;fxj=subs(fx,x,xj); %左點(diǎn)值fxi=subs(fx,x,xi); %右點(diǎn)值fxij=subs(fx,x,xij); %中點(diǎn)值f1=fxj*(b-a)/n;f2=fxi*(b-a)/n;f3=fxij*(b-a)/n;inum1=sum(f1)inu
6、m2=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: %gnn,. abs(inum2-integrate)/integrate)fprintf(the relativ
7、e error between inum3 and real-value is about: %gnn,.abs(inum3-integrate)/integrate)調(diào)試結(jié)果:inum1 = 0.786366529681526inum2 = 0.784428545185402inum3 = 0.785398476379441the relative error between inum1 and real-value is about: 0.00123296the relative error between inum2 and real-value is about: 0.00123456
8、the relative error between inum3 and real-value is about: 3.98501e-07 2.梯形法format longn=258;a=0;b=1;syms x fxfx=1/1+x2;i=1:n;xj=a+(i-1)*(b-a)/n; %所有左點(diǎn)的數(shù)組xi=a+i*(b-a)/n; %所有右點(diǎn)的數(shù)組fxj=subs(fx,x,xj); %所有左點(diǎn)值fxi=subs(fx,x,xi); %所有右點(diǎn)值f=(fxi+fxj)/2*(b-a)/n; %梯形面積inum=sum(f) %加和梯形面積求解integrate=int(fx,1,2);in
9、tegrate=double(integrate)fprintf(The relative error between inum and real-value is about:%g/n/n,.abs(inum-integrate)/integrate)調(diào)試結(jié)果:inum = 1.333335837189272integrate = 3.333333333333334The relative error between inum and real-value is about:0.599999/n/n 3. .拋物線法:format longn=258;a=0;b=1;inum=0;syms
10、x fxfx=1/1+x2;for i=1:n xj=a+(i-1)*(b-a)/n; %左點(diǎn) xi=a+i*(b-a)/n; %右點(diǎn) xk=(xi+xj)/2; %中點(diǎn) fxj=subs(fx,x,xj); fxi=subs(fx,x,xi); fxk=subs(fx,x,xk);inum=inum+(fxj+4*fxk+fxi)*(b-a)/(6*n);endinumintegrate=int(fx,1,2);integrate=double(integrate);fprintf(The relative error between inum and real-value is about
11、:%g/n/n,.abs(inum-integrate)/integrate)調(diào)試結(jié)果:inum = 1.333333333333334The relative error between inum and real-value is about:0.6/n/n二:1.梯形法format longn=120;a=1;b=2;syms x fxfx=1/x;i=1:n;xj=a+(i-1)*(b-a)/n; %所有左點(diǎn)的數(shù)組xi=a+i*(b-a)/n; %所有右點(diǎn)的數(shù)組fxj=subs(fx,x,xj); %所有左點(diǎn)值fxi=subs(fx,x,xi); %所有右點(diǎn)值f=(fxi+fxj)/2
12、*(b-a)/n; %梯形面積inum=sum(f) %加和梯形面積求解integrate=int(fx,1,2);integrate=double(integrate)fprintf(The relative error between inum and real-value is about:%g/n/n,.abs(inum-integrate)/integrate)【調(diào)試結(jié)果】inum = 0.69315152080005integrate = 0.69314718055995The relative error between inum and real-value is about:
13、6.26164e-006/n/n2.拋物線法:format longn=120;a=1;b=2;inum=0;syms x fxfx=1/x;for i=1:n xj=a+(i-1)*(b-a)/n; %左點(diǎn) xi=a+i*(b-a)/n; %右點(diǎn) xk=(xi+xj)/2; %中點(diǎn) fxj=subs(fx,x,xj); fxi=subs(fx,x,xi); fxk=subs(fx,x,xk); inum=inum+(fxj+4*fxk+fxi)*(b-a)/(6*n);endinumintegrate=int(fx,1,2);integrate=double(integrate);fprin
14、tf(The relative error between inum and real-value is about:%g/n/n,.abs(inum-integrate)/integrate)【調(diào)試結(jié)果】inum = 0.69314718056936The relative error between inum and real-value is about:1.35886e-011/n/n3.使用函數(shù)trapz()x=1:1/120:2;y=1./x;trapz(x,y)【調(diào)試結(jié)果】ans =0.693151520800054.使用函數(shù)quad()quad(1./x,1,2)【調(diào)試結(jié)果】a
15、ns = 0.69314719986297四1.梯形法:format long n=100;a=0;b=1;inum=0;syms x fx fx=1/(1+x2); for i=1:n xj=a+(i-1)*(b-a)/n; xi=a+i*(b-a)/n; fxj=subs(fx,x,xj); fxi=subs(fx,x,xi); inum=inum+(fxj+fxi)*(b-a)/(2*n); end inum integrate=int(fx,0,1) integrate=double(integrate) fprintf(The relative error between inum
16、and real-value is about: %gnn,. abs(inum-integrate)/integrate)【調(diào)試結(jié)果】:inum = 0.785393996730783integrate = pi/4 integrate = 0.785398163397448The relative error between inum and real-value is about: 5.30516e-062.矩形法:format long n=100;a=0;b=1;inum1=0;inum2=0;inum3=0; syms x fx fx=1/(1+x2); for i=1:n xj=
17、a+(i-1)*(b-a)/n; xi=a+i*(b-a)/n; fxj=subs(fx,x,xj); fxi=subs(fx,x,xi); fxij=subs(fx,x,(xi+xj)/2); inum1=inum1+fxj*(b-a)/n; inum2=inum2+fxi*(b-a)/n; inum3=inum3+fxij*(b-a)/n; end inum1 inum2 inum3 integrate=int(fx,0,1) integrate=double(integrate) fprintf(The relative error between inum1 and real-valu
18、e 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) 【調(diào)試結(jié)果】: inum1 = 0.787893996730782 inum2
19、 = 0.782893996730782 inum3 = 0.785400246730781 integrate = pi/4 integrate = 0.785398163397448The relative error between inum1 and real-value is about: 0.00317779The relative error between inum2 and real-value is about: 0.0031884nThe relative error between inum3 and real-value is about: 2.65258e-063.
20、梯形法 求和:format long n=100;a=0;b=1; syms x fx fx=1/(1+x2); i=1:n; xj=a+(i-1)*(b-a)/n; %所有左點(diǎn)的數(shù)組 xi=a+i*(b-a)/n; %所有右點(diǎn)的數(shù)組 fxj=subs(fx,x,xj); %所有左點(diǎn)值 fxi=subs(fx,x,xi); %所有右點(diǎn)值 f=(fxi+fxj)/2*(b-a)/n; %梯形面積 inum=sum(f) %加和梯形面積求解 integrate=int(fx,0,1) integrate=double(integrate) fprintf(The relative error be
21、tween inum and real-value is about: %gnn,. abs(inum-integrate)/integrate) 【調(diào)試結(jié)果】: inum = 0.785393996730783 integrate = pi/4 integrate = 0.785398163397448 The relative error between inum and real-value is about: 5.30516e-064.拋物線法:format long %2*n=200; n=100;a=0;b=1;inum=0; syms x fx fx=1/(1+x2); for
22、i=1:n x0=a+(2*i-2)*(b-a)/(2*n);x1=a+(2*i-1)*(b-a)/(2*n);x2=a+(2*i-0)*(b-a)/(2*n);fx0=subs(fx,x,x0); fx1=subs(fx,x,x1); fx2=subs(fx,x,x2); si=(fx0+4*fx1+fx2)*(b-a)/(6*n);inum=inum+si; end inum integrate=int(fx,0,1) integrate=double(integrate) fprintf(拋物線的相對(duì)誤差為:%en, abs(inum-integrate)/integrate) 【調(diào)試結(jié)
23、果】:inum = 0.785398163397448integrate = pi/4 integrate = 0.785398163397448數(shù)值計(jì)算:1.(符號(hào)求積分) :int(1/(1+x2),x,0,1) int(sym(1/(1+x2),x,0,1) 【調(diào)試結(jié)果】: ans =pi/42.(拋物線法求數(shù)值積分):quad(1./(1+x.2),0,1) 【調(diào)試結(jié)果】: ans = 0.785398149243260 3.(梯形法求數(shù)值積分): x=0:0.001:1; y=1./(1+x.2); trapz(x,y)【調(diào)試結(jié)果】:ans = 0.785398121730782六.
24、1.矩形法:利用求和函數(shù)%矩陣法format longn=100;a=0;b=1;syms x fxfx=1/(1+x2);i=1:n;xj=a+(i-1)*(b-a)/n; %左點(diǎn)xi=a+i*(b-a)/n; %右點(diǎn)xij=(xi+xj)/2;fxj=subs(fx,x,xj); %左點(diǎn)值fxi=subs(fx,x,xi); %右點(diǎn)值fxij=subs(fx,x,xij); %中點(diǎn)值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,0,1
25、);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: %gnn,. abs(inum2-integrate)/integrate)fprintf(the relative error between inum3 and real-value is abo
26、ut: %gnn,.abs(inum3-integrate)/integrate)【調(diào)試結(jié)果】inum1 = 0.78789399673078 inum2 = 0.78289399673078 inum3 = 0.78540024673078the relative error between inum1 and real-value is about: 0.00317779the relative error between inum2 and real-value is about: 0.0031884the relative error between inum3 and real-va
27、lue is about: 2.65258e-0062.拋物線法:使用求和函數(shù)%拋物線format longn=100;a=0;b=1;syms x fxfx=1/(1+x2);i=1:n;xj=a+(i-1)*(b-a)/n; %左點(diǎn)xi=a+i*(b-a)/n; %右點(diǎn)xij=(xi+xj)/2;fxj=subs(fx,x,xj); %左點(diǎn)值fxi=subs(fx,x,xi); %右點(diǎn)值fxij=subs(fx,x,xij); %中點(diǎn)值f=(fxj+4*fxij+fxi)*(b-a)/(6*n);inum=sum(f)integrate=int(fx,0,1);integrate=doub
28、le(integrate);fprintf(the relative error between inum and real-value is about: %gnn,. abs(inum-integrate)/integrate)【調(diào)試結(jié)果】 inum = 0.78539816339745the relative error between inum and real-value is about: 2.82716e-016實(shí)驗(yàn)結(jié)果報(bào)告與實(shí)驗(yàn)總結(jié):1 1.矩形法調(diào)試結(jié)果:inum1 = 0.786366529681526inum2 = 0.784428545185402inum3 = 0.7
29、85398476379441the relative error between inum1 and real-value is about: 0.00123296the relative error between inum2 and real-value is about: 0.00123456the relative error between inum3 and real-value is about: 3.98501e-072. 梯形法:調(diào)試結(jié)果:inum = 1.333335837189272integrate = 3.333333333333334The relative error between inum and real-value is about:0.599999/n/n 3. 拋物線法:調(diào)試結(jié)果:inum = 1.333333333333334The relative error between inum and real-value is about:0.6/n/n二:1.梯形法:調(diào)試結(jié)果:inum = 0.69315152080005integrate = 0.69314718055995The relative error between inum and real-value is about:6.26164e-006/n/n2
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 上班睡覺(jué)檢討書(shū)
- 醫(yī)生先進(jìn)事跡(13篇)
- 買房個(gè)人收入證明范本(20篇)
- 個(gè)人學(xué)期末工作總結(jié)
- DB12T 604-2015 應(yīng)用生物絮凝技術(shù)處理農(nóng)村生活污水操作規(guī)程
- DB12T 607-2015 智能郵件快件箱
- DB12∕T 989-2020 人參中有機(jī)磷和擬除蟲(chóng)菊酯類農(nóng)藥殘留量的測(cè)定 氣相色譜法
- 醫(yī)療器械經(jīng)營(yíng)監(jiān)督管理辦法培訓(xùn)2024
- 慢性病鑒定標(biāo)準(zhǔn)
- 高等數(shù)學(xué)教程 試卷2-答案
- 人力資源管理百年:演變與發(fā)展
- 材料成型工藝pdf
- 胃潰瘍伴出血的護(hù)理查房
- 郵政行測(cè)題庫(kù)2024
- 《紀(jì)念白求恩》專題探究課件(敘議結(jié)合理思路)
- 腹腔鏡手術(shù)操作技巧
- 品牌礦泉水物質(zhì)表
- 2024年中國(guó)移動(dòng)重慶分公司招聘筆試參考題庫(kù)含答案解析
- 污水源熱泵方案
- QCT 1037-2016 道路車輛用高壓電纜
- 現(xiàn)代交換原理與通信網(wǎng)技
評(píng)論
0/150
提交評(píng)論