Fix fixed-step Newton tolerance for complex states - #4213
Merged
ChrisRackauckas merged 1 commit intoAug 11, 2026
Merged
Conversation
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Member
Author
ChrisRackauckas
marked this pull request as ready for review
August 11, 2026 14:33
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.
Please ignore this PR until it has been reviewed by @ChrisRackauckas.
What changed and why
Fixed-step in-place Newton derived its LinearSolve relative tolerance with
eps(eltype(dz)). For complex states,dzis complex andeps(ComplexF64)is undefined. This derives the tolerance from the corresponding real scalar instead and adds fixed-step complex-state regressions for bothImplicitEMandISSEM.Fixes SciML/DifferentialEquations.jl#1161
Verification
Failing before
The regression body matching the checked-in in-place problem was run before the source change:
julia +1.12 --project=lib/StochasticDiffEq -e 'using ADTypes, StochasticDiffEq, Test; tspan=(0.0,1.0); u0=ones(2,4)+im*ones(2,4); function f(du,u,p,t); t isa Complex && error("time is complex"); du .= 1.01u; end; prob=SDEProblem(f,f,u0,tspan); @testset "issue 1161 regression" begin for alg in (ImplicitEM(autodiff=AutoFiniteDiff()),ISSEM(autodiff=AutoFiniteDiff())); sol=solve(prob,alg;adaptive=false,dt=0.01); @test eltype(sol.t)==Float64; @test eltype(sol.u[end])==ComplexF64; end; end'Both algorithms were also reproduced independently on clean master with the same
eps(ComplexF64)error. The introducing commit was f231f6c.Passing after
The identical regression command passed:
The full relevant Stochastic group passed without using shared compiled-module caches:
JULIA_PKG_PRECOMPILE_AUTO=0 GROUP=Interface1 julia +1.12 --project=. -e 'using Pkg; Pkg.test(; julia_args=["--compiled-modules=no"])'Formatting and spelling checks all exited 0 with no output:
Pre-existing local check failures
GROUP=Coreinlib/OrdinaryDiffEqNonlinearSolve: 112 passed, 1 failed. The failure is a deterministicnjacsassertion caused by resolving registered sibling releases. All-local master is already fixed by Fix clean-master solver package test regressions #4144.GROUP=QAinlib/OrdinaryDiffEqNonlinearSolveon Julia 1.12.6: JET reported five possibly-undefined locals (12 passed, 1 failed, 33 broken). This reproduces on clean master with JET 0.11.5/0.11.6; Julia 1.11/JET 0.9.20 and JET 0.10.15 pass. A separate isolated control-flow refactor makes JET 0.11.6 pass without suppressions.GROUP=StochasticDiffEq_QAroute exited 0, but the current Stochastic subpackage runner has no QA branch and executes zero assertions.Not verified
The docs build was not run because no docs, docstrings, or public API changed.
GROUP=Everything, GPU, downstream, and Julia pre jobs were not run.Reviewer attention
The original issue describes complex-valued time, but clean reproductions keep
eltype(sol.t) == Float64; the complex value is the state correctiondz. The fix is therefore inOrdinaryDiffEqNonlinearSolve, and uses the samereal(one(T))pattern already used for generic roundoff handling in the sublibrary.