How to learn how to solve equations in Julia 1.0?

For functions of a single variable, the simplest solution is the Roots.jl package:

julia> ]add Roots

julia> using Roots

julia> f(p) = 1 / ((1 + p) ^ 30) * 10000 - 100
f (generic function with 1 method)

julia> find_zero(f, 1.0)
0.16591440117983175

julia> find_zero(f, -3.0)
-2.165914401179832

julia> find_zeros(f, -1000, 1000)
2-element Array{Float64,1}:
 -2.1659144011798315
  0.16591440117983178

You can also use the IntervalRootFinding package, which guarantees (in the best cases) to find all roots and guarantee that they are unique within the respective found intervals:

julia> using IntervalArithmetic, IntervalRootFinding
WARNING: using IntervalRootFinding.Bisection in module Main conflicts with an existing identifier.

julia> roots(f, -∞..∞)
2-element Array{Root{Interval{Float64}},1}:
 Root([0.165914, 0.165915], :unique)
 Root([-2.16592, -2.16591], :unique)
7 Likes