Professional Documents
Culture Documents
#include<stdlib.h>
void main()
int n;
float x,y;
float f=0,g=0,h=0,k=0;
float a,b,c,d;
float det;
float P[4][4],P1[4][4];
int i,j;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%f",&x);
scanf("%f",&y);
x2=x2+x;
x3=x3+pow(x,2);
x4=x4+pow(x,3);
x5=x5+pow(x,4);
x6=x6+pow(x,5);
x7=x7+pow(x,6);
f=f+y;
g=g+y*pow(x,1);
h=h+y*pow(x,2);
k=k+y*pow(x,3);
P[0][0]=n;
P[0][1]=x2;
P[0][2]=x3;
P[0][3]=x4;
P[1][0]=x2;
P[1][1]=x3;
P[1][2]=x4;
P[1][3]=x5;
P[2][0]=x3;
P[2][1]=x4;
P[2][2]=x5;
P[2][3]=x6;
P[3][0]=x4;
P[3][1]=x5;
P[3][2]=x6;
P[3][3]=x7;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
printf("P[%d][%d]=%f\t",i,j);
break;
}
det = (- x7*x2*x2*x5 + x2*x2*x6*x6 + 2*x7*x2*x3*x4 - 2*x2*x3*x5*x6 - 2*x2*x4*x4*x6 +
2*x2*x4*x5*x5 - x7*x3*x3*x3 + 2*x3*x3*x4*x6 + x3*x3*x5*x5 - 3*x3*x4*x4*x5 + x1*x7*x3*x5 -
x1*x3*x6*x6 + x4*x4*x4*x4 - x1*x7*x4*x4 + 2*x1*x4*x5*x6 - x1*x5*x5*x5);
//P(t)Ax=P(t)Q
Q[0]=f;
Q[1]=g;
Q[2]=h;
Q[3]=k;
printf("a=%f\n",a);
printf("b=%f\n",b);
printf("c=%f\n",c);
printf("d=%f\n",d);
printf("polynomial is %f+%fx+%fx^2+%fx^3",a,b,c,d);