Question
Write a Python function bisection(f, a, b, tol=1e-6) that implements the Bisection Method:
- Raise a
ValueErrorif $f(a)$ and $f(b)$ have the same sign (no root guaranteed) - At each iteration print: iteration number, $a$, $b$, midpoint $c$, $f(c)$
- Stop when $|b - a| < tol$
Apply it to $f(x) = x - \cos(x)$ on $[0, 1]$ with tolerance $10^{-6}$. Report the root and how many iterations were needed.