Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Handle edge-cases of inverted root pairs in the condition rootfinding#1292

Closed
DaniGlez wants to merge 9 commits intoSciML:masterfrom
DaniGlez:master
Closed

Handle edge-cases of inverted root pairs in the condition rootfinding#1292
DaniGlez wants to merge 9 commits intoSciML:masterfrom
DaniGlez:master

Conversation

@DaniGlez
Copy link
Copy Markdown
Contributor

@DaniGlez DaniGlez commented Mar 3, 2026

Closes #1290 (see the issue discussion for context)

Checklist

Additional context

Add any other context about the problem here.

@DaniGlez
Copy link
Copy Markdown
Contributor Author

DaniGlez commented Mar 3, 2026

Also please squash if merging, I was a bit sloppy with the WIP commits 😅

@ChrisRackauckas
Copy link
Copy Markdown
Member

Needs a test

@DaniGlez
Copy link
Copy Markdown
Contributor Author

DaniGlez commented Mar 5, 2026

Test added; I would still like SciML/NonlinearSolve.jl#861 to be merged first, so that the ModAB behavior is consistent (if it hits the buggy path, a slightly different original root might be found)

@DaniGlez
Copy link
Copy Markdown
Contributor Author

DaniGlez commented Mar 5, 2026

Fuzzer script for posterity, in case the test needs to be recreated in the future: https://gist.github.com/DaniGlez/6100f2530fc76d4f9673a8f9f7422564

@DaniGlez
Copy link
Copy Markdown
Contributor Author

DaniGlez commented Mar 5, 2026

I think the JumpProcesses test failure should be solved by SciML/NonlinearSolve.jl#861 as well

@ChrisRackauckas
Copy link
Copy Markdown
Member

It seems like the bracketing methods should just be made better for this, rather than hacking it in here?

@DaniGlez
Copy link
Copy Markdown
Contributor Author

I'd be OK with that. The reason I made it here is because, in the context of a general bracketing problem, if there are multiple numerical roots (ie the condition switches signs multiple times in a small interval, or e.g. if there are multiple zeros in a row) it's not clear which one of the numerical root pairs should be preferred by the solver, whereas in this context we want the first one. One option would be to implement the optional functionality in BracketingNonlinearSolve and just call it from here; would that be acceptable?

@ChrisRackauckas
Copy link
Copy Markdown
Member

it's not clear which one of the numerical root pairs should be preferred by the solver, whereas in this context we want the first one. One option would be to implement the optional functionality in BracketingNonlinearSolve and just call it from here; would that be acceptable?

Yes. @oscardssmith wanted to do a thing where we made it a whole thing: make a brackating problem for it, and develop solvers specifically for it. We'd get a lot more performance out by really specializing this problem more, and it has many other use cases beyond the callback handling. So, taking it to nonlinearsolve in general seems like the right direction.

But at least the trick here, it seems like the solver just gets stuck because of a numerical error, and this just flips the brackets and tells it to solve again. To me, it seems like we should just make sure the solvers don't get stuck, and if their loop needs to do this in order to be accurate, it should get fixed there.

So I'll close given the assumption it's upstreaming.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RightRootFind and LeftRootFind have opposite behavior in some cases

2 participants