Guest User

Untitled

a guest
Oct 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. Bisection[a0_, b0_, function_, itt_] :=
  2. Module[{},
  3. a = N[a0];
  4. b = N[b0];
  5. m = (a+b)/2;
  6.  
  7. If[function[m] > 0,
  8. a = m,
  9. b = m
  10. ];
  11.  
  12. If[itt < 0,
  13. Return[m],
  14. Return[Bisection[a, b, function, itt--]]
  15. ];
  16. ]
  17.  
  18. f[x_] := x^3 - 5 x + 1;
  19. Bisection[0, 1, f, 7]
Add Comment
Please, Sign In to add comment