Drawing Separatrices: Phase Portraits & Lyapunov Spectra in Rust
Why qualitative geometry beats squinting at time series when studying nonlinear oscillators and bifurcations.
Contents
After eight years of teaching applied mathematics and dynamical systems at UNAM, I noticed the same turning point in almost every student: differential equations stop feeling like symbolic gymnastics the moment you see a phase portrait deform as a single parameter crosses a bifurcation.
That itch grew into Separatrix, a desktop explorer written in Rust and Tauri for integrating ODEs, tracing invariant manifolds, and estimating Lyapunov spectra interactively.
1. The Van der Pol Oscillator
A canonical bridge between linear intuition and nonlinear self-sustained oscillation is the Van der Pol system:
For , trajectories inside the unit neighborhood experience negative damping and spiral outward, while large-amplitude states dissipate energy and spiral inward. Regardless of where you start (away from the unstable origin), every orbit converges onto the same closed limit cycle.
As increases past , the system becomes stiff: fast horizontal jumps alternate with slow relaxation along the cubic nullcline . Fixed-step RK4 quickly blows up unless the step size shrinks dramatically, which is why adaptive Dormand–Prince (RK45) or implicit Rosenbrock integrators are essential for responsive interactive plotting.
2. Computing the Maximal Lyapunov Exponent
To quantify sensitive dependence on initial conditions in higher-dimensional systems (like Lorenz or Rössler), we integrate the state alongside a tangent perturbation governed by the Jacobian :
Periodic Gram–Schmidt re-orthonormalization keeps the tangent vectors from overflowing floating-point exponents or collapsing onto the single most expanding direction.
/// Single Benettin renormalization step for the maximal Lyapunov exponent.
pub fn benettin_step(tangent: &mut [f64], log_sum: &mut f64) {
let norm = tangent.iter().map(|v| v * v).sum::<f64>().sqrt();
if norm > 0.0 {
*log_sum += norm.ln();
for v in tangent.iter_mut() {
*v /= norm;
}
}
}3. Keeping Math Connected to Code
One design rule I carried over from my Spanish-language course notes at Biología Matemática is that every visualization should make its numerical assumptions visible: tolerance, integrator order, and step rejections. Pretty curves are easy to fake; honest phase portraits tell you when the solver is struggling.
Comments
0 commentsNo comments yet — pull up a chair and leave the first note below.
Leave a comment
Supports inline
`code`,*italic*, and**bold**.