Skip to content
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

add nlsolve method for scalar functions? #272

Open
stevengj opened this issue Jul 19, 2021 · 2 comments
Open

add nlsolve method for scalar functions? #272

stevengj opened this issue Jul 19, 2021 · 2 comments

Comments

@stevengj
Copy link

stevengj commented Jul 19, 2021

Would be nice to have a method for scalar functions, simply by dispatching on scalar initial values. In its simplest form, this could be:

nlsolve(f, initial_x::Number; kwargs...) =
    nlsolve(x -> f(x[]), fill(initial_x); kwargs...)

which works by wrapping and unwrapping 0-dimensional arrays. (Note: this requires JuliaNLSolvers/NLSolversBase.jl#141.) That way, for the case of scalar functions you wouldn't have to go to the trouble of wrapping in an array yourself.

Of course, in the longer run you could have optimized methods for the scalar (0-dimensional) case.

@ChrisRackauckas
Copy link
Contributor

I think we just need to point more people to NonlinearSolve.jl for that. NLsolve.jl make a few too many assumptions and internally will put things in mutable structures anyways, so it's not going to be full performance. The true algorithm in that case should be just a fully non-allocating iteration, which is why NonlinearSolve.jl's native algorithms will do when presented with scalars and static arrays. NLsolve.jl is great for its trust region methods on medium sized equations, but on the large and small end it would need some overhauls.

@pkofod
Copy link
Member

pkofod commented Jul 26, 2021

I think we just need to point more people to NonlinearSolve.jl for that. NLsolve.jl make a few too many assumptions and internally will put things in mutable structures anyways, so it's not going to be full performance. The true algorithm in that case should be just a fully non-allocating iteration, which is why NonlinearSolve.jl's native algorithms will do when presented with scalars and static arrays. NLsolve.jl is great for its trust region methods on medium sized equations, but on the large and small end it would need some overhauls.

These improvements are already present in NLSolvers.jl as well. Though, I'm happy to accomodate any improvements until I get time to properly deprecate NLsolve.jl .

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

No branches or pull requests

3 participants