[Math] Clarification when using the Bisection method

numerical methodsroots

I understand how the Bisection method works: you take an interval and test the end-points and the mid-point. Somewhere in those intervals, there will be a root. You keep swapping the mid-points and end-points to accurately choose the interval with the root, and you repeat (very close to binary search trees).

I'm trying to find the root of:

$$ f(x) = \sqrt{x} – cos(x) $$

On the interval $ [0,1] $

I'm not sure how to approach this as it is the first time I've used the Bisection method. I attempted doing:

$$ a=0 ~~;~~ b=1 ~~;~~ c=0.5 $$

And finding which interval to choose, then:

$$ a=0.5 ~~;~~ b=1 ~~;~~ c=0.75 $$

There has to be a better way of doing it other than manually and plugging into the function after every iteration.

Best Answer

First of all the bisection method is a numerical method: it doesn't find the root, it approximates it. You would have to be very lucky to stumble on the exact root of $f$, even after many iterations.
Although it may be impossible to analytically find roots for transcendental equations such as these, we can, in this case, prove that $\exists! \ \xi: 0 < \xi < 1 $ such that $f(\xi) = 0$. This is done by observing that $f(0) = -1 < 0$ and $f(1) = 1 - \cos(1) > 0$. Thus, applying the Intermediate Value Theorem we can conclude that our $\xi$ exists. To prove uniqueness simply note that $f'(x) = \frac{1}{2\sqrt{x}}+\sin(x) > 0$ in $(0, 1)$, so the function is strictly monotone, and therefore can have only one root in $[0,1]$.
Now that we know that there exists a unique root of $f$ in $[0,1]$, and that $f(0) < 0 $ and $f(1) > 0 \ $ we can apply the Bisection Method, which works as you described. After $n$ iterations of the Bisection Method we know that the solution lies in an interval of length $\frac{1}{2^n}$, and therefore by choosing the midpoint of such interval, we have approximated $\xi$ up to an error of $\frac{1}{2^{n+1}}$.
There are better ways to approximate solutions than the Bisection Method: these are better because (under certain circumstances) the convergence toward the solution is faster; the most famous such method is Newton's Method. You can also improve you bisection method by choosing a smaller interval to start with (you can do this by plotting the graph of $f$).
Also, numerical methods are certainly very tedious when carried out with pen and paper; in practical applications they are implemented in softwares such as Matlab.