Roots of a quadratic function: Difference between revisions

Content added Content deleted
Line 1,166: Line 1,166:
Alternative solutions might make use of Julia's Polynomials or Roots packages.
Alternative solutions might make use of Julia's Polynomials or Roots packages.


<lang julia>function quadroots(x::Real, y::Real, z::Real)
<lang julia>using Printf

function quadroots(x::Real, y::Real, z::Real)
a, b, c = promote(float(x), y, z)
a, b, c = promote(float(x), y, z)
if a ≈ 0.0 return [-c / b] end
if a ≈ 0.0 return [-c / b] end