NLsolve Intermediate Value Theorem

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).

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> 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> 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)
2 Likes