# NLsolve Intermediate Value Theorem

**URL:** <https://discourse.julialang.org/t/nlsolve-intermediate-value-theorem/48509>\
**Category:** Numerics\
**Created:** [October 16, 2020, 6:47pm UTC](https://discourse.julialang.org/t/nlsolve-intermediate-value-theorem/48509 "2020-10-16T18:47:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [October 16, 2020, 6:47pm UTC](https://discourse.julialang.org/t/nlsolve-intermediate-value-theorem/48509/1 "2020-10-16T18:47:21Z")

</div>

Does NLsolve use the Intermediate Value Theorem, how do I aproxemetly solve a problem like

1000=(x)^2+10sin(x)

I know that f(a)=f(0)=0  
and that f(b) can be f(100)=(100)^2+10sin(100)\>=9990

how would I find x such that f(x)=1000 (I know this in impossible and am instead looking for a floating point value).

---

<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:** [October 16, 2020, 6:58pm UTC](https://discourse.julialang.org/t/nlsolve-intermediate-value-theorem/48509/2 "2020-10-16T18:58:33Z")

</div>

There are various packages that can do this. The key is to rewrite your problem “solve this equation” into “find a root (zero) of this function”:

```julia

julia> using Roots

julia> f(x) = x^2 + 10 * sin(x)
f (generic function with 1 method)

julia> g(x) = f(x) - 1000
g (generic function with 1 method)

julia> find_zeros(g, -10000, 10000)
2-element Array{Float64,1}:
 -31.66113716508687
  31.594654877671626

```

or

```julia
julia> using IntervalRootFinding, IntervalArithmetic

julia> roots(g, -10000..10000)
2-element Array{Root{Interval{Float64}},1}:
 Root([31.5946, 31.5947], :unique)
 Root([-31.6612, -31.6611], :unique)

```
