-
-
Notifications
You must be signed in to change notification settings - Fork 38
feat: improve performance of the nonlinear functions #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
ChrisRackauckas
approved these changes
Apr 19, 2025
ErikQQY
approved these changes
Apr 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I am wondering if the failures of BVProblemLibrary.jl are real? I can't reproduce the same error locally.
ChrisRackauckas
added a commit
to SciML/NonlinearSolve.jl
that referenced
this pull request
Apr 23, 2025
This update is required due to SciML/DiffEqProblemLibrary.jl#138. Its inherently just a numerical instability. https://github.com/SciML/DiffEqProblemLibrary.jl/pull/138/files#diff-416284a99fdfe358ae2a33c649aa3a715568ff3cf4d0d0cf62e6c7a183aa9fc7R111 this change is effectively random, looking at: ```julia zz = out[1] + 3.0 * x[1] - 2.0 * x[1] * x[2] + 2.0 * x[1]^3 zzz = out[2] + x[2] - x[2]^2 - 1.0 out[1] += x[1] * (3.0 - 2.0 * x[2] + 2.0 * x[1]^2) out[2] += x[2] * (1.0 - x[2]) - 1.0 if abs(out[1] - zz) > 1e5 @show out[1] - zz, out[2] - zzz, x[1], x[2] @show 2.0 * x[2], 2.0 * x[1]^2 @show 3.0 * x[1], 2.0 * x[1] * x[2], 2.0 * x[1]^3 error() end ``` I get: ``` (out[1] - zz, out[2] - zzz, x[1], x[2]) = (-2048.0, 0.0, 1.032129073975807e6, -1.109530258395812e6) (2.0 * x[2], 2.0 * x[1] ^ 2) = (-2.219060516791624e6, 2.130580850692314e12) (3.0 * x[1], 2.0 * x[1] * x[2], 2.0 * x[1] ^ 3) = (3.096387221927421e6, -2.2903568762924146e12, 2.1990344404556452e18) ``` ``` (out[1] - zz, out[2] - zzz, x[1], x[2]) = (-4.503599627370496e15, 0.0, 2.027697193465798e10, -3.714249421601087e10) (2.0 * x[2], 2.0 * x[1] ^ 2) = (-7.428498843202174e10, 8.223111816778149e20) (3.0 * x[1], 2.0 * x[1] * x[2], 2.0 * x[1] ^ 3) = (6.0830915803973946e10, -1.5062746256024978e21, 1.6673980752436494e31) ``` with different thresholds. Basically when `x[1]` is large the error is floating point noise, and that floating point noise is enough for Broyden to be stable vs unstable.
5 tasks
ChrisRackauckas
added a commit
to SciML/NonlinearSolve.jl
that referenced
this pull request
Apr 23, 2025
This update is required due to SciML/DiffEqProblemLibrary.jl#138. Its inherently just a numerical instability. https://github.com/SciML/DiffEqProblemLibrary.jl/pull/138/files#diff-416284a99fdfe358ae2a33c649aa3a715568ff3cf4d0d0cf62e6c7a183aa9fc7R111 this change is effectively random, looking at: ```julia zz = out[1] + 3.0 * x[1] - 2.0 * x[1] * x[2] + 2.0 * x[1]^3 zzz = out[2] + x[2] - x[2]^2 - 1.0 out[1] += x[1] * (3.0 - 2.0 * x[2] + 2.0 * x[1]^2) out[2] += x[2] * (1.0 - x[2]) - 1.0 if abs(out[1] - zz) > 1e5 @show out[1] - zz, out[2] - zzz, x[1], x[2] @show 2.0 * x[2], 2.0 * x[1]^2 @show 3.0 * x[1], 2.0 * x[1] * x[2], 2.0 * x[1]^3 error() end ``` I get: ``` (out[1] - zz, out[2] - zzz, x[1], x[2]) = (-2048.0, 0.0, 1.032129073975807e6, -1.109530258395812e6) (2.0 * x[2], 2.0 * x[1] ^ 2) = (-2.219060516791624e6, 2.130580850692314e12) (3.0 * x[1], 2.0 * x[1] * x[2], 2.0 * x[1] ^ 3) = (3.096387221927421e6, -2.2903568762924146e12, 2.1990344404556452e18) ``` ``` (out[1] - zz, out[2] - zzz, x[1], x[2]) = (-4.503599627370496e15, 0.0, 2.027697193465798e10, -3.714249421601087e10) (2.0 * x[2], 2.0 * x[1] ^ 2) = (-7.428498843202174e10, 8.223111816778149e20) (3.0 * x[1], 2.0 * x[1] * x[2], 2.0 * x[1] ^ 3) = (6.0830915803973946e10, -1.5062746256024978e21, 1.6673980752436494e31) ``` with different thresholds. Basically when `x[1]` is large the error is floating point noise, and that floating point noise is enough for Broyden to be stable vs unstable.
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.
No description provided.