Vectorized Bisection Search
x = BISECTION(f,LB,UB,target,tol) uses a few simple lines for a fast bisection search to find array x +/- tol (LB < x < UB) such that f(x) = target.
This function is meant for use in finding roots of functions very quickly for situations where many function calls must otherwise be used and time is very important. This function is designed to be simple and quick, but it has useful applications where it will more quickly find the roots of a function than FZERO, which has more features but must be used in a loop for solving multiple cases.
Any or all of f(scalar), f(n-dim array), LB, UB, target, and tol may be scalars and/or n-dim arrays (where all of size(n-dim array) is the same). The output x will be this size. f will not be evaluated outside of interval specified by LB and UB. f should have only one root. For best results, f should be monotonic.