You will find a root of by looking for a change of sign, and halving the gap again and again.
Your tasks.
f, return .halve, start with low and high, where f(low) is negative and f(high) is positive. Repeat steps times: take the middle, and move low to it if f(middle) is negative, otherwise move high. Return the middle at the end.root to halve(1, 2, 30) rounded to decimal places.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…