# Multidimensional non-linear root search?

**URL:** <https://discourse.julialang.org/t/multidimensional-non-linear-root-search/89680>\
**Category:** Optimization (Mathematical)\
**Tags:** nonlinear, rootfinding\
**Created:** [November 3, 2022, 12:17am UTC](https://discourse.julialang.org/t/multidimensional-non-linear-root-search/89680 "2022-11-03T00:17:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gleyland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gleyland/32/15339_2.png) [@gleyland](https://discourse.julialang.org/u/gleyland)\
**Post date:** [November 3, 2022, 12:17am UTC](https://discourse.julialang.org/t/multidimensional-non-linear-root-search/89680/1 "2022-11-03T00:17:31Z")

</div>

Hi,

Does anyone have any guidance on what’s best practice for non-linear root search? (in this case, relatively small, smooth systems of equations expressed as code that should be AD-able) It looks like [NLsolve.jl](https://github.com/JuliaNLSolvers/NLsolve.jl) is a good option, but it hasn’t had a commit in two years. Is it the best option or has the landscape changed?

Thanks in advance!  
Geoff

---

<div class="post-metadata">

**Author:** ![cgeoga](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cgeoga/32/216186_2.png) [@cgeoga](https://discourse.julialang.org/u/cgeoga)\
**Post date:** [November 3, 2022, 3:00am UTC](https://discourse.julialang.org/t/multidimensional-non-linear-root-search/89680/2 "2022-11-03T03:00:52Z")

</div>

If `NLsolve` doesn’t work for you, I have a thin wrapper of Ipopt called [`StandaloneIpopt.jl`](https://git.sr.ht/~cgeoga/StandaloneIpopt.jl) that has an `ipopt_nlsolve(f, init; kwargs...)` function. You put in your function in the format `f(buf, x)` where `buf` is something you update with your system of equations at `x`. The package is officially registered so you can just `]add` it, but I haven’t really written much docs for it, so maybe if this is appealing to you and something isn’t clear then just shoot me a note and I’ll clarify and add some documentation to the README at least.

Under the hood, it works with the trick of solving the dummy objective problem of `min 0` but with constraints `f_j(x) = 0, j=1,...,k` for your `k` equations. Which seems weird, but it’s a trick I first saw in the KNITRO docs and it seems to work pretty well via Ipopt too. You could probably use JuMP with this trick too, although maybe @odow will chime in and say not to do that. If your functions are simple enough that you can write them in the format that JuMP likes, I bet that would be a better option.

If you have KNITRO, they actually have a least-squares mode that works at least as well and uses Gauss-Newton. `KNITRO.jl` has an example file for nonlinear least-squares mode that I can point you if you are interested and can’t find it with google.

---

<div class="post-metadata">

**Author:** ![gleyland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gleyland/32/15339_2.png) [@gleyland](https://discourse.julialang.org/u/gleyland)\
**Post date:** [November 3, 2022, 6:18pm UTC](https://discourse.julialang.org/t/multidimensional-non-linear-root-search/89680/3 "2022-11-03T18:18:33Z")

</div>

Thanks @cgeoga, I haven’t had any trouble with NLsolve yet, I just wanted to check that in a fast moving ecosystem it’s still the right thing to try first, and it sounds like it is. If I do have trouble I’ll look at StandaloneIpopt.

The idea of building a JuMP model is interesting and maybe feasible, but again, not what I’d try first.

Thanks again!

---

<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:** [November 3, 2022, 7:00pm UTC](https://discourse.julialang.org/t/multidimensional-non-linear-root-search/89680/4 "2022-11-03T19:00:26Z")

</div>

Ipopt could be fine, depending on the equations. Worth trying.
