用Romberg方法求解積分_第1頁(yè)
用Romberg方法求解積分_第2頁(yè)
用Romberg方法求解積分_第3頁(yè)
用Romberg方法求解積分_第4頁(yè)
用Romberg方法求解積分_第5頁(yè)
已閱讀5頁(yè),還剩10頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、0.8、21.用Romberg方法求解積分MXdx ,要求誤差不超過(guò) a = 10'0解:Romberg.m 文件:function I, step = Romberg(f, a, b,EPS) % Romberg.m是用龍貝格公式求積分 %f為被積函數(shù)% EPS為積分結(jié)果精度% a,b為積分區(qū)間的上下限% I為積分結(jié)果;step為積分的子區(qū)間數(shù)m = 1 k = 0 Er = 0.1 H =b-a S = zeros(1, 1)S(1, 1) = (H/2) * (subs(sym(f),findsym(sym(f),a)+subs(sym,findsym(sym),b) while

2、 Er > EPS k = k + 1 f1 = 0 H = H/2 for i = 1:mx = a +H*(2*i-1)f1 = f1 + subs(sym(f),findsym(sym),x) endS(k+1, 1) = S(k, 1)/2 + H*f1 m = 2 * m for n = 1:kS(k+1, n+1) = S(k+1, n) + (S(k+1, n)-S(k, n)/(4An-1) endEr = abs(S(k+1, n+1)-S(k, n) endI = S(k+1, k+1) step = k命令:clear clc format shorta = 0;

3、b = 0.8; EPS = 1e-2;I, step = Romberg('xA(1/2)', a, b, EPS)計(jì)算結(jié)果:Er =0.1000H =0.8000S =0.3578 fl =0H =0.4000x =0.40000.2000fl =0.63250.3578 0.43190.3578 0.431900.4566Er =0.0988fl =0.2000 fl =0.4472 x =0.6000 fl =1.2218S =0.357800.43190.45660.46030S =0.357800.43190.45660.46030.4698S =0.3578000

4、.43190.456600.46030.46980.4707Er =0.0141 fl =0H =0.1000 x =0.1000 fl =0.3162 x =0.3000 f1 =0.8640x =0.5000fl =1.5711x =0.7000fl =2.4077S =0.3578000.43190.456600.46030.46980.47070.470900m =8S =0.3578000.43190.456600.46030.46980.47070.47090.47450S =0.3578000.43190.456600.46030.46980.47070.47090.47450.

5、47480.35780000.43190.4566000.46030.46980.470700.47090.47450.47480.4748Er =0.0042I =0.4748 step =3I =0.4748 step =35x12x2X312,2.設(shè)方程組Xi4x22x320,試用Jacobi迭代法求解此方程,x0,0,02x1 3x2 10x3 3.T*1*,)105時(shí)終止迭代。解:Jacobi.m 文件:function Jacobi(A, b, max, eps) %max 為最大迭代次數(shù),eps為容許誤差n = length(A); x = zeros(n, 1); x1 = z

6、eros(n, 1); k = 0;while 1x1(1) = ( b-A(1,2:n) * x(2:n,1) )/A(1,1)for i = 2:n-1x1(i) = ( b(i) - A(i,1:i-1) * x(1:i-1,1) - A(i,i+1:n) * x(i+1:n,1)/A(i,i) endx1(n) = ( b(n) - A(n,1:n-1) * x(1:n-1,1) )/A(n,n)k = k + 1if sum(abs(x1 - x) < eps fprintf('number = %dn',k)breakendif k >= maxfpri

7、ntf('The Method is disconvergentn') breakendx = x1endif k < maxfor i = 1:nfprintf( 'x %d = %fn',i,x1(i)endend命令:clearcicformat shortA = 5 2 1; -1 4 2; 2 -3 10;b = -12 20 3'max = 100;eps = 1e-5Jacobi(A, b, max, eps)計(jì)算結(jié)果:i =1A =521-1422-310b =-12203D =5000400010L =000100-230U =0

8、-2-100-2000D0 =0.20000000.25000000.1000x0 =000B =0-0.4000-0.20000.25000-0.5000-0.20000.30000f =-2.40005.00000.3000x =-2.40005.00000.3000x0 =-2.40005.00000.3000i =2x =-4.46004.25002.2800x0 =i =-4.46004.25002.28003x =-4.55602.74502.4670x0i =-4.55602.74502.46704x =-3.99142.62752.0347x0i =-3.99142.62752

9、.03475x =-3.85792.98481.8865x0i =-3.85792.98481.88656x =-3.97123.09221.9670x0-3.97123.09221.9670i =7x =-4.03033.02372.0219 x0 =-4.03033.02372.0219 i =8x =-4.01392.98152.0132 x0 =-4.01392.98152.0132 i =9x =-3.99522.99001.9972 x0 =-3.99522.99001.9972 i =10x =-3.99543.00261.9960 x0 =-3.99543.00261.9960

10、 i =11x =-4.00023.00311.9999x0 =-4.00023.00311.9999i =12x =-4.00123.00002.0010x0 =-4.00123.00002.0010i =13x =-4.00022.99922.0002x0 =-4.00022.99922.0002i =14x =-3.99972.99981.9998x0 =-3.99972.99981.9998i =15x =-3.99993.00021.9999x0 =-3.9999203.00021.9999i =16x =-4.00003.00012.0000x0 =-4.00003.00012.0000i =17x =-4.00003.00002.0000x0 =-4.0000

溫馨提示

  • 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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論