Advertisement
DMG

SONE :: Newton's method

DMG
Nov 8th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.31 KB | None | 0 0
  1. function [x] = newton_method(x_0, max_iter, max_error, my_function, function_derivation)
  2.  
  3.     for i = 1:max_iter
  4.        x = x_0 - feval(my_function, x_0)/feval(function_derivation, x_0);
  5.        
  6.        if abs(feval(my_function, x)) < max_error
  7.            return;
  8.        end
  9.        x_0 = x;
  10.        
  11.     end
  12.  
  13. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement