Hard
Find a Root by Halving
Write
bisect_root(f, lo, hi) that finds x with f(x) = 0 between lo and hi (f(lo) and f(hi) have opposite signs) by halving the interval 60 times. Read a, b, c of f(x) = x³ + ax² + bx + c and an interval lo hi, pass a function for f, and print the root with 4 decimals.Input
a b c, then lo hi.
Output
One number.
Sample 1
Input
0 0 -2 0 2
Output
1.2599
Sample 2
Input
0 -1 0 0.5 3
Output
1.0000
Output appears here