Skip to content

Fix RKG1/RKG2 stage times for non-autonomous problems - #3949

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:rkg-stage-times
Jul 23, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:rkg-stage-times

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Important

This PR should be ignored until reviewed by @ChrisRackauckas.

What

Same defect and same construction as the RKL PR (#3948), for the Runge–Kutta–Gegenbauer methods: RKG1/RKG2 evaluated every interior stage at time t, so RKG2 loses an order on any time-dependent problem (order 1.0 on quadrature u' = cos(t), ~1.1–1.2 on Prothero–Robinson). Autonomous problems cannot detect this, which is all the existing tests used.

Fix

Track stage times cⱼ through the same three-term recurrence the stage values satisfy (c₁ = μ̃₁, cⱼ = μⱼcⱼ₋₁ + νⱼcⱼ₋₂ + μ̃ⱼ (+ γ̃ⱼ for RKG2)) and evaluate stage j at t + dt*cⱼ₋₁. Each stage becomes internally consistent, and internal consistency + the verified autonomous order conditions imply the non-autonomous order via the t-augmented autonomous system. The recurrence is a few scalar ops per stage — no measurable cost.

Measured convergence orders (before → after)

RKG2, ℓ∞ order over dts = 2⁻¹⁰..2⁻⁵, forced eigenvalue estimates: order 1.0–1.2 → 2.00 in all eight configurations (Prothero–Robinson + quadrature, oop + iip, fixed-λ + λ∝1/dt). RKG1 remains order 1.00 everywhere. Autonomous convergence unchanged.

Tests

Adds an RKG non-autonomous convergence testset mirroring the RKL one. Ran locally: ODEDIFFEQ_TEST_GROUP=Core Pkg.test() — 213/213 pass. Runic applied.

Part of a stabilized-RK audit; sibling PRs: #3947 (SERK2 in-place fix), #3948 (RKL stage times).

🤖 Generated with Claude Code

https://claude.ai/code/session_015WU5V4PXt8SZ3BpjxdtM7d

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

CI triage (2026-07-18): the failing checks here are pre-existing on master (commit 4e1a434, same base as this PR) and unrelated to this diff:

  • downgrade-sublibraries (9 sublibs, none touched by this PR) — also failing on master's own run.
  • sublibrary-ci / lib/OrdinaryDiffEqStabilizedIRK [QA] — ExplicitImports all_explicit_imports_are_public errors for build_nlsolver/nlsolve!/du_alias_or_new/markfirststage!/dolinsolve/update_W! in StabilizedIRK (a sublib this PR does not modify).

A separate investigation of the master failures is underway and will be filed as its own issue/PR. All checks that exercise this PR's code (lib/OrdinaryDiffEqStabilizedRK Core + QA) pass.

RKG1 and RKG2 evaluated every interior stage at time t with no stage-time
offsets, so RKG2 dropped from order 2 to order 1 on any time-dependent
problem. The existing convergence tests only use autonomous problems and
could not see this.

Track the stage times cⱼ through the same three-term recurrence the stage
values satisfy (c₁ = μ̃₁, cⱼ = μⱼcⱼ₋₁ + νⱼcⱼ₋₂ + μ̃ⱼ (+ γ̃ⱼ for RKG2)),
which makes every stage internally consistent; combined with the existing
autonomous order conditions this gives the non-autonomous order via the
t-augmented autonomous system.

Measured with forced eigenvalue estimates in both the classical (fixed λ,
dt -> 0) and stiff (λ ∝ 1/dt, constant stage count) regimes, on a
Prothero-Robinson problem and on pure quadrature u' = cos(t), in-place and
out-of-place: RKG2 goes from order ~1.0-1.2 to 2.00 in all eight
configurations; RKG1 stays at order 1.00; autonomous convergence is
unchanged. Adds these as tests.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WU5V4PXt8SZ3BpjxdtM7d
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review July 23, 2026 00:13
@ChrisRackauckas
ChrisRackauckas merged commit 26582e1 into SciML:master Jul 23, 2026
112 of 133 checks passed
ChrisRackauckas-Claude pushed a commit to ChrisRackauckas-Claude/OrdinaryDiffEq.jl that referenced this pull request Aug 2, 2026
Rebase of the surviving content of SciML#3902 onto current master.

In the in-place TSRKC2 and TSRKC3 stage loops `th` was assigned inside
the `if (iter < mdeg)` guard. Hoisting it out matches RKC and RKMC2,
which already compute `th` unconditionally.

This is a no-op: `th` is read only by the `th1 = th` on the following
line, which stays inside the guard, so nothing observes the value
computed on the final iteration.

The rest of SciML#3902 landed separately and is already on master:
  - RKL1/RKL2 non-autonomous stage times (SciML#3948)
  - RKG1/RKG2 non-autonomous stage times (SciML#3949)
  - RKC in-place mdeg < 2 handling (SciML#3951)
  - per-algorithm limiter fields, reverted by the author in c34fe7a
    and superseded by solve-level limiters (SciML#3835)

Original commits: 9158496, 05548a5, c34fe7a

Co-Authored-By: Chris Rackauckas <[email protected]>
ChrisRackauckas added a commit that referenced this pull request Aug 2, 2026
…4091)

Rebase of the surviving content of #3902 onto current master.

In the in-place TSRKC2 and TSRKC3 stage loops `th` was assigned inside
the `if (iter < mdeg)` guard. Hoisting it out matches RKC and RKMC2,
which already compute `th` unconditionally.

This is a no-op: `th` is read only by the `th1 = th` on the following
line, which stays inside the guard, so nothing observes the value
computed on the final iteration.

The rest of #3902 landed separately and is already on master:
  - RKL1/RKL2 non-autonomous stage times (#3948)
  - RKG1/RKG2 non-autonomous stage times (#3949)
  - RKC in-place mdeg < 2 handling (#3951)
  - per-algorithm limiter fields, reverted by the author in c34fe7a
    and superseded by solve-level limiters (#3835)

Original commits: 9158496, 05548a5, c34fe7a

Co-authored-by: Sreeram-Shankar <[email protected]>
Co-authored-by: Chris Rackauckas <[email protected]>
ChrisRackauckas added a commit that referenced this pull request Aug 3, 2026
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 #3948/#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 #3950



Claude-Session: https://claude.ai/code/session_01QPE849e5oSrZreh3mkE8AJ

Co-authored-by: ChrisRackauckas-Claude <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants