# Robust or global multivariate rootfinder

**URL:** https://discourse.julialang.org/t/robust-or-global-multivariate-rootfinder/23169
**Category:** Optimization (Mathematical)
**Tags:** question
**Created:** [April 15, 2019, 6:16pm UTC](https://discourse.julialang.org/t/robust-or-global-multivariate-rootfinder/23169 "2019-04-15T18:16:21Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [April 15, 2019, 6:16pm UTC](https://discourse.julialang.org/t/robust-or-global-multivariate-rootfinder/23169/1 "2019-04-15T18:16:22Z")

</div>

I have a function in about 3–7 variables (varies, ideally 7) and I am looking for a root.

It is best to treat the function as a “black box”, just delivering values and not derivatives, though I will try to make it work with `ForwardDiff` at some point, currently that is conceptually challenging. A function evaluation takes about `0.1s`–`0.5s`, depending on problem size. I may be able to micro-optimize this by a factor of, say, 5, but that is costly.

`NLsolve.nlsolve(f, ...)` finds the global root reasonably robustly 99% of the time.

`Optim.optimize(x -> sum(abs2, f(x)), ...)` converges to a point that is not a root, usually.

Are there any other options currently in Julia?

---

<div class="post-metadata">

### Author: ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)
#### Post date: [April 15, 2019, 6:42pm UTC](https://discourse.julialang.org/t/robust-or-global-multivariate-rootfinder/23169/2 "2019-04-15T18:42:27Z")

</div>

I’ve found [BlackBoxOptim](https://github.com/robertfeldt/BlackBoxOptim.jl) useful, although I haven’t tried it with such a slow function.

---

<div class="post-metadata">

### Author: ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)
#### Post date: [April 15, 2019, 7:41pm UTC](https://discourse.julialang.org/t/robust-or-global-multivariate-rootfinder/23169/3 "2019-04-15T19:41:07Z")

</div>

If you don’t mind wrappers, there is also MINPACK.jl and `kinsol` as part of Sundials.jl IIRC

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [April 16, 2019, 6:42am UTC](https://discourse.julialang.org/t/robust-or-global-multivariate-rootfinder/23169/4 "2019-04-16T06:42:44Z")

</div>

I tried it, it finds non-root local optima most of the time.

Exploring a hypercube with [Sobol sequences](https://github.com/stevengj/Sobol.jl), and picking the lowest point (by L^1) works reasonably well with Optim.

---

<div class="post-metadata">

### Author: ![braamvandyk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/braamvandyk/32/5086_2.png) [@braamvandyk](https://discourse.julialang.org/u/braamvandyk)
#### Post date: [April 16, 2019, 7:27am UTC](https://discourse.julialang.org/t/robust-or-global-multivariate-rootfinder/23169/5 "2019-04-16T07:27:01Z")

</div>

IntervalRootFinding? Not sure about the speed, but it’s robust.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [April 16, 2019, 7:36am UTC](https://discourse.julialang.org/t/robust-or-global-multivariate-rootfinder/23169/6 "2019-04-16T07:36:17Z")

</div>

Can that do multivariate? All the docs refer to univariate examples.

---

<div class="post-metadata">

### Author: ![braamvandyk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/braamvandyk/32/5086_2.png) [@braamvandyk](https://discourse.julialang.org/u/braamvandyk)
#### Post date: [April 16, 2019, 7:51am UTC](https://discourse.julialang.org/t/robust-or-global-multivariate-rootfinder/23169/7 "2019-04-16T07:51:19Z")

</div>

Using an Intervalbox, rather than Interval.

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [April 16, 2019, 3:26pm UTC](https://discourse.julialang.org/t/robust-or-global-multivariate-rootfinder/23169/8 "2019-04-16T15:26:41Z")

</div>

Yes it can; see e.g.

> [@\[Ann\] IntervalRootFinding.jl for finding all roots of a multivariate function](https://discourse.julialang.org/t/ann-intervalrootfinding-jl-for-finding-all-roots-of-a-multivariate-function/9515):
>
> We are excited to announce v0.2 of the [IntervalRootFinding.jl](https://github.com/JuliaIntervals/IntervalRootFinding.jl/) package, which has been completely rewritten from scratch. This package exports a function roots that is guaranteed to find all roots of a given function \mathbb{R}^n \to \mathbb{R}^n in a given box X \subseteq \mathbb{R}^n (or tell you that it is unable to do so). Functions are written with standard Julia syntax; no macros or other magic are required! It is able to do this thanks to the power of interval arithmetic methods, based …

The docs are about to be refreshed once we work out how to deploy them.

If your function is polynomial, you can try HomotopyContinuation.jl.  
If it is Julia code and only uses “standard” functions like `sin`, and no control flow, you can try `IntervalRootFinding.jl`.

In your problem statement, I don’t understand what you mean by “robust”, nor the “global root”. If you actually have an optimisation problem, rather than a root finding problem, and with the same caveats as before, you can try IntervalOptimisation.jl (or indeed any of the optimization packages available through JuMP).

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [April 16, 2019, 3:31pm UTC](https://discourse.julialang.org/t/robust-or-global-multivariate-rootfinder/23169/9 "2019-04-16T15:31:10Z")

</div>

> [@dpsanders](#):
>
> I don’t understand what you mean by “robust”, nor the “global root”.

Sorry if I was unclear.

“Robust” refers to the fact that it should handle functions with minor local jumps. Theoretically the function is continuous; our solution methodology sometimes introduces jumps, no matter how hard we try to smooth them out. It is a market clearing and aggregate resource constraint from an economic model.

“Global root” was an unfortunate term, too. Occasionally we have multiple roots, some of them we can rule out as spurious knife-edge cases _ex post_.
