Skip to content

Newton: report a NaN final residual as a failure to converge - #364

Merged
rveltz merged 1 commit into
bifurcationkit:masterfrom
ParadaCarleton:newton-nan-log
Oct 29, 2026
Merged

rveltz merged 1 commit into
bifurcationkit:masterfrom
ParadaCarleton:newton-nan-log

Conversation

@ParadaCarleton

Copy link
Copy Markdown
Contributor

With verbose = true, solve(prob, Newton(), options) prints "Newton algorithm failed to converge" only when residuals[end] > tol (src/Newton.jl:113). A NaN residual makes that comparison false, so a Newton run that ends on a NaN residual returns converged = false without the message; the same holds for a final residual equal to tol. The returned flag is already right, because line 114 tests residuals[end] < tol. This PR writes the message condition as the negation of that test, !(residuals[end] < tol), so the message appears whenever the flag says the run failed. A new test in test/newton/test_newton.jl checks that a residual function returning NaN logs the error and returns converged = false.

https://claude.ai/code/session_015sE9Latuiqsp6zSHQ1cshz

@rveltz
rveltz merged commit 6619bd8 into bifurcationkit:master Oct 29, 2026
3 of 4 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