ode_heun
Solves first-order ODE initial value problems with Heun's predictor-corrector method, returning numerical and exact solutions, error estimates, and an optional plot.
Instructions
Solve y'(x) = f(x, y), y(x0) = y0 with Heun's predictor-corrector method (2nd order).
Args: ecuacion_str: Right-hand side f(x, y). x0, y0: Initial condition. xf: Final x (must be > x0). h: Step size (must be positive). tol: Optional tolerance flag for the final error. precision: Rounding digits. plot: When True, also return a PNG plot of the solution.
Returns:
Dict with the numerical solution, exact solution (when available) and
errors. With plot=True a list [dict, Image] is returned instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| h | Yes | ||
| x0 | Yes | ||
| xf | Yes | ||
| y0 | Yes | ||
| tol | No | ||
| plot | No | ||
| precision | No | ||
| ecuacion_str | Yes |