Your question is Root Finding With Binary Search. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
In a Siemens NX geometry workflow, a parameterized calculation may require finding where a monotonic function reaches zero. Implement a binary-search, or bisection, method to approximate the unique root of a cubic polynomial.
The polynomial is defined as f(x) = a*x^3 + b*x + c, where a > 0 and b >= 0. Given coefficients [a, b, c], an interval [lo, hi], an absolute tolerance, and a maximum iteration count, return an approximation to the root. The input guarantees that f(lo) <= 0 <= f(hi), so the root is within the interval. Return the result rounded to 6 decimal places.
Implement root_binary_search(coefficients, lo, hi, tolerance, max_iterations).
coefficients is a list [a, b, c] of numbers.lo, hi, and tolerance are floating-point numbers.max_iterations is a positive integer.x such that f(x) = 0.At each iteration, evaluate the midpoint and retain the half-interval that still contains the sign change.
a > 0 and b >= 0-10^6 <= a, b, c <= 10^6lo < hif(lo) <= 0 <= f(hi)1e-12 <= tolerance <= 11 <= max_iterations <= 100000def root_binary_search(coefficients, lo, hi, tolerance, max_iterations):