Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. NEWTON MATLAB
  2.  
  3. h=0.01;
  4. f= @(x) x.^3+x.^2-20*x;
  5. df= @(x) (f(x+h)-f(x))/h;
  6. ddf= @(x) (f(x+2*h)-2*f(x+h)+f(x))/(h^2);
  7. x = 6;
  8. a = 0;
  9. b = 6;
  10. k = 0;
  11. while ( df(x) > 0.001 )
  12. x1=x-(df(x)/ddf(x));
  13. k=k+1;
  14. x=x1;
  15. end
  16. wynik_newton = x
  17. n_newton = k
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement