先使用牛頓向前的內插多項式
============================
x f(x) 第一項P'n(x) 前二項P'n(x) 前三項P'n(x)
0.5 0.4794
0.6 0.5646
0.8 0.7174
1.05 0.8674
============================
/* ex3-3.c is for developing the divided-defference
* table for Newton Interpolation polynomial.
*/
#include <stdio.h>
void main()
{
int i,j,n=3;
double x[]= {0.5 , 0.6 , 0.8 , 1.05};
double f[40][40];
f[0][0] = 0.4794;
f[1][0] = 0.5646;
f[2][0] = 0.7174;
f[3][0] = 0.8674;
printf("\n Divided Difference Table:\n");
printf(" =========================\n");
for(j=1;j<=n;j++)
{
for(i=0;i<=n-j;i++)
{
f[i][j]=(f[i+1][j-1]-f[i][j-1])/(x[i+j]-x[i]);
}
}
printf("i x(i) f(i) f(i,i+1) f(i,i+1.i+2), ......\n");
for(i=0;i<=n;i++)
{
printf("%d %8.5lf ",i,x[i]);
for(j=0;j<=n-i;j++)
{
printf("%8.5lf ",f[i][j]);
}
printf("\n");
}
return;
}
Divided Difference Table:
=========================
i x(i) f(i) f(i,i+1) f(i,i+1.i+2), ......
0 0.50000 0.47940 0.85200 -0.29333 -0.12929
1 0.60000 0.56460 0.76400 -0.36444
2 0.80000 0.71740 0.60000
3 1.05000 0.86740
到網站
輸入方程式
\frac{d}{dx}\left(0.47940\:+\:\:0.85200\:\left(x-0.5\right)\:-0.29333\:\left(x-0.5\right)\left(x-0.6\right)\:-\:0.12929\:\left(x-0.5\right)\left(x-0.6\right)\:\left(x-0.8\right)\right)
求解
=0+0.852-0.29333\left(2x-1.1\right)-0.12929\left(3x^2-3.8x+1.18\right)
沒有留言:
張貼留言