Porting from Python optimize.broyden2

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

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)
2 Likes