# Bisection Method for root finding

My university teacher gave us a project. He wants us to create a program which will execute a modified bisection method for a function but not by diving everytime the range by $2$, but by dividing it with a random number. The process stops when $6$ digits precision occurs. My problem is with finding the correct condition for stopping finding roots.

*In classic Bisection when it gives us accuracy (for example, $6$) there's a formula for iterations that says:

Given a function $f$ defined on $(a,b)$,

$N> \frac{ \ln(b-a)-\ln k }{\ln2}$ with

$N$: number of iterations

$k: \frac12 \times 10^{-n}$ with $n$ being the wanted accuracy ($6$ in this example).

Write a while loop, at each step, check the size of interval that you are working on $(a_k,b_k)$, you may stop when $b_k-a_k < 10^{-6}$.
If you know more information about how you are going to draw your random number, such that we know $\frac{b_k-a_k}{b_{k-1}-a_{k-1}} \leq r$ for some constant $r$, you should be able to come out with a closed form.
• what about checking $|b_k-a_k| < 10^{-6}$? note the absolute value since it seems that you are storing one value at a time, which can be either smaller or bigger than the previous value. Commented Dec 21, 2016 at 21:46