Problem statement
Write a program that uses the bisection algorithm to find a root of
the equation x2 − 2 = 0.
The method of successive bisection works as follows: Start with a lower bound l and an
upper bound u such that f(l)*f(u) > 0, ie, f(l) and f(u) are of opposite signs. Then there is
a foot of f(x) between l and u. Write a loop where in each iteration, you compute the
middlepoint (mid) of the current interval [l, u]. Evaluate f(mid), and based on the sign of
f(mid), change the current interval to [l, mid] or to [mid, u]. The loop terminates when
width of the interval becomes smaller than 10−6