欢迎来到天天文库
浏览记录
ID:57420837
大小:736.50 KB
页数:27页
时间:2020-08-16
《数值分析所有代码.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验一:拉格朗日插值多项式命名(源程序.cpp及工作区.dsw):lagrange问题:0.40.550.800.910.410750.578150.888111.026521.17520用四次拉格朗日多项式求的函数近似值//Lagrange.cpp#include#include#defineN4intcheckvalid(doublex[],intn);voidprintLag(doublex[],doubley[],doublevarx,intn);doubleLagrange(doublex[],doubley[],doublevar
2、x,intn);voidmain(){doublex[N+1]={0.4,0.55,0.8,0.9,1};doubley[N+1]={0.41075,0.57815,0.88811,1.02652,1.17520};doublevarx=0.5;if(checkvalid(x,N)==1){printf("插值结果:P(%f)=%f",varx,Lagrange(x,y,varx,N));}else{printf("结点必须互异");}getch();}intcheckvalid(doublex[],intn){inti,j;for(i=0;i3、(j=i+1;j4、u);fenzi=1;for(j=0;j5、h>#include#include#defineN4intcheckvaild(doublex[],intn){inti,j;for(i=0;i6、3][0]=y[3];f[4][0]=y[4]}for(j=1;j7、,1,1,1,1};printf("itXitF(Xi)t1阶t2阶tt3阶t4阶");printf("--------------------------------------------------------------------------------");for(i=0;i
3、(j=i+1;j4、u);fenzi=1;for(j=0;j5、h>#include#include#defineN4intcheckvaild(doublex[],intn){inti,j;for(i=0;i6、3][0]=y[3];f[4][0]=y[4]}for(j=1;j7、,1,1,1,1};printf("itXitF(Xi)t1阶t2阶tt3阶t4阶");printf("--------------------------------------------------------------------------------");for(i=0;i
4、u);fenzi=1;for(j=0;j5、h>#include#include#defineN4intcheckvaild(doublex[],intn){inti,j;for(i=0;i6、3][0]=y[3];f[4][0]=y[4]}for(j=1;j7、,1,1,1,1};printf("itXitF(Xi)t1阶t2阶tt3阶t4阶");printf("--------------------------------------------------------------------------------");for(i=0;i
5、h>#include#include#defineN4intcheckvaild(doublex[],intn){inti,j;for(i=0;i6、3][0]=y[3];f[4][0]=y[4]}for(j=1;j7、,1,1,1,1};printf("itXitF(Xi)t1阶t2阶tt3阶t4阶");printf("--------------------------------------------------------------------------------");for(i=0;i
6、3][0]=y[3];f[4][0]=y[4]}for(j=1;j7、,1,1,1,1};printf("itXitF(Xi)t1阶t2阶tt3阶t4阶");printf("--------------------------------------------------------------------------------");for(i=0;i
7、,1,1,1,1};printf("itXitF(Xi)t1阶t2阶tt3阶t4阶");printf("--------------------------------------------------------------------------------");for(i=0;i
此文档下载收益归作者所有