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

Analytical Jacobian is not being used in the 3.13 version of NonlinearSolve #451

Open
RayleighLord opened this issue Jul 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@RayleighLord
Copy link

This is a duplicate from here, but I thought it might be better to ask here in GitHub.

This question came up when I did some tests related to this post.

Imagine I have the code

using NonlinearSolve

function f(u, p)
    return u^2 - 2
end

function df(u, p)
    println("Hey")
    return 2u
end

fn = NonlinearFunction(f, jac=df)
prob = NonlinearProblem(fn, 1.0)
sol = solve(prob, NewtonRaphson(; concrete_jac=true))

Running this code does not print "Hey" to the terminal, so I guess that automatic differentiation is being used to compute the jacobian instead of the given function. I noticed this behavior because in the post that I mentioned, there was an incompatible interaction between AD and QuadGK that was present even if you provide the analytical jacobian.

Is this intended behavior? How could I provide the analytical jacobian to a problem? Also, does it need to be given to NonlinearFunction always and cannot be an optional parameter to NonlinearProblem?

At least in a quick review of the documentation I did not see a clear explanation on how to provide analytical jacobians.

PD: I am using the version

  [8913a72c] NonlinearSolve v3.13.1
@RayleighLord RayleighLord added the bug Something isn't working label Jul 2, 2024
@afossa
Copy link

afossa commented Jul 5, 2024

This bug apparently affects only scalar functions. See the thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants