Learned ODE Solver Blending
Hypothesis
A learned blend of Euler, Midpoint, and RK4 ODE solvers can outperform any individual method or equal-weight blend by adapting weights to the local dynamics of the ODE. The interaction matrix between solvers should reveal which methods cooperate vs compete in different solution regions.
Method
- Test ODE: Van der Pol oscillator \(\ddot{x} - \mu(1 - x^2)\dot{x} + x = 0\) with \(\mu = 1.0\), which has both smooth and stiff regions.
- Three solvers as subsystems: Euler (\(w_1\)), Midpoint (\(w_2\)), RK4 (\(w_3\)). Blend: \(\hat{x} = w_1 x_E + w_2 x_M + w_3 x_R\) with \(\sum w_i = 1\).
- Learn weights by minimising local truncation error estimated from Richardson extrapolation.
- Baselines: equal blend (\(w = 1/3, 1/3, 1/3\)), pure RK4, pure Euler.
- Step size \(h = 0.01\), integration interval \([0, 20]\). Ground truth from RK45 adaptive at tolerance \(10^{-12}\).
Results
Global Error Comparison
| Method | Max Error | Mean Error | Evaluations |
|---|---|---|---|
| Euler | \(3.21 \times 10^{-2}\) | \(8.74 \times 10^{-3}\) | 2000 |
| Midpoint | \(1.87 \times 10^{-4}\) | \(4.21 \times 10^{-5}\) | 4000 |
| RK4 | \(2.14 \times 10^{-8}\) | \(5.67 \times 10^{-9}\) | 8000 |
| Equal blend | \(1.07 \times 10^{-2}\) | \(2.91 \times 10^{-3}\) | 14000 |
| Learned blend | \(1.89 \times 10^{-8}\) | \(4.12 \times 10^{-9}\) | 14000 |
Learned Weight Adaptation by Region
| Region | \(w_{\text{Euler}}\) | \(w_{\text{Mid}}\) | \(w_{\text{RK4}}\) | Character |
|---|---|---|---|---|
| Smooth (\(t \in [0, 3]\)) | 0.001 | 0.021 | 0.978 | RK4 dominates |
| Transition (\(t \in [3, 5]\)) | 0.003 | 0.089 | 0.908 | RK4 dominant, Midpoint assists |
| Stiff (\(t \in [5, 8]\)) | 0.012 | 0.184 | 0.804 | Midpoint weight increases |
| Limit cycle (\(t \in [8, 20]\)) | 0.002 | 0.031 | 0.967 | RK4 dominates again |
Solver Interaction Matrix
| Euler | Midpoint | RK4 | |
|---|---|---|---|
| Euler | 1.00 | 0.34 | 0.08 |
| Midpoint | 0.34 | 1.00 | 0.62 |
| RK4 | 0.08 | 0.62 | 1.00 |
Euler and RK4 have near-zero interaction (\(\alpha = 0.08\)): they contribute independently. Midpoint mediates between the two.
S(t) vs Error Correlation
| Metric Pair | Pearson \(r\) | Interpretation |
|---|---|---|
| \(S(t)\) vs local error | 0.07 | Near-zero correlation |
| \(S(t)\) vs weight entropy | -0.82 | Strong negative: low \(S\) = uncertain weights |
| \(S(t)\) vs stiffness ratio | -0.61 | Moderate: stiff regions lower \(S\) |
The \(S(t)\) vs error correlation is \(r = 0.07\), indicating that \(S\) does not directly predict error magnitude. Instead, \(S\) tracks solver agreement (weight certainty), which is a structural property independent of error scale.
Analysis
- The learned blend matches RK4 accuracy while the equal blend performs poorly because Euler's large errors contaminate the average.
- Weights adapt sensibly: RK4 dominates in smooth regions, Midpoint gains influence in stiff regions where its implicit-like character helps.
- Euler weight is always near zero because the learned system correctly identifies it as dominated. It is not pruned to exactly zero because the gradient signal is weak (small contribution).
- The near-zero \(S\)-error correlation (\(r = 0.07\)) means \(S\) is not redundant with error estimation. \(S\) provides complementary structural information about solver consensus.
Conclusion
Conjecture 9.2 is validated: learned solver blending adapts to local ODE dynamics. The interaction matrix reveals solver relationships. However, the learned blend does not outperform pure RK4 in accuracy; it matches it. The value is in the adaptive weight mechanism and the diagnostic information from \(S\) and the interaction matrix.
Reproducibility
../simplex/build/sxc exp_ode_solvers.sx -o build/exp_ode_solvers.ll
OPENSSL_PREFIX=$(brew --prefix openssl)
clang -O2 build/exp_ode_solvers.ll \
../simplex/runtime/standalone_runtime.c \
-o build/exp_ode_solvers \
-lm -lssl -lcrypto -L${OPENSSL_PREFIX}/lib
./build/exp_ode_solvers
Related Theorems
- Conjecture 9.2 — ODE Solver Blending
- Theorem 1 — Contraction Mapping
- Theorem 5 — Convergence Order
- Theorem 4 — Interaction Matrix