ode_rk4
Solve ODE initial value problems using the Runge-Kutta 4 method. Input equation, x0, y0, xf, and step size to get numerical solution, exact solution, and per-step errors.
Instructions
Solve an initial value problem y'(x) = f(x, y) with the Runge-Kutta 4 method.
Args: ecuacion_str: Right-hand side f(x, y), e.g. "y" or "-2xy". x0: Initial x. y0: Initial y(x0). xf: Final x (must be > x0). h: Step size (must be positive). The endpoint xf is always reached. tol: Optional tolerance to flag whether the final error meets it. precision: Rounding digits.
Returns: Dict with the numerical solution table, exact solution (when SymPy can solve it) and per-step errors.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| h | Yes | ||
| x0 | Yes | ||
| xf | Yes | ||
| y0 | Yes | ||
| tol | No | ||
| precision | No | ||
| ecuacion_str | Yes |