Quantcast
Viewing all articles
Browse latest Browse all 164

why doesn't fsolve command return the same equations when trying to numerically solve a system of equations such as: x[j-1]-2x[j]+x[j+1]=0, j=3...98?

why doesn't fsolve command return the same equations when trying to numerically solve a system of equations such as: x[j-1]-2x[j]+x[j+1]=0,  j=3...98?

 

how do you fix the solve command so epsilon is equal to 10e-6 such as in C++ code below:

 

double epsilon = 1e-6; 
double x = 1.0; 
double f = x*x - 2; 
double Df = 2*x; 
while (fabs(f) > epsilon) { 
cout << x << endl; 
x -= f/Df; 
f = x*x - 2; 
Df = 2*x; } 
cout << x << endl;

 


Viewing all articles
Browse latest Browse all 164

Trending Articles