# Optimizing small systems of NonLinear equations with Optim.jl

**URL:** <https://discourse.julialang.org/t/optimizing-small-systems-of-nonlinear-equations-with-optim-jl/102068>\
**Category:** Optimization (Mathematical)\
**Created:** [July 25, 2023, 9:58am UTC](https://discourse.julialang.org/t/optimizing-small-systems-of-nonlinear-equations-with-optim-jl/102068 "2023-07-25T09:58:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Mastermage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/the_mastermage/32/49444_2.png) [@The\_Mastermage](https://discourse.julialang.org/u/The_Mastermage)\
**Post date:** [July 25, 2023, 9:58am UTC](https://discourse.julialang.org/t/optimizing-small-systems-of-nonlinear-equations-with-optim-jl/102068/1 "2023-07-25T09:58:32Z")

</div>

Hello there I have a very small system of nonlinear equation and i do not quite understand how I can use this using Optim.jl. So far I have only figured out how to do one equation but I have a system (3 Equations):  
The system is defined by:

```julia
function fb(x)
    dco, dm, dcr = x*1e3
    
    rco = dco
    rm = dco + dm
    rcr = dco + dm + dcr

    ρco = 13e3 #kg/m^3
    ρm = 4.5e3
    ρcr = 2.9e3
    
    R_planet = 6062e3 #m
    M_planet = 4.88e24 #kg
    C = 0.33*M_planet*R_planet^2

    radius = dco + dcr + dm - R_planet
    mass = 4/3*pi *( dco^3 * ρco + ((dco + dm)^3 - dm^3)*ρm + ρcr*((dco + dm + dcr)^3 - (dco + dm)^3)) - M_planet
    MoI = 8/15*π*(ρco * rco^5 + ρm * (rm^5 - rco^5) + ρcr*(rcr^5 - rm^5)) - C
return [radius, mass, MoI]
end

```

How can I solve for possible solution vectors x with Optim.jl?  
Also anyone know how to implement constraints?  
Thank you in advance.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [July 25, 2023, 4:02pm UTC](https://discourse.julialang.org/t/optimizing-small-systems-of-nonlinear-equations-with-optim-jl/102068/2 "2023-07-25T16:02:03Z")

</div>

What do you mean by minimize a system of equations?

If you’re doing constrained nonlinear optimization, you might want to use JuMP instead: [Simple examples · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/nonlinear/simple_examples/)

---

<div class="post-metadata">

**Author:** ![The\_Mastermage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/the_mastermage/32/49444_2.png) [@The\_Mastermage](https://discourse.julialang.org/u/The_Mastermage)\
**Post date:** [July 25, 2023, 6:19pm UTC](https://discourse.julialang.org/t/optimizing-small-systems-of-nonlinear-equations-with-optim-jl/102068/3 "2023-07-25T18:19:06Z")

</div>

Sorry to be confusing what i mean with minimizing is searching for one or more solution vectors which let my functions vector output be close to 0 so. fb(xsol) ≈ [0,0,0].

Do I have to do this with JuMP as everything I have seen of JuMP seems to be quite more complicated than Optim.jl. Does Optim.jl not allow for “Solving” systems of equations?  
I am sorry if any of what I am saying makes not much sense, I am trying to figure this out as I follow a course at my University.

Thanks for the Answer and the link tho.
