### Bisection method

The bisection method is a root-finding method that applies to any continuous functions for which one knows two values with opposite signs. The method consists of repeatedly bisecting the interval defined by these values and then selecting the subinterval in which the function changes sign, and therefore must contain a root. It is a very simple and robust method, but it is also relatively slow. Because of this, it is often used to obtain a rough approximation to a solution which is then used as a starting point for more rapidly converging methods.

For a given function $f(x)$,the Bisection Method algorithm works as follows:

1. two values a and b are chosen for which $f(a)>0$ and $f(b)<0$ (or the other way around)
2. interval halving: a midpoint $s$ is calculated as the arithmetic mean between $a$ and $b$, $s = \frac{a+b}{2}$
3. the function $f$ is evaluated for the value of $s$
4. if $f(s) = 0$ means that we found the root of the function, which is $s$
5. if $f(s) \neq 0$ we check the sign of $f(s)$:
• if $f(s)$ has the same sign as $f(a)$ we replace $a$ with $s$ and we keep the same value for $b$
• if $f(s)$ has the same sign as $f(b)$, we replace $b$ with $s$ and we keep the same value for $a$
6. we go back to step 2. and recalculate $s$ with the new value of $a$ or $b$

Visualisation for Bisection method is displayed in figure below. $a_1$ and $b_1$ are initial bounderies. Drag them.

 You may change the function term here: f(x) = and set the number of iterations: 10