pub fn compute_consistent_initial_tol<S, Sys>(
system: &Sys,
t0: S,
y0: &[S],
tol: S,
max_iter: usize,
) -> Result<Vec<S>, String>Expand description
Compute consistent initial conditions with user-specified tolerance.
§Algorithm
Uses Newton iteration with a full Jacobian on the algebraic variable subset:
- Keep differential variables fixed
- Evaluate residual g(t₀, y) on algebraic equations
- Build full Jacobian ∂g/∂y_alg via finite differences
- Solve J_alg * Δy_alg = -g using LU factorization
- Update y_alg += Δy_alg
- Repeat until convergence
This handles coupled algebraic constraints correctly (unlike a diagonal Jacobian approach which fails when constraints share variables).