
(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 10 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 -5e+85)
(/
(- (fabs (fma b (sqrt (fma (/ c b) (/ a (* b -0.25)) 1.0)) 0.0)) b)
(* a 2.0))
(if (<= b 0.0022)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(- 0.0 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+85) {
tmp = (fabs(fma(b, sqrt(fma((c / b), (a / (b * -0.25)), 1.0)), 0.0)) - b) / (a * 2.0);
} else if (b <= 0.0022) {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = 0.0 - (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+85) tmp = Float64(Float64(abs(fma(b, sqrt(fma(Float64(c / b), Float64(a / Float64(b * -0.25)), 1.0)), 0.0)) - b) / Float64(a * 2.0)); elseif (b <= 0.0022) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(0.0 - Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+85], N[(N[(N[Abs[N[(b * N[Sqrt[N[(N[(c / b), $MachinePrecision] * N[(a / N[(b * -0.25), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] + 0.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.0022], 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[(0.0 - N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+85}:\\
\;\;\;\;\frac{\left|\mathsf{fma}\left(b, \sqrt{\mathsf{fma}\left(\frac{c}{b}, \frac{a}{b \cdot -0.25}, 1\right)}, 0\right)\right| - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 0.0022:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.0000000000000001e85Initial program 50.4%
Taylor expanded in b around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6450.1
Simplified50.1%
rem-square-sqrtN/A
rem-sqrt-squareN/A
fabs-lowering-fabs.f64N/A
+-rgt-identityN/A
sqrt-prodN/A
sqrt-prodN/A
rem-square-sqrtN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr97.4%
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
times-fracN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64100.0
Applied egg-rr100.0%
if -5.0000000000000001e85 < b < 0.00220000000000000013Initial program 79.5%
if 0.00220000000000000013 < b Initial program 12.2%
Taylor expanded in b around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6495.2
Simplified95.2%
sub0-negN/A
neg-lowering-neg.f64N/A
/-lowering-/.f6495.2
Applied egg-rr95.2%
Final simplification90.0%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+87)
(/
(- (fabs (fma b (sqrt (fma a (/ c (* -0.25 (* b b))) 1.0)) 0.0)) b)
(* a 2.0))
(if (<= b 0.0215)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(- 0.0 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+87) {
tmp = (fabs(fma(b, sqrt(fma(a, (c / (-0.25 * (b * b))), 1.0)), 0.0)) - b) / (a * 2.0);
} else if (b <= 0.0215) {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = 0.0 - (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+87) tmp = Float64(Float64(abs(fma(b, sqrt(fma(a, Float64(c / Float64(-0.25 * Float64(b * b))), 1.0)), 0.0)) - b) / Float64(a * 2.0)); elseif (b <= 0.0215) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(0.0 - Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+87], N[(N[(N[Abs[N[(b * N[Sqrt[N[(a * N[(c / N[(-0.25 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] + 0.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.0215], 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[(0.0 - N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+87}:\\
\;\;\;\;\frac{\left|\mathsf{fma}\left(b, \sqrt{\mathsf{fma}\left(a, \frac{c}{-0.25 \cdot \left(b \cdot b\right)}, 1\right)}, 0\right)\right| - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 0.0215:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.9999999999999998e87Initial program 50.4%
Taylor expanded in b around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6450.1
Simplified50.1%
rem-square-sqrtN/A
rem-sqrt-squareN/A
fabs-lowering-fabs.f64N/A
+-rgt-identityN/A
sqrt-prodN/A
sqrt-prodN/A
rem-square-sqrtN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr97.4%
if -4.9999999999999998e87 < b < 0.021499999999999998Initial program 79.5%
if 0.021499999999999998 < b Initial program 12.2%
Taylor expanded in b around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6495.2
Simplified95.2%
sub0-negN/A
neg-lowering-neg.f64N/A
/-lowering-/.f6495.2
Applied egg-rr95.2%
Final simplification89.3%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+157)
(/ b (- 0.0 a))
(if (<= b 0.0022)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(- 0.0 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+157) {
tmp = b / (0.0 - a);
} else if (b <= 0.0022) {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = 0.0 - (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+157)) then
tmp = b / (0.0d0 - a)
else if (b <= 0.0022d0) then
tmp = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
else
tmp = 0.0d0 - (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e+157) {
tmp = b / (0.0 - a);
} else if (b <= 0.0022) {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = 0.0 - (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+157: tmp = b / (0.0 - a) elif b <= 0.0022: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) else: tmp = 0.0 - (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+157) tmp = Float64(b / Float64(0.0 - a)); elseif (b <= 0.0022) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(0.0 - Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+157) tmp = b / (0.0 - a); elseif (b <= 0.0022) tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); else tmp = 0.0 - (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+157], N[(b / N[(0.0 - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.0022], 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[(0.0 - N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+157}:\\
\;\;\;\;\frac{b}{0 - a}\\
\mathbf{elif}\;b \leq 0.0022:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.99999999999999976e157Initial program 30.9%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6496.3
Simplified96.3%
if -4.99999999999999976e157 < b < 0.00220000000000000013Initial program 82.2%
if 0.00220000000000000013 < b Initial program 12.2%
Taylor expanded in b around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6495.2
Simplified95.2%
sub0-negN/A
neg-lowering-neg.f64N/A
/-lowering-/.f6495.2
Applied egg-rr95.2%
Final simplification88.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.05e+138)
(/ b (- 0.0 a))
(if (<= b 0.01)
(* (/ -0.5 a) (- b (sqrt (fma b b (* c (* a -4.0))))))
(- 0.0 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e+138) {
tmp = b / (0.0 - a);
} else if (b <= 0.01) {
tmp = (-0.5 / a) * (b - sqrt(fma(b, b, (c * (a * -4.0)))));
} else {
tmp = 0.0 - (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.05e+138) tmp = Float64(b / Float64(0.0 - a)); elseif (b <= 0.01) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))))); else tmp = Float64(0.0 - Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.05e+138], N[(b / N[(0.0 - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.01], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 - N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.05 \cdot 10^{+138}:\\
\;\;\;\;\frac{b}{0 - a}\\
\mathbf{elif}\;b \leq 0.01:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.05000000000000003e138Initial program 38.2%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6496.7
Simplified96.7%
if -1.05000000000000003e138 < b < 0.0100000000000000002Initial program 81.3%
Applied egg-rr81.3%
if 0.0100000000000000002 < b Initial program 12.2%
Taylor expanded in b around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6495.2
Simplified95.2%
sub0-negN/A
neg-lowering-neg.f64N/A
/-lowering-/.f6495.2
Applied egg-rr95.2%
Final simplification88.8%
(FPCore (a b c)
:precision binary64
(if (<= b -4.5e-21)
(fma b (/ c (* b b)) (/ b (- 0.0 a)))
(if (<= b 0.0023)
(/ (- b (sqrt (* c (* a -4.0)))) (* a -2.0))
(- 0.0 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-21) {
tmp = fma(b, (c / (b * b)), (b / (0.0 - a)));
} else if (b <= 0.0023) {
tmp = (b - sqrt((c * (a * -4.0)))) / (a * -2.0);
} else {
tmp = 0.0 - (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.5e-21) tmp = fma(b, Float64(c / Float64(b * b)), Float64(b / Float64(0.0 - a))); elseif (b <= 0.0023) tmp = Float64(Float64(b - sqrt(Float64(c * Float64(a * -4.0)))) / Float64(a * -2.0)); else tmp = Float64(0.0 - Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.5e-21], N[(b * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(b / N[(0.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.0023], N[(N[(b - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * -2.0), $MachinePrecision]), $MachinePrecision], N[(0.0 - N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{c}{b \cdot b}, \frac{b}{0 - a}\right)\\
\mathbf{elif}\;b \leq 0.0023:\\
\;\;\;\;\frac{b - \sqrt{c \cdot \left(a \cdot -4\right)}}{a \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.49999999999999968e-21Initial program 61.1%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-*l/N/A
*-lft-identityN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6492.5
Simplified92.5%
if -4.49999999999999968e-21 < b < 0.0023Initial program 74.7%
Applied egg-rr74.7%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6469.3
Simplified69.3%
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
div-invN/A
metadata-evalN/A
metadata-evalN/A
*-lowering-*.f64N/A
metadata-eval69.4
Applied egg-rr69.4%
if 0.0023 < b Initial program 12.2%
Taylor expanded in b around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6495.2
Simplified95.2%
sub0-negN/A
neg-lowering-neg.f64N/A
/-lowering-/.f6495.2
Applied egg-rr95.2%
Final simplification85.5%
(FPCore (a b c)
:precision binary64
(if (<= b -4.5e-16)
(fma b (/ c (* b b)) (/ b (- 0.0 a)))
(if (<= b 0.0022)
(* (/ -0.5 a) (- b (sqrt (* -4.0 (* c a)))))
(- 0.0 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-16) {
tmp = fma(b, (c / (b * b)), (b / (0.0 - a)));
} else if (b <= 0.0022) {
tmp = (-0.5 / a) * (b - sqrt((-4.0 * (c * a))));
} else {
tmp = 0.0 - (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.5e-16) tmp = fma(b, Float64(c / Float64(b * b)), Float64(b / Float64(0.0 - a))); elseif (b <= 0.0022) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(-4.0 * Float64(c * a))))); else tmp = Float64(0.0 - Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.5e-16], N[(b * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(b / N[(0.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 0.0022], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 - N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{c}{b \cdot b}, \frac{b}{0 - a}\right)\\
\mathbf{elif}\;b \leq 0.0022:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{-4 \cdot \left(c \cdot a\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.5000000000000002e-16Initial program 61.1%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-*l/N/A
*-lft-identityN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6492.5
Simplified92.5%
if -4.5000000000000002e-16 < b < 0.00220000000000000013Initial program 74.7%
Applied egg-rr74.7%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6469.3
Simplified69.3%
if 0.00220000000000000013 < b Initial program 12.2%
Taylor expanded in b around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6495.2
Simplified95.2%
sub0-negN/A
neg-lowering-neg.f64N/A
/-lowering-/.f6495.2
Applied egg-rr95.2%
Final simplification85.4%
(FPCore (a b c) :precision binary64 (if (<= b 7.5e-285) (/ b (- 0.0 a)) (- 0.0 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.5e-285) {
tmp = b / (0.0 - a);
} else {
tmp = 0.0 - (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 <= 7.5d-285) then
tmp = b / (0.0d0 - a)
else
tmp = 0.0d0 - (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 7.5e-285) {
tmp = b / (0.0 - a);
} else {
tmp = 0.0 - (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.5e-285: tmp = b / (0.0 - a) else: tmp = 0.0 - (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.5e-285) tmp = Float64(b / Float64(0.0 - a)); else tmp = Float64(0.0 - Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 7.5e-285) tmp = b / (0.0 - a); else tmp = 0.0 - (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.5e-285], N[(b / N[(0.0 - a), $MachinePrecision]), $MachinePrecision], N[(0.0 - N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.5 \cdot 10^{-285}:\\
\;\;\;\;\frac{b}{0 - a}\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{c}{b}\\
\end{array}
\end{array}
if b < 7.4999999999999999e-285Initial program 68.1%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6466.8
Simplified66.8%
if 7.4999999999999999e-285 < b Initial program 30.6%
Taylor expanded in b around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6472.0
Simplified72.0%
sub0-negN/A
neg-lowering-neg.f64N/A
/-lowering-/.f6472.0
Applied egg-rr72.0%
Final simplification69.1%
(FPCore (a b c) :precision binary64 (- 0.0 (/ c b)))
double code(double a, double b, double c) {
return 0.0 - (c / b);
}
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 - (c / b)
end function
public static double code(double a, double b, double c) {
return 0.0 - (c / b);
}
def code(a, b, c): return 0.0 - (c / b)
function code(a, b, c) return Float64(0.0 - Float64(c / b)) end
function tmp = code(a, b, c) tmp = 0.0 - (c / b); end
code[a_, b_, c_] := N[(0.0 - N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0 - \frac{c}{b}
\end{array}
Initial program 51.2%
Taylor expanded in b around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6433.7
Simplified33.7%
sub0-negN/A
neg-lowering-neg.f64N/A
/-lowering-/.f6433.7
Applied egg-rr33.7%
Final simplification33.7%
(FPCore (a b c) :precision binary64 (/ c b))
double code(double a, double b, double c) {
return c / b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c / b
end function
public static double code(double a, double b, double c) {
return c / b;
}
def code(a, b, c): return c / b
function code(a, b, c) return Float64(c / b) end
function tmp = code(a, b, c) tmp = c / b; end
code[a_, b_, c_] := N[(c / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b}
\end{array}
Initial program 51.2%
Taylor expanded in b around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6433.7
Simplified33.7%
flip3--N/A
metadata-evalN/A
div-subN/A
Applied egg-rr8.1%
(FPCore (a b c) :precision binary64 (/ b a))
double code(double a, double b, double c) {
return b / 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 / a
end function
public static double code(double a, double b, double c) {
return b / a;
}
def code(a, b, c): return b / a
function code(a, b, c) return Float64(b / a) end
function tmp = code(a, b, c) tmp = b / a; end
code[a_, b_, c_] := N[(b / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a}
\end{array}
Initial program 51.2%
Applied egg-rr32.6%
Taylor expanded in a around 0
/-lowering-/.f642.3
Simplified2.3%
herbie shell --seed 2024198
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))