# Porting from Python optimize.broyden2

**URL:** <https://discourse.julialang.org/t/porting-from-python-optimize-broyden2/81874>\
**Category:** General Usage\
**Tags:** question, optimization\
**Created:** [May 29, 2022, 5:09pm UTC](https://discourse.julialang.org/t/porting-from-python-optimize-broyden2/81874 "2022-05-29T17:09:56Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [May 29, 2022, 9:56pm UTC](https://discourse.julialang.org/t/porting-from-python-optimize-broyden2/81874/4 "2022-05-29T21:56:55Z")

</div>

And here you go, I made it 50x faster (100 ns)

```julia
using NonlinearSolve, StaticArrays, BenchmarkTools

function fun(x, p)
    SA[x[1] + 0.5 * (x[1] - x[2])^3 - 1.0,
     0.5 * (x[2] - x[1])^3 + x[2]]
end

function test_nr()
    prob = NonlinearProblem{false}(fun,SA[0.0; 0.0])
    sol = solve(prob, NewtonRaphson())
    sol.u
end

@btime test_nr() # 106.760 ns (0 allocations: 0 bytes)

```

---

_[View the full topic](https://discourse.julialang.org/t/porting-from-python-optimize-broyden2/81874)._
