资源描述:
《《数值分析》上机习题.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、《数值分析》上机习题1.用Newton法求方程X7-28X4+14=0在(0.1,1.9)中的近似根(初始近似值取为区间端点,迭代6次或误差小于0.00001)。#include#includeintmain(){floatx1,x,f1,f2;staticintcount=0;x1=0.1;//定义初始值do{x=x1;f1=x*(x*x*x*x*x*x-28*x*x*x)+14;f2=7*x*x*x*x*x*x-4*28*x*x*x;//对函数f1求导x1=x-f1/f2;count++;}while(fabs(x1-x)>=1e-
2、5);printf("%8.7f",x1);printf("%d",count);return0;}2.已知函数值如下表:x12345f(x)00.1.1.1.x678910f(x)1.1.2.2.2.f’(x)f’(1)=1f’(10)=0.1试用三次样条插值求f(4.563)及f’(4.563)的近似值。include#include#defineN11main(){doubleB[N+1][N+1],m,x,u[N+1],y[N+1],c[N+1],d[N+1];doublee[N+1]={2,0,4.,6.,8.,9.,
3、10.,11.,12.47667,13.,13.,14.};inti;x=4.563;B[0][0]=-2;B[0][1]=-4;B[N][N-1]=4;B[N][N]=2;for(i=1;i=0;i--)c[i]=(y[i]-
4、B[i][i+1]*c[i+1])/u[i];for(i=0;i<12;i++){m=fabs(x-i);if(m>=2)d[i]=0;elseif(m<=1)d[i]=0.5*fabs(pow(m,3))-m*m+2.0/3;elsed[i]=(-1.0/6.0)*fabs(pow(m,3))+m*m-2*fabs(m)+4/3.0;}m=0;for(i=0;i<12;i++)m=m+c[i]*d[i];printf("f(%4.3f)=%f",x,m);printf("f'(4.563)=%lf",(c[4]-c[2])/2);}3.用Romberg算法求.
5、#include"stdafx.h"#include#includefloatf(floatx){floatf=0.0;f=pow(3.0,x)*pow(x,1.4)*(5*x+7)*sin(x*x);return(f);}main(){inti=1,j,k,n=12;floatT[12],a=1.0,b=3.0,s=0.0;T[0]=0.5*(b-a)*(f(a)+f(b));for(j=1;j6、=0.5*(T[j-1]+(b-a)*s/pow(2,j-1));s=0.0;}T[11]=(4*T[1]-T[0])/(float)3;for(;fabs(T[11]-T[0])>0.00001;i++){T[0]=T[11];for(j=1;j7、=y3y3’=1000-1000y2-100y3(y1(0)=y2(0)=y3(0)=0)h=0.0005,打印yi(0.025),yi(0.045),yi(0.085),yi(0.1),(i=1,2,3)h=0.0005,打印yi(0.025),yi(0.045),yi(0.085),yi(0.1),(i=1,2,3)#include"stdafx.h"#include#includedoubleF(doublex,doubley[4],doublef[4]){f[1]=0*x+0*y[1]+0*y[2