Quantcast
Channel: MaplePrimes - Questions and Posts tagged with system
Viewing all articles
Browse latest Browse all 164

fsolve function doesnt work on a system of equations

$
0
0
equations:
x[j-1]-2x[j]+x[j+1]=0, j=3...98 where x[j] is x-sub -j
-2x[1]+x[2]=5
x[1]-2x[2]+x[3]=-4
x[98]-2x[99]+x[100]=-8
x[99]-2x[100]=13
 
I'm trying to solve them using Isaac Newton's method for numerical approximation with epsilon equal to 1e-6 such in C++ code below
 
double epsilon=1e-6;
double x=1.0;
double f=x[j-1]-2x[j]+x[j+1] j=3...98; x3-x97+x98=3;
double Df=1-2+1;
while (fabs(f)>epsilon){
cout<<x<<endl;
x-=f/Df
f=x[j-1]-2x[j]+x[j+1] j=3...98; x3-x97+x98=3;
Df=1-2+1;}
cout<<x<<endl;

Viewing all articles
Browse latest Browse all 164

Trending Articles