Skip to content

Fix wrong interpolation coefficients for Rodas3, ROS34PW3#3276

Merged
ChrisRackauckas merged 3 commits intoSciML:masterfrom
ChrisRackauckas-Claude:fix-rosenbrock-empty-H-addsteps
Mar 30, 2026
Merged

Fix wrong interpolation coefficients for Rodas3, ROS34PW3#3276
ChrisRackauckas merged 3 commits intoSciML:masterfrom
ChrisRackauckas-Claude:fix-rosenbrock-empty-H-addsteps

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor

Summary

The Rosenbrock consolidation PR (#3102) added a Hermite fallback in _ode_addsteps! for methods with empty H matrices (Rodas3, ROS34PW3, ROS3P, etc.) that computed:

k₁ = dt*f₀ - (u - uprev)
k₂ = 2*(u - uprev) - dt*(f₀ + f₁)

But hermite_interpolant in generic_dense.jl expects k[1] = f₀ and k[2] = f₁ (raw derivative values at endpoints):

u(θ) = (1-θ)*y₀ + θ*y₁ + θ*-1)*((1-2θ)*(y₁-y₀) +-1)*dt*k[1] + θ*dt*k[2])

The mismatch produced wildly wrong interpolated values at saveat points. For example, with du/dt = u*p and Rodas3:

  • Correct u(0.15)3.28 (linear and exact agree)
  • Buggy Hermite u(0.15) = 3.97

This caused wrong saveat values → wrong loss → wrong gradients in SciMLSensitivity stiff adjoint tests (Core2 intermittent failures since March 23).

Fix: Remove the incorrect fallback. Methods with empty H fall through to the generic _ode_addsteps! in generic_dense.jl which correctly stores f₀ and f₁.

Test plan

  • Existing Rosenbrock convergence tests pass
  • SciMLSensitivity Core2 stiff_adjoints tests pass (currently failing for Rodas3, ROS34PW3)

🤖 Generated with Claude Code

ChrisRackauckas and others added 3 commits March 29, 2026 09:10
The Rosenbrock consolidation PR (SciML#3102) added a Hermite fallback in
_ode_addsteps! for methods with empty H matrices that computed:

  k₁ = dt*f₀ - (u - uprev)
  k₂ = 2*(u - uprev) - dt*(f₀ + f₁)

But hermite_interpolant in generic_dense.jl expects k[1] = f₀ and
k[2] = f₁ (raw derivative values at endpoints). The mismatch produced
wildly wrong interpolated values at saveat points (e.g. u(0.15) = 3.97
vs correct 3.28 for the test ODE du/dt = u*p).

Remove the incorrect fallback. Methods with empty H now fall through
to the generic _ode_addsteps! which correctly stores f₀ and f₁ for
standard Hermite interpolation.

Fixes SciML/SciMLSensitivity.jl#1398 (Core2 stiff_adjoints failures).

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Test that sol(t) at intermediate points matches the exact solution
for Rodas3, ROS3P, ROS34PW1a, ROS34PW1b, ROS34PW2, ROS34PW3 — all
methods with empty H matrices that use generic Hermite interpolation.

Tests both OOP and IIP, plus saveat consistency. Uses exponential
decay (du/dt = λ*u) with known exact solution.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- ode_rosenbrock_tests.jl: Add dense_errors=true to convergence tests
  for Rodas3, ROS3P, ROS34PW1a, ROS34PW1b, ROS34PW2, ROS34PW3.
  These methods use generic Hermite interpolation (no H matrix), so
  dense L2 convergence order is 3 (cubic). Ensures the interpolation
  coefficients stored by _ode_addsteps! are correct.

- event_dae_addsteps.jl: Add Rodas3 and ROS34PW3 to the DAE callback
  test that verifies sol(t) accuracy during continuous callback events.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ChrisRackauckas-Claude ChrisRackauckas-Claude force-pushed the fix-rosenbrock-empty-H-addsteps branch from fa725fa to c4d0cc8 Compare March 30, 2026 15:46
@ChrisRackauckas ChrisRackauckas merged commit 23c7524 into SciML:master Mar 30, 2026
84 of 98 checks passed
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