Advertisement
DMG

SONE :: Regula falsi

DMG
Nov 8th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.44 KB | None | 0 0
  1. function [x] = regula_falsi_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.         if (feval(my_function, b) * feval(my_function, x) < 0)
  11.             a = x;
  12.         else
  13.             b = x;
  14.         end
  15.     end
  16.  
  17. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement