Advertisement
kaburen

siecz

Apr 3rd, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.35 KB | None | 0 0
  1. function [wyn] = met_siecznych(g,a,b)
  2. f = @(x)eval(g);
  3. fb = f(b);
  4. fa=f(a);
  5. ep = 0.001;
  6. if(f(a)*f(b)>0)
  7.    disp('punkty  nie spelniaja zalozen')    
  8.    return;
  9. end
  10. while(abs(a-b)>0)
  11.     c = a - fa*(a-b)/(fa-fb);
  12.     fc = f(c);
  13.     if(abs(fc)<ep)
  14.         break;
  15.     end
  16.     a = b;
  17.     fa = fb;
  18.     b = c;
  19.     fb = fc;
  20. end
  21. wyn = [b,c];
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement