


版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、2012-2013 (1)專業(yè)課程實踐論文等距節(jié)點插值公式柳希元,0818180127, R數(shù)學08-1班、算法理論將Newton差商插值多項式中各階差商用相應差分替代,就可得到各種形 式的等距節(jié)點插值公式。如果節(jié)點込F +馳=0丄 ,.要計算_附近點X的函數(shù)- 值,可令護眼專腌腮L于是Nn(x + =禹 + tA/a + 耳®+- + - " + - A"/fl為Newton前插公式。其中也=&mfk - AraffcAfjr = Ar+1 一 fk如果要求表示函數(shù)在工屛付近的值此時應用Newton插值公式,插值點應按'-| ;:? i 1 &q
2、uot;4 L的次序排列,有叫(刃=x91) + /xB,x_vx_2(z - XJ(z-Xn_t) + f 北和場i-W衍仗一?!?(工 寓1)做變換応口徨/感*廣農(nóng)住灼;:鏈帶入公式得” vt(t - 1) ,t(t 一 1) ft - n +1)凡仗+tft) = 4 +岡人+七+計曠啟為Newton后插公式。其中嚴人=% -嚴人負二 /fc+i- fk二、算法框圖三、算法程序class Interpolationpublic :Interpolation(int num, double x1, double x2, double func);double ComputeForwardV
3、alue( double x);/ compute forward interpolation valueln terpolati on();private :void GetForwardTable(); / get the forward differential tableprivate :int m_num; / the number of interpolation pointsdouble m_x1, m_x2;/ the first point m_x1 and last point m_x2double m_step; / the in terpolati on stepdou
4、ble * m_func; / the function value of interpolation pointsdouble * m_ftable; / the forward differential table;#in clude <iostream>#i nclude <limits>using namespacestd;#define NUM 11/上l?面?輸o?入?需要°&多0少|(zhì)個?樣本a?#define MIN 0/上|?面?輸o?入?區(qū)?間?的1最 a?小?值| 1#define MAX 10/上|?面?輸o?入?區(qū)?間?的1最a
5、大?值| 1int main()/下?面?輸o?入?y的1值| 1double funcNUM=0,1,4,9,16,25,36,49,64,81,100;/上I?面?輸o?入?y的值| 1double x1=MIN, x2=MAX, x;int num=NUM;char flag= 'Y'In terpolati on test (n um, x1, x2, fun c);while (flag= Y )cout<< "I nput x:"cin»x;if (!cin)/ checking failure stateci n.clea
6、r(); / clear failure tagcin .ig nore(n umeric_limits<int >:max(),'n' ); / clear in put buffercontinue ;if (x<x1 | x>x2)cout<<"-I nvalid in put: "<<x<<"-" <<e ndl;<<e ndl;cout<<"Only the number between " vvx1<v&q
7、uot; and " <<x2<<" is valid."elsecout<< "Forward in terpolati on value:"<<test.ComputeForwardValue(x+0.001)<<e ndl;cout<<endl<< "Do you want to process? please input(Y/N):"<<endl;cin> >flag;return 0;In terpolati
8、o n:l nterpolatio n(int num, double x1, double x2, double func)m_num = num;m_x1 = x1;m_x2 = x2;m_step = (m_x2-m_x1)/( num-1); m_func = new double m_num; m_ftable = new double m_num;for ( int i=0; i<m_num; +i) m_fu nci = fun ci; m_ftablei = fun ci;GetForwardTable();In terpolatio n:l nterpolatio n(
9、)delete m_func;delete m_ftable;void Interpolation:GetForwardTable()/ get the forward differe ntial tableint i, j;for (i=1; i<m_num; +i)for (j=m_num-1; j>=i; -j) m_ftablej = m_ftablej-m_ftablej-1;double x) double In terpolati on:ComputeForwardValue( / compute forward in terpolati on valuedouble
10、 * coef; /coefficient talbedouble result, t;int i;coef = new double m_num;/compute the coefficie nt tablet = (x-m_x1)/m_step;for (i=1, coef0=1; i<m_num; +i)coefi = coefi-1*(t-i+1)/i;for (i=0, result=0; i<m_num; +i) result += m_ftablei*coefi;delete coef;return result;四、算法實現(xiàn)例i當心時求.在范圍m內(nèi)任意他刑的值解:(
11、1) 在程序中輸入11個樣本:0,1,4,9,16,25,36,49,64,81,100且輸入MIN : 0, MAX : 10,樣本容量:11。(2) 在運行程序中輸入范圍內(nèi)的任意.的值,如:1.2, 1.4等。(3) 程序提示答案和提示是否繼續(xù),是則輸入大寫丫,否則輸入大寫NfE3 C A'ind q-a system32cmd,exeInput x: 1_ 2Forward interpolation value = 1-4424Do you uant to process? please input<¥/N>:Y1nput x: 1.4Forward in
12、terpolation ualue: 1.9628Do you want to process? please injiut (¥/N): NPress any key to cont inue , 例2.當給出15個亠:1.38, 1.48, 1.58, 1.69, 1.81,1.94, 2.10, 2.28, 2.50, 2.76,3.06, 3.41, 3.83, 4.33, 4.93,且給出范圍: m 二二二求出任意廠對的值。解:(1) 給出15個題目上顯示的值:1.38, 1.48, 1.58, 1.69, 1.81,1.94, 2.10, 2.28, 2.50, 2.76
13、,3.06, 3.41, 3.83, 4.33, 4.93,且輸入 MIN : 4000, MAX : 11000,樣本容量:15。(2) 在運行程序中輸入范圍內(nèi)的任意的值,如:1001,5200等。(3) 程序提示答案和提示是否繼續(xù),是則輸入大寫 丫,否則輸入大寫Nral C :W i ndowssystem3 2cmd .exeInput x: 4001 Forward interpolation value =3?4?Do sroti viant to process? please input <V/N>:*Input x: 5200Forward inteppolat ion value: 1.61375Douant
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年中國預拉伸板市場調(diào)查研究報告
- 2025年船用動力堆及配套產(chǎn)品項目合作計劃書
- 學校規(guī)范漢字書寫教育方案
- 2025年止血用醫(yī)用生物蛋白膠項目發(fā)展計劃
- 鋼橋:鋼梁防護涂裝工程現(xiàn)場質(zhì)量檢驗報告單
- 2024年中國智能養(yǎng)老行業(yè)市場集中度、投融資動態(tài)及未來趨勢預測報告(智研咨詢發(fā)布)
- 腎病綜合征護理SPAR模式
- 2025年聚碳酸酯原料雙酚A項目發(fā)展計劃
- 中草藥專門零售企業(yè)縣域市場拓展與下沉戰(zhàn)略研究報告
- 公路客運企業(yè)數(shù)字化轉(zhuǎn)型與智慧升級戰(zhàn)略研究報告
- 2024人工智能開源大模型生態(tài)體系研究報告
- Maximo7.5功能介紹和升級原因
- 2024-2030年中國螯合劑類行業(yè)發(fā)展形勢與前景規(guī)劃分析研究報告
- 四年級語文國測模擬試題 (1)附有答案
- 2024年北京政法職業(yè)學院高職單招筆試歷年職業(yè)技能測驗典型例題與考點解析含答案
- DL∕ T 949-2005 水工建筑物塑性嵌縫密封材料技術(shù)標準
- 高考數(shù)學專項練習極值點偏移問題
- 輸變電工程施工質(zhì)量驗收統(tǒng)一表式附件1:線路工程填寫示例
- 《金融科技學》教案 及 習題答案 (李建軍 版)
- 基金應知應會專項考試題庫(證券類190題)附有答案
- 拉森鋼板樁圍堰施工專項方案詳細
評論
0/150
提交評論