# Roots Package Resulting in Different Roots if adding another zeros to interval

**URL:** https://discourse.julialang.org/t/roots-package-resulting-in-different-roots-if-adding-another-zeros-to-interval/88551
**Category:** General Usage
**Tags:** package
**Created:** [October 11, 2022, 4:33am UTC](https://discourse.julialang.org/t/roots-package-resulting-in-different-roots-if-adding-another-zeros-to-interval/88551 "2022-10-11T04:33:45Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)
#### Post date: [October 11, 2022, 4:33am UTC](https://discourse.julialang.org/t/roots-package-resulting-in-different-roots-if-adding-another-zeros-to-interval/88551/1 "2022-10-11T04:33:45Z")

</div>

Hi all,

I am trying to find roots of this equation:

490x + 2450 e^{-x/50} - 2450 = 0

I use this code:

```julia
using Roots

f(x) = 490x + 2450*(exp(-x/50)) - 2450
find_zeros(f, -1000,1000000000)

```

the results are  
**2-element Vector{Float64}:**  
\*\* -180.74752135437652\*\*  
\*\* 1.7919879079366315e-16\*\*

Now if I add 2 zeros the number change, to become smaller, why is this happening?

```julia
using Roots

f(x) = 490x + 2450*(exp(-x/50)) - 2450
find_zeros(f, -1000,100000000000)

```

**2-element Vector{Float64}:**  
\*\* -180.74752135437652\*\*  
\*\* 5.738679610848498e-17\*\*

If the interval is only from (-1000,1000) then the results are

```julia
using Roots

f(x) = 490x + 2450*(exp(-x/50)) - 2450
find_zeros(f, -1000,1000)

```

**2-element Vector{Float64}:**  
\*\* -180.74752135437652\*\*  
\*\* 0.0\*\*

The problem is even if the second root is converging to zero, the results are changing for different interval.

Why is the larger the interval the roots can be computed more precisely? not just 0 as root.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [October 11, 2022, 4:37am UTC](https://discourse.julialang.org/t/roots-package-resulting-in-different-roots-if-adding-another-zeros-to-interval/88551/2 "2022-10-11T04:37:44Z")

</div>

```julia
julia> eps(Float64)
2.220446049250313e-16

```

All of those are below machine precision, so are effectively zero. You just cannot compute any more accurately than that.

---

<div class="post-metadata">

### Author: ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)
#### Post date: [October 11, 2022, 4:40am UTC](https://discourse.julialang.org/t/roots-package-resulting-in-different-roots-if-adding-another-zeros-to-interval/88551/3 "2022-10-11T04:40:47Z")

</div>

Okay thank you for the explanation

---

<div class="post-metadata">

### Author: ![j\_verzani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_verzani/32/8551_2.png) [@j\_verzani](https://discourse.julialang.org/u/j_verzani)
#### Post date: [October 11, 2022, 9:43am UTC](https://discourse.julialang.org/t/roots-package-resulting-in-different-roots-if-adding-another-zeros-to-interval/88551/4 "2022-10-11T09:43:59Z")

</div>

> [@Freya\_the\_Goddess](#):
>
> ```julia
> f(x) = 490x + 2450*(exp(-x/50)) - 2450
> find_zeros(f, -1000,100000000000)
> 
> ```

The difference is a bit of an artifact of the underlying (very heuristic) algorithm. More rigorous searches for roots over a wide interval are available by `IntervalRootFinding` (which identifies that zero at 0.0 with `Root([-6.71673e-10, 7.33042e-10], :unique)`). With `find_zeros` really wide search intervals will sometimes have the zero identified by a non-bracketing solutions, which, as here, converge to a zero, but up to tolerances, as already explained. When you pass the smaller interval, that zero at 0.0 is handled by a bracketing algorithm, and the answer is more in line with your mathematical expectation. For this problem, you can see that nothing bigger than 10, say, could lead to a problem, so `100000000000` is overkill for an endpoint of your search.
