
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.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) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \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) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.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) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))))
(if (<= b -2.1e+128)
(/ (/ (fma b 2.0 (* (/ (* a -1.5) b) c)) a) -3.0)
(if (<= b 9.8e-88)
t_0
(if (<= b 5.8e-71)
(+ (* -0.375 (* (/ a (pow b 3.0)) (pow c 2.0))) (/ c (/ b -0.5)))
(if (<= b 6.5e+27) t_0 (/ (* c -0.5) b)))))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
double tmp;
if (b <= -2.1e+128) {
tmp = (fma(b, 2.0, (((a * -1.5) / b) * c)) / a) / -3.0;
} else if (b <= 9.8e-88) {
tmp = t_0;
} else if (b <= 5.8e-71) {
tmp = (-0.375 * ((a / pow(b, 3.0)) * pow(c, 2.0))) + (c / (b / -0.5));
} else if (b <= 6.5e+27) {
tmp = t_0;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) tmp = 0.0 if (b <= -2.1e+128) tmp = Float64(Float64(fma(b, 2.0, Float64(Float64(Float64(a * -1.5) / b) * c)) / a) / -3.0); elseif (b <= 9.8e-88) tmp = t_0; elseif (b <= 5.8e-71) tmp = Float64(Float64(-0.375 * Float64(Float64(a / (b ^ 3.0)) * (c ^ 2.0))) + Float64(c / Float64(b / -0.5))); elseif (b <= 6.5e+27) tmp = t_0; else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.1e+128], N[(N[(N[(b * 2.0 + N[(N[(N[(a * -1.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 9.8e-88], t$95$0, If[LessEqual[b, 5.8e-71], N[(N[(-0.375 * N[(N[(a / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision] * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c / N[(b / -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.5e+27], t$95$0, N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{if}\;b \leq -2.1 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, 2, \frac{a \cdot -1.5}{b} \cdot c\right)}{a}}{-3}\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{-88}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-71}:\\
\;\;\;\;-0.375 \cdot \left(\frac{a}{{b}^{3}} \cdot {c}^{2}\right) + \frac{c}{\frac{b}{-0.5}}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{+27}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.1e128Initial program 44.2%
Applied egg-rr60.7%
associate-/r*60.8%
Simplified60.8%
associate-*r/60.7%
Applied egg-rr60.7%
un-div-inv60.8%
div-sub60.8%
Applied egg-rr60.8%
div-sub60.8%
Simplified60.8%
Taylor expanded in b around -inf 0.0%
+-commutative0.0%
*-commutative0.0%
fma-def0.0%
associate-*r/0.0%
*-commutative0.0%
associate-*r*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt96.0%
associate-*r*96.0%
metadata-eval96.0%
associate-*r*96.0%
*-commutative96.0%
associate-*r*96.0%
associate-*l/96.2%
*-commutative96.2%
Simplified96.2%
if -2.1e128 < b < 9.80000000000000055e-88 or 5.7999999999999997e-71 < b < 6.5000000000000005e27Initial program 86.6%
if 9.80000000000000055e-88 < b < 5.7999999999999997e-71Initial program 7.9%
Taylor expanded in b around inf 98.8%
+-commutative98.8%
fma-def98.8%
associate-/l*80.1%
*-commutative80.1%
associate-*l/80.1%
Simplified80.1%
fma-udef80.1%
associate-/r/100.0%
associate-/l*100.0%
Applied egg-rr100.0%
if 6.5000000000000005e27 < b Initial program 11.5%
Taylor expanded in b around inf 97.1%
*-commutative97.1%
associate-*l/97.1%
Simplified97.1%
Final simplification91.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))))
(if (<= b -2.2e+128)
(/ (/ (fma b 2.0 (* (/ (* a -1.5) b) c)) a) -3.0)
(if (<= b 7.5e-89)
t_0
(if (<= b 2.2e-66)
(* c (/ -0.5 b))
(if (<= b 6.5e+27) t_0 (/ (* c -0.5) b)))))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
double tmp;
if (b <= -2.2e+128) {
tmp = (fma(b, 2.0, (((a * -1.5) / b) * c)) / a) / -3.0;
} else if (b <= 7.5e-89) {
tmp = t_0;
} else if (b <= 2.2e-66) {
tmp = c * (-0.5 / b);
} else if (b <= 6.5e+27) {
tmp = t_0;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)) tmp = 0.0 if (b <= -2.2e+128) tmp = Float64(Float64(fma(b, 2.0, Float64(Float64(Float64(a * -1.5) / b) * c)) / a) / -3.0); elseif (b <= 7.5e-89) tmp = t_0; elseif (b <= 2.2e-66) tmp = Float64(c * Float64(-0.5 / b)); elseif (b <= 6.5e+27) tmp = t_0; else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.2e+128], N[(N[(N[(b * 2.0 + N[(N[(N[(a * -1.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 7.5e-89], t$95$0, If[LessEqual[b, 2.2e-66], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.5e+27], t$95$0, N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{if}\;b \leq -2.2 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, 2, \frac{a \cdot -1.5}{b} \cdot c\right)}{a}}{-3}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-89}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-66}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{+27}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -2.20000000000000017e128Initial program 44.2%
Applied egg-rr60.7%
associate-/r*60.8%
Simplified60.8%
associate-*r/60.7%
Applied egg-rr60.7%
un-div-inv60.8%
div-sub60.8%
Applied egg-rr60.8%
div-sub60.8%
Simplified60.8%
Taylor expanded in b around -inf 0.0%
+-commutative0.0%
*-commutative0.0%
fma-def0.0%
associate-*r/0.0%
*-commutative0.0%
associate-*r*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt96.0%
associate-*r*96.0%
metadata-eval96.0%
associate-*r*96.0%
*-commutative96.0%
associate-*r*96.0%
associate-*l/96.2%
*-commutative96.2%
Simplified96.2%
if -2.20000000000000017e128 < b < 7.4999999999999999e-89 or 2.2000000000000001e-66 < b < 6.5000000000000005e27Initial program 86.6%
Taylor expanded in a around 0 86.4%
if 7.4999999999999999e-89 < b < 2.2000000000000001e-66Initial program 7.9%
Taylor expanded in b around inf 97.6%
associate-/l*97.6%
Simplified97.6%
expm1-log1p-u56.6%
expm1-udef19.7%
times-frac19.7%
metadata-eval19.7%
associate-/r/19.7%
Applied egg-rr19.7%
expm1-def56.9%
expm1-log1p98.2%
associate-/l*79.5%
Simplified79.5%
associate-*r/79.5%
clear-num79.8%
Applied egg-rr79.8%
associate-/r/79.2%
*-commutative79.2%
associate-*r*79.2%
times-frac79.5%
*-commutative79.5%
*-rgt-identity79.5%
*-commutative79.5%
Simplified79.5%
*-commutative79.5%
clear-num79.5%
un-div-inv79.5%
Applied egg-rr79.5%
associate-/r/79.5%
associate-*l/79.5%
*-commutative79.5%
*-commutative79.5%
times-frac79.8%
associate-/r/98.8%
*-inverses98.8%
*-lft-identity98.8%
Simplified98.8%
if 6.5000000000000005e27 < b Initial program 11.5%
Taylor expanded in b around inf 97.1%
*-commutative97.1%
associate-*l/97.1%
Simplified97.1%
Final simplification91.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- (sqrt (- (* b b) (* a (* c 3.0)))) b) (* a 3.0))))
(if (<= b -2e+127)
(/ (/ (fma b 2.0 (* (/ (* a -1.5) b) c)) a) -3.0)
(if (<= b 2.1e-87)
t_0
(if (<= b 2.65e-64)
(* c (/ -0.5 b))
(if (<= b 6.5e+27) t_0 (/ (* c -0.5) b)))))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - (a * (c * 3.0)))) - b) / (a * 3.0);
double tmp;
if (b <= -2e+127) {
tmp = (fma(b, 2.0, (((a * -1.5) / b) * c)) / a) / -3.0;
} else if (b <= 2.1e-87) {
tmp = t_0;
} else if (b <= 2.65e-64) {
tmp = c * (-0.5 / b);
} else if (b <= 6.5e+27) {
tmp = t_0;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 3.0)))) - b) / Float64(a * 3.0)) tmp = 0.0 if (b <= -2e+127) tmp = Float64(Float64(fma(b, 2.0, Float64(Float64(Float64(a * -1.5) / b) * c)) / a) / -3.0); elseif (b <= 2.1e-87) tmp = t_0; elseif (b <= 2.65e-64) tmp = Float64(c * Float64(-0.5 / b)); elseif (b <= 6.5e+27) tmp = t_0; else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2e+127], N[(N[(N[(b * 2.0 + N[(N[(N[(a * -1.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 2.1e-87], t$95$0, If[LessEqual[b, 2.65e-64], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.5e+27], t$95$0, N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{if}\;b \leq -2 \cdot 10^{+127}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, 2, \frac{a \cdot -1.5}{b} \cdot c\right)}{a}}{-3}\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{-87}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 2.65 \cdot 10^{-64}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{+27}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.99999999999999991e127Initial program 44.2%
Applied egg-rr60.7%
associate-/r*60.8%
Simplified60.8%
associate-*r/60.7%
Applied egg-rr60.7%
un-div-inv60.8%
div-sub60.8%
Applied egg-rr60.8%
div-sub60.8%
Simplified60.8%
Taylor expanded in b around -inf 0.0%
+-commutative0.0%
*-commutative0.0%
fma-def0.0%
associate-*r/0.0%
*-commutative0.0%
associate-*r*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt96.0%
associate-*r*96.0%
metadata-eval96.0%
associate-*r*96.0%
*-commutative96.0%
associate-*r*96.0%
associate-*l/96.2%
*-commutative96.2%
Simplified96.2%
if -1.99999999999999991e127 < b < 2.10000000000000007e-87 or 2.6500000000000001e-64 < b < 6.5000000000000005e27Initial program 86.6%
Taylor expanded in a around 0 86.4%
*-commutative86.4%
associate-*r*86.5%
Simplified86.5%
if 2.10000000000000007e-87 < b < 2.6500000000000001e-64Initial program 7.9%
Taylor expanded in b around inf 97.6%
associate-/l*97.6%
Simplified97.6%
expm1-log1p-u56.6%
expm1-udef19.7%
times-frac19.7%
metadata-eval19.7%
associate-/r/19.7%
Applied egg-rr19.7%
expm1-def56.9%
expm1-log1p98.2%
associate-/l*79.5%
Simplified79.5%
associate-*r/79.5%
clear-num79.8%
Applied egg-rr79.8%
associate-/r/79.2%
*-commutative79.2%
associate-*r*79.2%
times-frac79.5%
*-commutative79.5%
*-rgt-identity79.5%
*-commutative79.5%
Simplified79.5%
*-commutative79.5%
clear-num79.5%
un-div-inv79.5%
Applied egg-rr79.5%
associate-/r/79.5%
associate-*l/79.5%
*-commutative79.5%
*-commutative79.5%
times-frac79.8%
associate-/r/98.8%
*-inverses98.8%
*-lft-identity98.8%
Simplified98.8%
if 6.5000000000000005e27 < b Initial program 11.5%
Taylor expanded in b around inf 97.1%
*-commutative97.1%
associate-*l/97.1%
Simplified97.1%
Final simplification91.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))))
(if (<= b -1.6e+127)
(/ (/ (fma b 2.0 (* (/ (* a -1.5) b) c)) a) -3.0)
(if (<= b 5.6e-89)
t_0
(if (<= b 8.5e-66)
(* c (/ -0.5 b))
(if (<= b 4.4e+32) t_0 (/ (* c -0.5) b)))))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
double tmp;
if (b <= -1.6e+127) {
tmp = (fma(b, 2.0, (((a * -1.5) / b) * c)) / a) / -3.0;
} else if (b <= 5.6e-89) {
tmp = t_0;
} else if (b <= 8.5e-66) {
tmp = c * (-0.5 / b);
} else if (b <= 4.4e+32) {
tmp = t_0;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)) tmp = 0.0 if (b <= -1.6e+127) tmp = Float64(Float64(fma(b, 2.0, Float64(Float64(Float64(a * -1.5) / b) * c)) / a) / -3.0); elseif (b <= 5.6e-89) tmp = t_0; elseif (b <= 8.5e-66) tmp = Float64(c * Float64(-0.5 / b)); elseif (b <= 4.4e+32) tmp = t_0; else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.6e+127], N[(N[(N[(b * 2.0 + N[(N[(N[(a * -1.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / -3.0), $MachinePrecision], If[LessEqual[b, 5.6e-89], t$95$0, If[LessEqual[b, 8.5e-66], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.4e+32], t$95$0, N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{if}\;b \leq -1.6 \cdot 10^{+127}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, 2, \frac{a \cdot -1.5}{b} \cdot c\right)}{a}}{-3}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-89}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-66}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{+32}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -1.59999999999999988e127Initial program 44.2%
Applied egg-rr60.7%
associate-/r*60.8%
Simplified60.8%
associate-*r/60.7%
Applied egg-rr60.7%
un-div-inv60.8%
div-sub60.8%
Applied egg-rr60.8%
div-sub60.8%
Simplified60.8%
Taylor expanded in b around -inf 0.0%
+-commutative0.0%
*-commutative0.0%
fma-def0.0%
associate-*r/0.0%
*-commutative0.0%
associate-*r*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt96.0%
associate-*r*96.0%
metadata-eval96.0%
associate-*r*96.0%
*-commutative96.0%
associate-*r*96.0%
associate-*l/96.2%
*-commutative96.2%
Simplified96.2%
if -1.59999999999999988e127 < b < 5.5999999999999998e-89 or 8.49999999999999966e-66 < b < 4.40000000000000002e32Initial program 86.6%
if 5.5999999999999998e-89 < b < 8.49999999999999966e-66Initial program 7.9%
Taylor expanded in b around inf 97.6%
associate-/l*97.6%
Simplified97.6%
expm1-log1p-u56.6%
expm1-udef19.7%
times-frac19.7%
metadata-eval19.7%
associate-/r/19.7%
Applied egg-rr19.7%
expm1-def56.9%
expm1-log1p98.2%
associate-/l*79.5%
Simplified79.5%
associate-*r/79.5%
clear-num79.8%
Applied egg-rr79.8%
associate-/r/79.2%
*-commutative79.2%
associate-*r*79.2%
times-frac79.5%
*-commutative79.5%
*-rgt-identity79.5%
*-commutative79.5%
Simplified79.5%
*-commutative79.5%
clear-num79.5%
un-div-inv79.5%
Applied egg-rr79.5%
associate-/r/79.5%
associate-*l/79.5%
*-commutative79.5%
*-commutative79.5%
times-frac79.8%
associate-/r/98.8%
*-inverses98.8%
*-lft-identity98.8%
Simplified98.8%
if 4.40000000000000002e32 < b Initial program 11.5%
Taylor expanded in b around inf 97.1%
*-commutative97.1%
associate-*l/97.1%
Simplified97.1%
Final simplification91.4%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (/ (* b -2.0) (* a 3.0)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = (c * -0.5) / 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 <= (-4d-310)) then
tmp = (b * (-2.0d0)) / (a * 3.0d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (b * -2.0) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (b * -2.0) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(b * -2.0) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = (b * -2.0) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 74.5%
Taylor expanded in b around -inf 70.8%
*-commutative70.8%
Simplified70.8%
if -3.999999999999988e-310 < b Initial program 40.4%
Taylor expanded in b around inf 62.6%
*-commutative62.6%
associate-*l/62.6%
Simplified62.6%
Final simplification66.8%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (* (/ b a) -0.6666666666666666) (* c (/ -0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = c * (-0.5 / 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 <= (-4d-310)) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = c * ((-0.5d0) / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = c * (-0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (b / a) * -0.6666666666666666 else: tmp = c * (-0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(c * Float64(-0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = (b / a) * -0.6666666666666666; else tmp = c * (-0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-0.5}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 74.5%
Taylor expanded in b around -inf 70.7%
*-commutative70.7%
Simplified70.7%
if -3.999999999999988e-310 < b Initial program 40.4%
Taylor expanded in b around inf 48.4%
associate-/l*52.2%
Simplified52.2%
expm1-log1p-u47.3%
expm1-udef22.5%
times-frac22.6%
metadata-eval22.6%
associate-/r/21.0%
Applied egg-rr21.0%
expm1-def44.3%
expm1-log1p48.4%
associate-/l*50.8%
Simplified50.8%
associate-*r/50.8%
clear-num50.5%
Applied egg-rr50.5%
associate-/r/50.7%
*-commutative50.7%
associate-*r*50.7%
times-frac52.6%
*-commutative52.6%
*-rgt-identity52.6%
*-commutative52.6%
Simplified52.6%
*-commutative52.6%
clear-num52.3%
un-div-inv52.3%
Applied egg-rr52.3%
associate-/r/52.6%
associate-*l/52.6%
*-commutative52.6%
*-commutative52.6%
times-frac57.1%
associate-/r/62.4%
*-inverses62.4%
*-lft-identity62.4%
Simplified62.4%
Final simplification66.6%
(FPCore (a b c) :precision binary64 (if (<= b 4.5e-309) (* (/ b a) -0.6666666666666666) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.5e-309) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c * -0.5) / 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 <= 4.5d-309) then
tmp = (b / a) * (-0.6666666666666666d0)
else
tmp = (c * (-0.5d0)) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 4.5e-309) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.5e-309: tmp = (b / a) * -0.6666666666666666 else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.5e-309) tmp = Float64(Float64(b / a) * -0.6666666666666666); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 4.5e-309) tmp = (b / a) * -0.6666666666666666; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.5e-309], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.5 \cdot 10^{-309}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 4.5000000000000011e-309Initial program 74.5%
Taylor expanded in b around -inf 70.7%
*-commutative70.7%
Simplified70.7%
if 4.5000000000000011e-309 < b Initial program 40.4%
Taylor expanded in b around inf 62.6%
*-commutative62.6%
associate-*l/62.6%
Simplified62.6%
Final simplification66.7%
(FPCore (a b c) :precision binary64 (* c (/ -0.5 b)))
double code(double a, double b, double c) {
return c * (-0.5 / 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 * ((-0.5d0) / b)
end function
public static double code(double a, double b, double c) {
return c * (-0.5 / b);
}
def code(a, b, c): return c * (-0.5 / b)
function code(a, b, c) return Float64(c * Float64(-0.5 / b)) end
function tmp = code(a, b, c) tmp = c * (-0.5 / b); end
code[a_, b_, c_] := N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \frac{-0.5}{b}
\end{array}
Initial program 57.9%
Taylor expanded in b around inf 24.6%
associate-/l*26.5%
Simplified26.5%
expm1-log1p-u24.0%
expm1-udef11.9%
times-frac11.9%
metadata-eval11.9%
associate-/r/11.1%
Applied egg-rr11.1%
expm1-def22.5%
expm1-log1p24.6%
associate-/l*26.1%
Simplified26.1%
associate-*r/26.1%
clear-num26.0%
Applied egg-rr26.0%
associate-/r/26.1%
*-commutative26.1%
associate-*r*26.1%
times-frac28.6%
*-commutative28.6%
*-rgt-identity28.6%
*-commutative28.6%
Simplified28.6%
*-commutative28.6%
clear-num28.5%
un-div-inv28.5%
Applied egg-rr28.5%
associate-/r/28.6%
associate-*l/28.6%
*-commutative28.6%
*-commutative28.6%
times-frac30.8%
associate-/r/31.5%
*-inverses31.5%
*-lft-identity31.5%
Simplified31.5%
Final simplification31.5%
herbie shell --seed 2024026
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))