# NonlinearSolve.jl : mimic SimpleNewtonRaphson with NewtonRaphson

**URL:** https://discourse.julialang.org/t/nonlinearsolve-jl-mimic-simplenewtonraphson-with-newtonraphson/134280
**Category:** Numerics
**Tags:** nonlinearsolve
**Created:** [December 2, 2025, 9:31am UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-mimic-simplenewtonraphson-with-newtonraphson/134280 "2025-12-02T09:31:32Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![bmxam](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@bmxam](https://discourse.julialang.org/u/bmxam)
#### Post date: [December 2, 2025, 9:31am UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-mimic-simplenewtonraphson-with-newtonraphson/134280/1 "2025-12-02T09:31:32Z")

</div>

Hi everyone,

I’m trying to solve a non-linear equation using a Newton-Raphson method using NonlinearSolve.jl . I have my own implementation of a basic Newton-Raphson algorithm, and the `SimpleNewtonRaphson` algorithm does reproduce the same results. Now, I’d like to use the `NewtonRaphson` alg (with advanced features) but first I would like to reproduce my reference results. In other words, I’d like to mimic the `SimpleNewtonRaphson` with `NewtonRaphson`. So far, I’ve tried

```julia
alg = NewtonRaphson(; linsolve = LUFactorization(), linesearch = NoLineSearch())

```

but the algorithm does not lead to the correct solution.

Is it possible to set the `NewtonRaphson` in order to obtain exactly the same results as the `SimpleNewtonRaphson`?

PS : unfortunately, I cannot give a MWE, the non-linear function involves a whole finite-element discretization etc.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [December 4, 2025, 2:17am UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-mimic-simplenewtonraphson-with-newtonraphson/134280/2 "2025-12-04T02:17:08Z")

</div>

This is probably not possible? Little differences in SIMD would be hard to track down.

---

<div class="post-metadata">

### Author: ![karei](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/karei/32/214809_2.png) [@karei](https://discourse.julialang.org/u/karei)
#### Post date: [December 4, 2025, 5:26am UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-mimic-simplenewtonraphson-with-newtonraphson/134280/3 "2025-12-04T05:26:39Z")

</div>

Provide the same initial vector for both algorithms and print the iteration information for each step. You can examine them carefully.

---

<div class="post-metadata">

### Author: ![bmxam](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@bmxam](https://discourse.julialang.org/u/bmxam)
#### Post date: [December 5, 2025, 9:35am UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-mimic-simplenewtonraphson-with-newtonraphson/134280/4 "2025-12-05T09:35:54Z")

</div>

This situation might be related to the `termination_cache` mechanism of `NewtonRaphson`. From my understanding, when the `SimpleNewtonRaphson` reaches the maximum number of iterations, it returns the solution obtained from the last iteration performed. When the `NewtonRaphson` hits the maximum number of iterations, it does not return the solution obtained from the last iteration, but the minimizer of `f` from all the performed iterations. For stiff problems, the two solutions (minimizer of `f` accross all the newton iterations vs last solution obtained from the iterations) are not equal, hence the differences.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [December 5, 2025, 12:08pm UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-mimic-simplenewtonraphson-with-newtonraphson/134280/5 "2025-12-05T12:08:37Z")

</div>

I see, and yes there are different termination algorithm choices, so if you swap that to one that doesn’t use best is it matching?

---

<div class="post-metadata">

### Author: ![bmxam](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@bmxam](https://discourse.julialang.org/u/bmxam)
#### Post date: [December 5, 2025, 2:50pm UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-mimic-simplenewtonraphson-with-newtonraphson/134280/6 "2025-12-05T14:50:57Z")

</div>

Yes if I “skip” this termination algorithm, NewtonRaphson and SimpleNewtonRaphson return the same result.  
For now I solved my problem here and the one related to the “callback” (cf my other topic) by using the `step!` interface. Thanks for all these features 😉
