Skip to main content

Module ode

Module ode 

Source
Expand description

Ordinary differential equation (ODE) solvers from scratch.

Provides Euler’s method, the classical 4th-order Runge–Kutta (RK4), and adaptive step-size control via the Runge–Kutta–Fehlberg (RKF45) method.

Functions§

euler
Integrate dy/dt = f(t, y) from t0 to t1 with initial condition y0 using Euler’s method with n steps.
euler_step
One step of Euler’s method: y_{n+1} = y_n + h * f(t_n, y_n).
rk4
Integrate dy/dt = f(t, y) from t0 to t1 with initial condition y0 using RK4 with n steps.
rk4_step
One step of classical 4th-order Runge–Kutta (RK4).
rk4_system
RK4 for a system of ODEs: dy_i/dt = f_i(t, y). y0 is the initial state vector; returns the state at t1.
rk4_trajectory
Integrate and return the full trajectory as Vec<(t, y)>.
rkf45
Adaptive RK4(5) — Runge–Kutta–Fehlberg — with automatic step-size control. Integrates dy/dt = f(t, y) from t0 to t1 with initial condition y0. tol is the desired absolute error per step.