Advertisement
DMG

SONE :: Secant method

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