
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e+19)
(/ b (- a))
(if (<= b 1.65e-130)
(/ (- (sqrt (fma a (* c -4.0) (* b b))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e+19) {
tmp = b / -a;
} else if (b <= 1.65e-130) {
tmp = (sqrt(fma(a, (c * -4.0), (b * b))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.5e+19) tmp = Float64(b / Float64(-a)); elseif (b <= 1.65e-130) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), Float64(b * b))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.5e+19], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.65e-130], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{+19}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-130}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.5e19Initial program 57.0%
*-commutative57.0%
Simplified57.3%
Taylor expanded in b around -inf 94.1%
associate-*r/94.1%
mul-1-neg94.1%
Simplified94.1%
if -1.5e19 < b < 1.6499999999999999e-130Initial program 84.1%
*-commutative84.1%
Simplified84.1%
if 1.6499999999999999e-130 < b Initial program 21.0%
*-commutative21.0%
Simplified21.0%
Taylor expanded in a around 0 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification86.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+19)
(/ b (- a))
(if (<= b 1.45e-122)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+19) {
tmp = b / -a;
} else if (b <= 1.45e-122) {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1d+19)) then
tmp = b / -a
else if (b <= 1.45d-122) then
tmp = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e+19) {
tmp = b / -a;
} else if (b <= 1.45e-122) {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e+19: tmp = b / -a elif b <= 1.45e-122: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e+19) tmp = Float64(b / Float64(-a)); elseif (b <= 1.45e-122) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e+19) tmp = b / -a; elseif (b <= 1.45e-122) tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e+19], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.45e-122], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+19}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-122}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1e19Initial program 57.0%
*-commutative57.0%
Simplified57.3%
Taylor expanded in b around -inf 94.1%
associate-*r/94.1%
mul-1-neg94.1%
Simplified94.1%
if -1e19 < b < 1.4500000000000001e-122Initial program 84.1%
if 1.4500000000000001e-122 < b Initial program 21.0%
*-commutative21.0%
Simplified21.0%
Taylor expanded in a around 0 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification86.5%
(FPCore (a b c)
:precision binary64
(if (<= b -8e-62)
(/ b (- a))
(if (<= b 5.8e-123)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8e-62) {
tmp = b / -a;
} else if (b <= 5.8e-123) {
tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-8d-62)) then
tmp = b / -a
else if (b <= 5.8d-123) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) / (a * 2.0d0)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -8e-62) {
tmp = b / -a;
} else if (b <= 5.8e-123) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8e-62: tmp = b / -a elif b <= 5.8e-123: tmp = (math.sqrt((a * (c * -4.0))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8e-62) tmp = Float64(b / Float64(-a)); elseif (b <= 5.8e-123) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8e-62) tmp = b / -a; elseif (b <= 5.8e-123) tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8e-62], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 5.8e-123], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8 \cdot 10^{-62}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-123}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -8.0000000000000003e-62Initial program 63.1%
*-commutative63.1%
Simplified63.3%
Taylor expanded in b around -inf 87.5%
associate-*r/87.5%
mul-1-neg87.5%
Simplified87.5%
if -8.0000000000000003e-62 < b < 5.80000000000000007e-123Initial program 82.9%
*-commutative82.9%
Simplified82.9%
Taylor expanded in a around inf 78.5%
*-commutative78.5%
associate-*r*78.5%
Simplified78.5%
if 5.80000000000000007e-123 < b Initial program 21.0%
*-commutative21.0%
Simplified21.0%
Taylor expanded in a around 0 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification83.9%
(FPCore (a b c)
:precision binary64
(if (<= b -9.4e-58)
(/ b (- a))
(if (<= b 1.06e-122)
(* (- (sqrt (* a (* c -4.0))) b) (/ 0.5 a))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.4e-58) {
tmp = b / -a;
} else if (b <= 1.06e-122) {
tmp = (sqrt((a * (c * -4.0))) - b) * (0.5 / a);
} else {
tmp = c / -b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-9.4d-58)) then
tmp = b / -a
else if (b <= 1.06d-122) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) * (0.5d0 / a)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -9.4e-58) {
tmp = b / -a;
} else if (b <= 1.06e-122) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) * (0.5 / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9.4e-58: tmp = b / -a elif b <= 1.06e-122: tmp = (math.sqrt((a * (c * -4.0))) - b) * (0.5 / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9.4e-58) tmp = Float64(b / Float64(-a)); elseif (b <= 1.06e-122) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) * Float64(0.5 / a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9.4e-58) tmp = b / -a; elseif (b <= 1.06e-122) tmp = (sqrt((a * (c * -4.0))) - b) * (0.5 / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9.4e-58], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.06e-122], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.4 \cdot 10^{-58}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.06 \cdot 10^{-122}:\\
\;\;\;\;\left(\sqrt{a \cdot \left(c \cdot -4\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -9.39999999999999989e-58Initial program 63.1%
*-commutative63.1%
Simplified63.3%
Taylor expanded in b around -inf 87.5%
associate-*r/87.5%
mul-1-neg87.5%
Simplified87.5%
if -9.39999999999999989e-58 < b < 1.05999999999999994e-122Initial program 82.9%
*-commutative82.9%
Simplified82.9%
div-sub82.9%
sub-neg82.9%
div-inv82.8%
pow282.8%
*-commutative82.8%
associate-/r*82.8%
metadata-eval82.8%
div-inv82.8%
*-commutative82.8%
associate-/r*82.8%
metadata-eval82.8%
Applied egg-rr82.8%
sub-neg82.8%
distribute-rgt-out--82.8%
Simplified82.8%
Taylor expanded in a around inf 78.4%
*-commutative78.4%
associate-*r*78.4%
Simplified78.4%
if 1.05999999999999994e-122 < b Initial program 21.0%
*-commutative21.0%
Simplified21.0%
Taylor expanded in a around 0 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification83.9%
(FPCore (a b c) :precision binary64 (if (<= b -1.05e-182) (/ b (- a)) (if (<= b 3e-146) (* -0.5 (- (sqrt (* c (/ -4.0 a))))) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-182) {
tmp = b / -a;
} else if (b <= 3e-146) {
tmp = -0.5 * -sqrt((c * (-4.0 / a)));
} else {
tmp = c / -b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.05d-182)) then
tmp = b / -a
else if (b <= 3d-146) then
tmp = (-0.5d0) * -sqrt((c * ((-4.0d0) / a)))
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-182) {
tmp = b / -a;
} else if (b <= 3e-146) {
tmp = -0.5 * -Math.sqrt((c * (-4.0 / a)));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.05e-182: tmp = b / -a elif b <= 3e-146: tmp = -0.5 * -math.sqrt((c * (-4.0 / a))) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.05e-182) tmp = Float64(b / Float64(-a)); elseif (b <= 3e-146) tmp = Float64(-0.5 * Float64(-sqrt(Float64(c * Float64(-4.0 / a))))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.05e-182) tmp = b / -a; elseif (b <= 3e-146) tmp = -0.5 * -sqrt((c * (-4.0 / a))); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.05e-182], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 3e-146], N[(-0.5 * (-N[Sqrt[N[(c * N[(-4.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.05 \cdot 10^{-182}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 3 \cdot 10^{-146}:\\
\;\;\;\;-0.5 \cdot \left(-\sqrt{c \cdot \frac{-4}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.05e-182Initial program 65.7%
*-commutative65.7%
Simplified65.8%
Taylor expanded in b around -inf 77.8%
associate-*r/77.8%
mul-1-neg77.8%
Simplified77.8%
if -1.05e-182 < b < 3.00000000000000019e-146Initial program 84.9%
*-commutative84.9%
Simplified84.9%
add-cube-cbrt84.1%
pow384.0%
associate-*l*84.0%
Applied egg-rr84.0%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt43.7%
rem-cube-cbrt44.1%
associate-/l*44.0%
Simplified44.0%
if 3.00000000000000019e-146 < b Initial program 21.0%
*-commutative21.0%
Simplified21.0%
Taylor expanded in a around 0 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification76.4%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = b / -a
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 68.8%
*-commutative68.8%
Simplified68.9%
Taylor expanded in b around -inf 67.4%
associate-*r/67.4%
mul-1-neg67.4%
Simplified67.4%
if -4.999999999999985e-310 < b Initial program 28.3%
*-commutative28.3%
Simplified28.3%
Taylor expanded in a around 0 74.9%
associate-*r/74.9%
mul-1-neg74.9%
Simplified74.9%
Final simplification71.6%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (- a)) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / -a;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = b / -a
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / -a;
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / -a else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b / Float64(-a)); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b / -a; else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / (-a)), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 68.8%
*-commutative68.8%
Simplified68.9%
Taylor expanded in b around -inf 67.4%
associate-*r/67.4%
mul-1-neg67.4%
Simplified67.4%
if -4.999999999999985e-310 < b Initial program 28.3%
*-commutative28.3%
Simplified28.3%
neg-sub028.3%
flip--27.8%
metadata-eval27.8%
pow227.8%
add-sqr-sqrt24.6%
sqrt-prod19.4%
sqr-neg19.4%
sqrt-unprod0.0%
add-sqr-sqrt21.0%
sub-neg21.0%
neg-sub021.0%
add-sqr-sqrt0.0%
sqrt-unprod19.4%
sqr-neg19.4%
sqrt-prod24.6%
add-sqr-sqrt27.8%
Applied egg-rr27.8%
neg-sub027.8%
Simplified27.8%
Taylor expanded in a around 0 15.5%
associate-*r/15.5%
distribute-rgt1-in15.5%
metadata-eval15.5%
mul0-lft15.5%
metadata-eval15.5%
Simplified15.5%
Taylor expanded in a around 0 15.5%
Final simplification38.4%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 46.1%
*-commutative46.1%
Simplified46.1%
neg-sub046.1%
flip--45.8%
metadata-eval45.8%
pow245.8%
add-sqr-sqrt13.7%
sqrt-prod16.0%
sqr-neg16.0%
sqrt-unprod11.7%
add-sqr-sqrt22.8%
sub-neg22.8%
neg-sub022.8%
add-sqr-sqrt11.7%
sqrt-unprod16.0%
sqr-neg16.0%
sqrt-prod13.7%
add-sqr-sqrt45.8%
Applied egg-rr45.8%
neg-sub045.8%
Simplified45.8%
Taylor expanded in a around 0 9.9%
associate-*r/9.9%
distribute-rgt1-in9.9%
metadata-eval9.9%
mul0-lft9.9%
metadata-eval9.9%
Simplified9.9%
Taylor expanded in a around 0 9.9%
herbie shell --seed 2024144
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))