Intermediate value theorem/Bisection method/3/Method

Let ${\displaystyle {}a\leq b}$ be real numbers, and let ${\displaystyle {}f\colon [a,b]\rightarrow \mathbb {R} }$ denote a continuous function such that ${\displaystyle {}f(a)\leq 0}$ and ${\displaystyle {}f(b)\geq 0}$. Then the function has a zero within the interval, due to the Intermediate value theorem. Such a zero can be found by the bisection method, as described in the proof of the Intermediate value theorem. We put ${\displaystyle {}a_{0}=a}$ and ${\displaystyle {}b_{0}=b}$, and the other interval bounds are inductively defined in such a way that ${\displaystyle {}f(a_{n})\leq 0}$ and ${\displaystyle {}f(b_{n})\geq 0}$ hold. Define ${\displaystyle {}x_{n}={\frac {a_{n}+b_{n}}{2}}}$ and compute ${\displaystyle {}f(x_{n})}$. If ${\displaystyle {}f{\left(x_{n}\right)}\leq 0}$, then we set

${\displaystyle a_{n+1}:=x_{n}\,\,{\text{ and }}\,\,b_{n+1}:=b_{n},}$

and if ${\displaystyle {}f{\left(x_{n}\right)}>0}$, then we set

${\displaystyle a_{n+1}:=a_{n}\,\,{\text{ and }}\,\,b_{n+1}:=x_{n}.}$

In both cases, the new interval ${\displaystyle {}[a_{n+1},b_{n+1}]}$ has half the length of the preceding interval and so we have bisected intervals. The real number ${\displaystyle {}x}$ defined by these nested intervals is a zero of the function.