Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function nst = bisekt (a, b, eps, f)
- if((f(a) * f(b)) >= 0)
- disp("Invalid arguments! f(a) or f(b) must be negative.");
- disp(f(a));
- disp(f(b));
- return;
- endif
- c = (a+b)/2;
- fc = f(c);
- if (abs(fc) < eps)
- nst = c;
- else
- if (fc > 0)
- nst = bisekt(c, b, eps, f);
- else
- nst = bisekt(a, c, eps, f);
- endif
- endif
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement