Skip to main content

Module dense

Module dense 

Source
Expand description

General-dimension numerical methods (Calculus plan §4.4).

The original solvers in super (RungeKutta4Static, ShootingMethodBVP, SimpsonsIntegratorChunked) are fixed at [f64; 4] / scalar — the same toy-sizing the linear-algebra and optimisation solvers once had. This module generalises them to arbitrary state dimension on heap Vec<f64>, reusing the engine’s canonical dense LU solve (crate::solvers::linear_algebra::lu::lu_solve) for the BVP Newton correction — no re-implemented linear algebra. These are the allocate-friendly authoring-path versions; the zero-heap [f64; 4] solvers remain for the hot path.

Functions§

rk4_integrate
Integrate y' = f(t, y) from t0 to t1 in steps equal RK4 steps; returns the final state. steps is clamped to ≥ 1.
rk4_solve
Full trajectory [(t, y)], including the initial point, over steps RK4 steps.
rk4_step
One classical RK4 step of y' = f(t, y) for a state of any dimension. f returns the derivative vector, which must have the same length as y.
shooting_bvp
Shooting-method boundary-value solver for a first-order system y' = f(t, y) of dimension n. The components of the initial state listed in free are the unknowns; they are chosen by Newton’s method so the user residual(y(t1)) (length = free.len()) is driven to zero. The Jacobian is built by forward finite differences and solved with the canonical lu_solve. Returns the converged initial state, or None if it fails to converge within max_iter (or the Jacobian is singular).
simpson
Composite Simpson’s rule for a scalar integrand over [a, b] with panels subintervals (forced even, ≥ 2). The general-N version of the fixed 100-chunk solver in super.
simpson_vec
Composite Simpson’s rule for a vector-valued integrand g: t → ℝᵏ, integrated component-wise (e.g. a vector field along a parameter, or a state trajectory). The output length is the length of g(a); panels is forced even and ≥ 2.