Advertisement
STANAANDREY

secant mat

Feb 27th, 2023
1,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.19 KB | None | 0 0
  1. function xc = secant(f, x0, x1, k)
  2.     x(1) = x0;
  3.     x(2) = x1;
  4.     for i=2:(k+1)
  5.         x(i+1) = x(i) - f(x(i))*(x(i)-x(i-1))/(f(x(i)) - f(x(i-1)));
  6.     end
  7.     xc = x(k + 2);
  8. end
  9.  
  10.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement