Julia equivalent for python scipy.optimize.fsolve

ModellingToolkit.jl also works quite well for this kind of manipulation:

julia> using ModelingToolkit

julia> @variables x y z
(x, y, z)

julia> eqs = [3x + 5y + 2z - 12, 2x + 5y - 4z - 9, 4x - y + 5z + 3]
3-element Array{Operation,1}:
 ((3x + 5y) + 2z) - 12
  ((2x + 5y) - 4z) - 9
   ((4x - y) + 5z) + 3

julia> M = get.(ModelingToolkit.jacobian(eqs, [x, y, z]))
3×3 Array{Int64,2}:
 3   5   2
 2   5  -4
 4  -1   5

julia> b = get.(substitute.(eqs, Ref([x, y, z] .=> 0)))
3-element Array{Int64,1}:
 -12
  -9
   3

julia> M \ -b
3-element Array{Float64,1}:
 -0.8918918918918918
  2.675675675675676
  0.6486486486486486

julia> substitute.(eqs, Ref([x, y, z] .=> ans))
3-element Array{ModelingToolkit.Constant,1}:
 ModelingToolkit.Constant(0.0)
 ModelingToolkit.Constant(0.0)
 ModelingToolkit.Constant(0.0)

To explicitely get the augmented matrix, you can just do the following:

julia> [M -b]
3×4 Array{Int64,2}:
 3   5   2  12
 2   5  -4   9
 4  -1   5  -3
5 Likes