Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [x] = bisection_method(a, b, max_error, my_function)
- x_0 = feval(my_function, (a+b)/2);
- x = (a+b)/2;
- if abs(b-a) < max_error || x_0 == 0
- return;
- end
- if x_0*feval(my_function, a) < 0
- x = bisection_method(a, x, max_error, my_function);
- end
- if x_0*feval(my_function, b) < 0
- x = bisection_method(x, b, max_error, my_function);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement