Advertisement
Guest User

Metoda bisekcji

a guest
May 30th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.37 KB | None | 0 0
  1. function x = bisekcja(f, xp, xk, N)
  2.  
  3.     a  =  f(xp)
  4.     b = f(xk)
  5.    
  6.     if  (a*b  >  0.0)
  7.         disp("f(x) ma taki sam znak na obydwu końcach badanego przedziału")
  8.     end
  9.    
  10.     for k=1:N
  11.         x  =  (xp + xk)/2
  12.         y  =  f(x)
  13.        
  14.         if   (a*y  < 0)
  15.             xk = x
  16.         else
  17.             xp = x
  18.         end
  19.     end
  20. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement