Repository navigation
Fix SERK2 stage times for non-autonomous problems - #4108
Merged
ChrisRackauckas merged 1 commit intoAug 3, 2026
Merged
Conversation
SERK2 passed each f evaluation the time of the stage it was *producing* rather than the stage it was *evaluating at*, an off-by-one in the same family as the RKL/RKG fixes in SciML#3948/SciML#3949. Stage j of block i sits at t + (j^2 + (i-1)*internal_deg^2)*alpha*dt, but f is applied to the previous stage, so the correct argument uses (j-1)^2, and the leading Euler stage of each block sits at the last stage time of the previous block. Reconstructing the tableau confirms the coefficients themselves are correct: for every mdeg in the tableau, sum(B) = 1, sum(b) = 1 and sum(b .* c) = 0.5 exactly with the internally consistent stage times, while the times the code passed gave 0.5 + O(1/mdeg) - breaking the second-order condition by a fixed amount and dropping the observed order to ~1. On dts = 2^-10..2^-5 with forced eigen_est, order on a Prothero-Robinson problem goes 1.01 -> 2.00 and on pure quadrature u' = cos(t) 0.80 -> 2.00, in-place and out-of-place alike. Autonomous convergence is unchanged. Fixes SciML#3950 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QPE849e5oSrZreh3mkE8AJ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3950.
Root cause
Not what the issue hypothesized. The issue guessed that the
Bᵢtableau and the stage-time layout disagreed and that the SERK2 papers would be needed to resolve it. They don't disagree — the tableau is correct, and the bug is an off-by-one in exactly the same family as #3948 and #3949.perform_step!evaluatedfat the time of the stage it was producing, not the stage it was evaluating at:Applying the recurrence to
u' = 1does givecⱼ = (j² + (i-1)·d²)·α— the issue is right about that — but that is the row sum of the stage being written, whilefis applied touᵢ₋₁. The consistent argument is therefore((j-1)² + (i-1)·d²)·α, and the leading forward-Euler stage of blockisits at the last stage time of blocki-1, i.e.(i-1)·d²·αrather than(1 + (i-1)·d²)·α.Evidence
Reconstructing
AandBfrom the implementation and formingbₗ = Σᵢ Bᵢ Aᵢₗ, for everymdegin the tableau:Σb·c = 1/2holds exactly with the internally consistent times, so the generatedBᵢare fine and no paper/Fortran reference is needed. The shipped times miss the second-order condition byO(1/mdeg), a fixed defect that does not shrink withdt— hence order ~1 rather than 2.Directly probing the times the integrator passes to
fwhile solvingu' = 1(where a stage value equals its own row sum) givesmax|u - t|:Measured convergence
dts = 2⁻¹⁰..2⁻⁵, forcedeigen_est;fixed= 55.0,scaled= 500/dt.u' = cos(t)oopu' = cos(t)oopu' = cos(t)iipu' = cos(t)iipAutonomous convergence is unchanged, as expected.
Tests
Two new testsets in
lib/OrdinaryDiffEqStabilizedRK/test/rkc_tests.jl, mirroring the RKL/RKG ones:SERK2 non-autonomous convergence— Prothero–Robinson and pure quadrature, oop and iip, botheigen_estregimes.SERK2 stage times are internally consistent— probes everyfcall onu' = 1and asserts the stage value equals the time argument. Separates fixed from broken by eight orders of magnitude (4.3e-4 vs 1.4e-12), so it is a tight regression guard.Both fail on master and pass here.
Full group run on this branch:
Runic clean.
Note on ESERK4/ESERK5
The issue's closing note that ESERK4/ESERK5 are unaffected holds up. Their stage times are laid out differently (the time argument lags by one stage but is recomputed from a global stage counter that does not reset per block), and probing
u' = 1shows a 0.053/0.057 discrepancy against the stage row sums — but it does not cost them order. Measuring on adtrange where the error is above roundoff, on the same quadrature problem:At the
dts = 2⁻¹⁰..2⁻⁵used for SERK2 above, ESERK errors are already down at 1e-13, so an order estimate there measures roundoff rather than truncation. Nothing to fix here.🤖 Generated with Claude Code
https://claude.ai/code/session_01QPE849e5oSrZreh3mkE8AJ