root_bisection
Finds a root of f(x)=0 within an interval using the bisection method, requiring opposite endpoint signs and returning convergence details.
Instructions
Find a root of f(x) = 0 in [a, b] using the bisection method.
Requires f(a) and f(b) to have opposite signs (Bolzano's theorem).
Args: func_str: Math expression in x, e.g. "x**2 - 4". a: Left endpoint of the interval. b: Right endpoint of the interval (must be > a). tol: Convergence tolerance on the residual/error. max_iter: Maximum number of iterations. precision: Rounding digits for the reported root. plot: When True, also return a PNG plot of f(x) and the root.
Returns:
Dict with the root, convergence flag, iteration table and errors.
With plot=True a list [dict, Image] is returned instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes | ||
| tol | No | ||
| plot | No | ||
| func_str | Yes | ||
| max_iter | No | ||
| precision | No |