# ForwardDiff.jl Jacobian with NonlinearSolve.jl

**URL:** https://discourse.julialang.org/t/forwarddiff-jl-jacobian-with-nonlinearsolve-jl/132353
**Category:** General Usage
**Tags:** forwarddiff, nonlinearsolve
**Created:** [September 13, 2025, 4:54pm UTC](https://discourse.julialang.org/t/forwarddiff-jl-jacobian-with-nonlinearsolve-jl/132353 "2025-09-13T16:54:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jskacines](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@Jskacines](https://discourse.julialang.org/u/Jskacines)
#### Post date: [September 13, 2025, 4:54pm UTC](https://discourse.julialang.org/t/forwarddiff-jl-jacobian-with-nonlinearsolve-jl/132353/1 "2025-09-13T16:54:14Z")

</div>

Hello,  
I am new to Julia, so let me know if i’m missing any basics.  
I am using NonlinearSolve.jl to solve a nonlinear system, and I wish to take the jacobian of this solution with respect to input parameters. The code I have is of the form:

```julia-auto
nonlinear_problem = NonlinearProblem(nl_fun, u0, (p1, p2, x0)
function f(x)
    remake(nonlinear_problem,u0,(p1,p2,x)
    sol = solve(nonlinear_problem, NewtonRaphson())
    return sol.u
end

x = x0
y = f(x0)
dy = ForwardDiff.jacobian(f,x0)

```

This yields a correct solution for y, but dy is all zero. I can verify with finite differencing that the jacobian should not be zero, so I imagine this is some sort of compatibility issue with ForwardDiff.jl and NonlinearSolve.jl, or an issue in how I set up my problem that is failing to allow them to interact in the way I’m intending.

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [September 13, 2025, 5:39pm UTC](https://discourse.julialang.org/t/forwarddiff-jl-jacobian-with-nonlinearsolve-jl/132353/2 "2025-09-13T17:39:14Z")

</div>

Hi, welcome to the community!  
Can you post a complete reproducible example?
