Hi, this is more of a math/linear algebra question. In the pdf you need to find v in order to make everything work... where the heck is v coming from? I see the equations and all, but what does it all mean, and how would you write that in c++?
Code:
#include <stdio.h>
#include <math.h>
#include <sys/syslimits.h>
#include <std.lib>
double determinant(double M);
double main(void)
{
char filename[PATH_MAX+1];
printf("enter input file name =>"); /* prompt user for file name */
scanf("%s", filename); /* store in filename[] buffer */
#define MAXPOINTS 100
int i, N;
double t[MAXPOINTS];
double y[MAXPOINTS];
FILE *f; /* pointer to FILE (used for file I/O) */
f = fopen(filename, "r"); /* open input file for reading */
if (f == NULL) /* fopen unsuccessful */
{
perror(filename); /* print system error message */
exit(-1); /* die */
}
for (i = 0; i < MAXPOINTS; i++)
if (fscanf(f, "%lf %lf", &t[i], &y[i]) != 2)
break;
fclose(f);
N = i;
double sumt, sumtt, sumttt, sumtttt; /* sums for t, t^2, t^3, t^4 */
double sumy, sumty, sumtty; /* sums for y, t*y, t^2*y */
double M[3][3], v[3]; /* system we are solving: Mx = v */
double x[3]; /* solution: x = [a b c] */
}
double determinant(double M[3][3]){
return ((-1)*M[2][0]*M[1][1]*M[0][2]+(-1)*M[2][1]*M[1][2]*M[0][0]+
(-1)*M[2][2]*M[1][0]*M[0][1]+M[0][0]*M[1][1]*M[2][2]+M[0][1]*M[1][2]*M[2][0]+
M[0][2]*M[1][0]*M[2][1]);
}
void solve(double M[3][3], double v[3], double x[3])
{
double det = determinant(M);
double A[3][3];
A[0][0]=v[0][0];
A[1][0]=v[1][0];
A[2][0]=v[2][0];
X[0]= determinant(A)/det;
X[1]= determinant(A)/det;
X[2]= determinant(A)/det;
}
this is all that I have so far, and I know that I'm not done yet. Thanks for the help!
-Jonbuckets