資源描述:
《數(shù)值分析上機實驗》由會員上傳分享,免費在線閱讀,更多相關內容在工程資料-天天文庫。
1、劉力輝2010210804011.“畫圓為方”問題也是古希臘人所提出幾何三大難題中的另一個問題。即求作一個正方形,使其面積等于已知圓的面積。不妨設已知圓的半徑為R=1,試用數(shù)值試驗顯示“畫圓為方”問題計算過程中的誤差。(1)MATLAB程序:y=pi^(1/2);%togenerate15-bitvalueofsquarerootofpib=1;d=1;fork=1:8b=b*10;d=d/10;%banddcombinedtocontrolthedigitofxx=d*fix(b*y);s(k)=x^3;l(k)=x;endformatlong[l',s'](2)誤差分析:位數(shù)h近似
2、值V近似值21.74.9130000000000031.775.5452330000000041.7725.5640516480000051.77245.5678204794240061.772455.5682917029811371.7724535.5683199772400181.77245385.5683275170585491.772453855.568327988297422.算法的數(shù)值穩(wěn)定性實驗設,由xn=xn+5xn–1–5xn–1可得遞推式In=–5In–1+1/n(1)從I0盡可能精確的近似值出發(fā),利用遞推公式:(n=1,2,…20)計算從I1到I20的近似值;(2)
3、從較粗糙的估計值出發(fā),用遞推公式:(n=30,29,…,3,2)計算從到的近似值;(3)分析所得結果的可靠性以及出現(xiàn)這種現(xiàn)象的原因。I0==ln(5+x)=ln6-ln5所以I0≈0.18232155679395MATLAB程序:formatlongI0=log2(6)/log2(exp(1))-log2(5)/log2(exp(1))%calculatethevalueofI0=ln6-ln5forn=1:20I0=-5*I0+1/n;%recyclingequationbetweenI(n+1)andI(n)s(n)=I0;ends'則計算結果為:表1I10.08839221603
4、02300I110.0140713362538500I20.0580389198488700I120.0129766520640700I30.0431387340890000I130.0120398166027400I40.0343063295550100I140.0112294884148600I50.0284683522249700I150.0105192245923700I60.0243249055418100I160.0099038770381400I70.0212326151481100I170.0093041442210800I80.0188369242594600I180
5、.0090348344501700I90.0169264898137900I190.0074574066965100I100.0153675509310500I200.0127129665174600從計算的數(shù)據(jù)看出I20=0.0127129665174600>I19=0.0074574066965100又In的積分范圍為0~1,所以應該有In>In+1。所以算法不穩(wěn)定。下面分析導致算法不穩(wěn)定的原因:令Sn為近似值,則有(1)又(2)(1)-(2)得Sn-In=-5Sn-1-In-1=(-5)n(S0-I0)=(-5)nε0(3)ε0為I0的誤差??芍上峦线f推時誤差是以指數(shù)增加傳遞
6、的,即εn=(-5)nε0所以必然會導致算法不穩(wěn)定。又公式(3)知,當由上往下遞推時,誤差是以指數(shù)減少傳遞的,即ε0=1/(-5)nεn(4)所以此時算法是穩(wěn)定的。下面便給出由I30的估計值算I29~I1的值?!堋芩杂小躀n≤即1/186≤I30≤1/155,取為1/155。MATLAB程序:formatlongI0=1/155%calculatethevalueofI30=ln6-ln5forn=30:-1:2I0=(-1/5)*I0+1/(5*n);%recyclingequationbetweenI(n+1)andI(n)s(n-1)=I0;endj=1;fori=29:-1:
7、1a(j)=s(i);j=j+1;enda'計算出相應數(shù)據(jù)為:表2S290.005376344086020S140.011229186626480S280.005821282906930S130.012039876960420S270.005978600561470S120.012976639992530S260.006211687295110S100.014071338668160S250.006449970233290S90.0153675