@@ -116,3 +116,22 @@ prob = ODEProblem(sys, u0, (0, 11.5), sparse = true, jac = true)
116116 @test W! (similar (W_prototype, Float64), u, p, γ, t) ==
117117 0.1 * M + jac! (similar (W_prototype, Float64), u, p, t)
118118end
119+
120+ @testset " Issue#3556: Numerical accuracy" begin
121+ t = ModelingToolkit. t_nounits
122+ D = ModelingToolkit. D_nounits
123+ @parameters g
124+ @variables x (t) y (t) [state_priority = 10 ] λ (t)
125+ eqs = [D (D (x)) ~ λ * x
126+ D (D (y)) ~ λ * y - g
127+ x^ 2 + y^ 2 ~ 1 ]
128+ @mtkbuild pend = ODESystem (eqs, t)
129+ prob = ODEProblem (pend, [x => 0.0 , D (x) => 1.0 ], (0.0 , 1.0 ), [g => 1.0 ];
130+ guesses = [y => 1.0 , λ => 1.0 ], jac = true , sparse = true )
131+ J = deepcopy (prob. f. jac_prototype)
132+ prob. f. jac (J, prob. u0, prob. p, 1.0 )
133+ # this currently works but may not continue to do so
134+ # see https://github.com/SciML/ModelingToolkit.jl/pull/3556#issuecomment-2792664039
135+ @test J == prob. f. jac (prob. u0, prob. p, 1.0 )
136+ @test J ≈ prob. f. jac (prob. u0, prob. p, 1.0 )
137+ end
0 commit comments