Advertisement
STANAANDREY

falsi rule

Feb 27th, 2023
1,137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.31 KB | None | 0 0
  1. function xc = mfp(f, a, b, k)
  2.     if f(a)*f(b)>0
  3.         error('error');
  4.     end
  5.     for i=1:k
  6.         c = (b*f(a) - a*f(b))/(f(a)-f(b));
  7.         if f(c)==0
  8.             break
  9.         end
  10.         if f(a) * f(c) < 0
  11.             b = c;
  12.         else
  13.             a = c;
  14.         end
  15.     end
  16.     xc = c;
  17. end
  18.  
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement