Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %fnc - funkcja
- %dfnc - pochodna funkcji
- function [z, iters] = newton(x0, epsilon, max_iter,fnc, dfnc)
- x = x0;
- x1 = x0 - eval(fnc)/eval(dfnc);
- z = [x1];
- i = 0;
- while abs(x0 - x1) > epsilon && i < max_iter,
- i = i + 1;
- x0 = x1;
- x1 = x0 - eval(fnc)/eval(dfnc);
- z = [z; x1];
- end
- iters = i;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement