Start by running the command include("quad.jl"), which defines the following two functions for calculating the desired roots of the quadratic equation:
function quadratic1(a, b, c) t(s) = (-b + s*sqrt(Δ))/(2a) a == 0 && error("a must be different than zero") Δ = Complex(b^2-4*a*c) t(1), t(-1)endfunction quadratic2(a, b, c) Δ = Complex(b^2-4*a*c) t(s) = (-b + s*sqrt(Δ))/(2a) a == 0 && error("a must be different than zero") t(1), t(-1)end
Although they seemingly perform the same work, when we benchmark them, it turns out that they have significantly different performance characteristics (you need to have the BenchmarkTools.jl package installed for this code to work; if it is not installed, add it using the commands using Pkg; ...