插值法数值分析课程设计
① 数值分析中的(插值法)
Excel怎样查找表格纵横向两值A、B值相应值
② 数值分析课程设计利用多项式拟合和指数函数拟合题
这种东西也拿出来,还只给30分。太不地道了
③ 数值分析 插值法区分、介绍
插值法的分类与应用内_网络文库容
http://wenku..com/view/5d3d7e1ea8114431b90dd833.html
④ 数值分析课程设计,编制一般迭代法、牛顿法、弦截法求解方程组的计算机程序,并分析它们的特点
C++才是主流语言。。
你是建模用的吗?那可根据语法稍加修改,这个编程实现的难度不大。
#include <iostream>//弦截法
using namespace std;
static int count=1;
double f(double x)
{
return (x*x*x-x-1);
}
int main()
{
double x0,x1,x2;
double e=0.00001;
cout<<"请输入两个初值X0,X1"<<endl;
cin>>x0>>x1;
x2=x1-f(x1)*(x1-x0)/(f(x1)-f(x0));
while(x2-x1>e||x1-x2>e)
{
x0=x1;
x1=x2;
x2=x1-f(x1)*(x1-x0)/(f(x1)-f(x0));
count+=1;
}
cout<<"方程的根为:"<<x2<<endl;
cout<<"迭代的次数为:"<<count<<endl;
return 0;
}
#include<iostream>//简单迭代法
#include<math.h>
using namespace std;
double f(double t0)
{ double t=t0+1;
return pow(t,1.0/3);
}
int main()
{
double a,b,x0,x1,e;
static int count=1;
cout<<"请输入A,B的值"<<endl;
cin>>a>>b;
cout<<"请输入E的值"<<endl;
cin>>e;
x0=(a+b)/2;
x1=f(x0);
while((x1-x0)>e||(x0-x1)>e)
{
count+=1;
x0=x1;
x1=f(x0);
}
cout<<"方程的根为:"<<x1<<endl;
cout<<"迭代次数"<<count<<endl;
return 0;
}
#include <iostream>//牛顿迭代法
using namespace std;
static k=0;
static int count=1;
double newt(double x)
{
return (x*x*x-x-1);
}
int main()
{
double x0,x1,x2;
cout<<"请输入两个初值X0,X1"<<endl;
cin>>x0>>x1;
x2=x1-f(x1)*(x1-x0)/(f(x1)-f(x0));
while(x2-x1>e||x1-x2>e)
{
x0=x1;
x1=x2;
x2=x1-f(x1)*(x1-x0)/(f(x1)-f(x0));
count+=1;
}
cout<<"方程的根为:"<<x2<<endl;
cout<<"迭代的次数为:"<<count<<endl;
return 0;
}
牛顿迭代法是求方程根的重要方法之一,,方法使用函数f(x)的泰勒级数的前面几项来寻找方程f(x) = 0的根。其最大优点是在方程f(x) = 0的单根附近具有平方收敛,而且该法还可以用来求方程的重根、复根。另外该方法广泛用于计算机编程中。
简单迭代法又称逐次迭代法,基本思想是构造不动点方程,以求得近似根。即由方程f(x)=0变换为x=F(x), 然后建立迭代格式
弦截法计算x(k+1)时需要利用前两步信息x(k),x(k-1).免去了Newton法中需要求解一阶导函数的繁琐.
但收敛速度比牛顿法要慢
⑤ 数值分析 插值法 计算实习题求插值
>> clear
>> x=[0 1 4 9 16 25 36 49 64];
>> y=0:8;
>> f=interp1(x,y,y);
>> F=interp1(x,y,y,'spline');
>> f,F
f =
0 1.0000 1.3333 1.6667 2.0000 2.2000 2.4000
2.6000 2.8000
F =
0 1.0000 1.5601 1.8402 2.0000 2.1706 2.3682
2.5806 2.7953
>> clear
>> x=[0 1 4 9 16 25 36 49 64];
>> y=0:8;
>> t=0:0.1:70;
>> f=interp1(x,y,t,'spline');
>> plot(x,y,'k+',t,f,x,y,'r')
>>xlabel('x')
>>ylabel('y')
>>titel('y=x^1/2')
>>grid on
⑥ 数值分析课程设计报告列主元消去发求矩阵行列式的值 及求解线性方程组
你好!具体功能要求发一下,可以尝试完成
⑦ 数值分析计算实习题关于插值法,用C语言编程
①/*拉格朗日差值*/
#include<stdio.h>
#include<conio.h>
#define N 4
void main()
{int checkvalid(double x[],int n);
double Largrange(double x[],double y[],double varx,int n);
double x[N+1]={0.4,0.55,0.8,0.9,1};
double y[N+1]={0.41075,0.57815,0.88811,1.02652,1.17520};
double varx=0.5;
if(checkvalid(x,N)==1)
printf("\n\n插值结果:P(%f)=%f\n",varx,Largrange(x,y,varx,N));
else
printf("输入的插值节点的x值必须互异!");
getch();
}
int checkvalid(double x[],int n)
{int i,j;
for(i=0;i<n+1;i++)
for(j=i+1;j<n+1;j++)
if(x[i]==x[j])
return -1;
else
return 1;
}
double Largrange(double x[],double y[],double varx,int n)
{int k,j;
double A,B,C=1,D=0;
for(k=0;k<=n;k++)
{
C=1;
for(j=0;j<=n;j++)
{if(j!=k)
{
A=(varx-x[j]);
B=(x[k]-x[j]);
C=C*A/B;
}
}
D=D+C*y[k];
}
return D;
}
②/*牛顿插值*/
#include<stdio.h>
#include<conio.h>
#define N 4
int checkvalid(double x[],int n)
{
int i,j;
for(i=0;i<N;i++)
for(j=i+1;j<=N;j++)
{
if(x[i]==x[j])
return(-1);
}
return(1);
}
void chashang(double x[N],double y[N],double f[N][N])
{
int i,j,h;
for(j=0;j<=N;j++)
{
f[j][j]=y[j];
}
for(h=1;h<=N;h++)
{
for(i=0;i<=N-h;i++)
{
f[i][i+h]=(f[i+1][i+h]-f[i][i+h-1])/(x[i+h]-x[i]);
}
}
}
double compvalue(double f[N][N],double x[N],double y[N],double varx)
{
int i;
double t=1.000000,n=y[0];
chashang(x,y,f);
for(i=1;i<=N;i++)
{
t=t*(varx-x[i-1]);
n=n+f[0][i]*t;
}
return n;
printf("the result is %f.",n);
}
void main()
{
int i,j;double varx,x[N],y[N],f[N][N];
printf("input the value of x:");
for(i=0;i<N;i++)
scanf("%f",&x[i]);
if(checkvalid(x,N)==1)
{
printf("input the value of y:");
for(j=0;j<N;j++)
scanf("%f",&y[j]);
printf("input the value of varx:");
scanf("%f",&varx);
compvalue(f,x,y,varx);
}
else
printf("the value of x must be different!\n");
}