Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool newton(FuncPointer f, double* x, double* Df){
- double y[2];
- while(true){
- f(x, y, Df);
- if(fabs(y[0]) > 1e-14 || fabs(y[1]) > 1e-14){
- double g = (Df[0]*Df[4]) - (Df[1] * Df[3]);
- double new_x1 = (-Df[4] / g * y[0]) + (Df[1] / g * y[1]);
- double new_x2 = (Df[3] / g * y[0]) + (-Df[0] /g * y[1]);
- x[0] = x[0] + new_x1;
- x[1] = x[1] + new_x2;
- if(fabs(y[0] - y[1]) > 10)
- return false;
- }
- else
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement