
(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
(if (<= b -1.35e+42)
(/ (* b -0.6666666666666666) a)
(if (<= b -3.6e-254)
(* -0.3333333333333333 (/ (- b (sqrt (fma b b (* a (* c -3.0))))) a))
(if (<= b 1e-30)
(/ (- c) (+ b (hypot b (sqrt (* c (* a -3.0))))))
(/ (- c) (fma 0.5 (* -3.0 (* a (/ c b))) (* b 2.0)))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e+42) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= -3.6e-254) {
tmp = -0.3333333333333333 * ((b - sqrt(fma(b, b, (a * (c * -3.0))))) / a);
} else if (b <= 1e-30) {
tmp = -c / (b + hypot(b, sqrt((c * (a * -3.0)))));
} else {
tmp = -c / fma(0.5, (-3.0 * (a * (c / b))), (b * 2.0));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.35e+42) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= -3.6e-254) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(fma(b, b, Float64(a * Float64(c * -3.0))))) / a)); elseif (b <= 1e-30) tmp = Float64(Float64(-c) / Float64(b + hypot(b, sqrt(Float64(c * Float64(a * -3.0)))))); else tmp = Float64(Float64(-c) / fma(0.5, Float64(-3.0 * Float64(a * Float64(c / b))), Float64(b * 2.0))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.35e+42], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, -3.6e-254], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(b * b + N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-30], N[((-c) / N[(b + N[Sqrt[b ^ 2 + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / N[(0.5 * N[(-3.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.35 \cdot 10^{+42}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq -3.6 \cdot 10^{-254}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}{a}\\
\mathbf{elif}\;b \leq 10^{-30}:\\
\;\;\;\;\frac{-c}{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{\mathsf{fma}\left(0.5, -3 \cdot \left(a \cdot \frac{c}{b}\right), b \cdot 2\right)}\\
\end{array}
\end{array}
if b < -1.35e42Initial program 62.6%
neg-sub062.6%
associate-+l-62.6%
sub0-neg62.6%
neg-mul-162.6%
associate-*r/62.6%
*-commutative62.6%
metadata-eval62.6%
metadata-eval62.6%
times-frac62.6%
*-commutative62.6%
times-frac62.5%
Simplified62.6%
Applied egg-rr0.0%
*-commutative0.0%
associate-*r/0.0%
associate-/l*0.0%
*-commutative0.0%
*-commutative0.0%
associate-/r*0.0%
Simplified0.0%
Taylor expanded in c around 0 12.9%
mul-1-neg12.9%
Simplified12.9%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt95.1%
metadata-eval95.1%
*-commutative95.1%
associate-*l/95.2%
Simplified95.2%
if -1.35e42 < b < -3.59999999999999984e-254Initial program 82.7%
/-rgt-identity82.7%
metadata-eval82.7%
associate-/l*82.7%
associate-*r/82.6%
*-commutative82.6%
associate-*l/82.7%
associate-*r/82.7%
metadata-eval82.7%
metadata-eval82.7%
times-frac82.7%
neg-mul-182.7%
distribute-rgt-neg-in82.7%
times-frac82.8%
metadata-eval82.8%
neg-mul-182.8%
Simplified82.8%
if -3.59999999999999984e-254 < b < 1e-30Initial program 62.0%
neg-sub062.0%
associate-+l-62.0%
sub0-neg62.0%
neg-mul-162.0%
associate-*r/62.0%
*-commutative62.0%
metadata-eval62.0%
metadata-eval62.0%
times-frac62.0%
*-commutative62.0%
times-frac62.0%
Simplified61.7%
Applied egg-rr54.2%
*-commutative54.2%
associate-*r/54.1%
associate-/l*54.0%
*-commutative54.0%
*-commutative54.0%
associate-/r*61.7%
Simplified61.6%
Taylor expanded in c around 0 86.2%
mul-1-neg86.2%
Simplified86.2%
if 1e-30 < b Initial program 15.4%
neg-sub015.4%
associate-+l-15.4%
sub0-neg15.4%
neg-mul-115.4%
associate-*r/15.4%
*-commutative15.4%
metadata-eval15.4%
metadata-eval15.4%
times-frac15.4%
*-commutative15.4%
times-frac15.4%
Simplified15.4%
Applied egg-rr13.4%
*-commutative13.4%
associate-*r/13.4%
associate-/l*13.4%
*-commutative13.4%
*-commutative13.4%
associate-/r*13.5%
Simplified13.4%
Taylor expanded in c around 0 59.2%
mul-1-neg59.2%
Simplified59.2%
Taylor expanded in b around inf 0.0%
fma-def0.0%
*-rgt-identity0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt87.5%
times-frac87.5%
associate-*l/89.9%
*-commutative89.9%
metadata-eval89.9%
*-commutative89.9%
Simplified89.9%
Final simplification89.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1.35e+42)
(/ (* b -0.6666666666666666) a)
(if (<= b -3.7e-254)
(* -0.3333333333333333 (/ (- b (sqrt (- (* b b) (* c (* a 3.0))))) a))
(if (<= b 9.5e-31)
(/ (- c) (+ b (hypot b (sqrt (* c (* a -3.0))))))
(/ (- c) (fma 0.5 (* -3.0 (* a (/ c b))) (* b 2.0)))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e+42) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= -3.7e-254) {
tmp = -0.3333333333333333 * ((b - sqrt(((b * b) - (c * (a * 3.0))))) / a);
} else if (b <= 9.5e-31) {
tmp = -c / (b + hypot(b, sqrt((c * (a * -3.0)))));
} else {
tmp = -c / fma(0.5, (-3.0 * (a * (c / b))), (b * 2.0));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.35e+42) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= -3.7e-254) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0))))) / a)); elseif (b <= 9.5e-31) tmp = Float64(Float64(-c) / Float64(b + hypot(b, sqrt(Float64(c * Float64(a * -3.0)))))); else tmp = Float64(Float64(-c) / fma(0.5, Float64(-3.0 * Float64(a * Float64(c / b))), Float64(b * 2.0))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.35e+42], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, -3.7e-254], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.5e-31], N[((-c) / N[(b + N[Sqrt[b ^ 2 + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / N[(0.5 * N[(-3.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.35 \cdot 10^{+42}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq -3.7 \cdot 10^{-254}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{a}\\
\mathbf{elif}\;b \leq 9.5 \cdot 10^{-31}:\\
\;\;\;\;\frac{-c}{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -3\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{\mathsf{fma}\left(0.5, -3 \cdot \left(a \cdot \frac{c}{b}\right), b \cdot 2\right)}\\
\end{array}
\end{array}
if b < -1.35e42Initial program 62.6%
neg-sub062.6%
associate-+l-62.6%
sub0-neg62.6%
neg-mul-162.6%
associate-*r/62.6%
*-commutative62.6%
metadata-eval62.6%
metadata-eval62.6%
times-frac62.6%
*-commutative62.6%
times-frac62.5%
Simplified62.6%
Applied egg-rr0.0%
*-commutative0.0%
associate-*r/0.0%
associate-/l*0.0%
*-commutative0.0%
*-commutative0.0%
associate-/r*0.0%
Simplified0.0%
Taylor expanded in c around 0 12.9%
mul-1-neg12.9%
Simplified12.9%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt95.1%
metadata-eval95.1%
*-commutative95.1%
associate-*l/95.2%
Simplified95.2%
if -1.35e42 < b < -3.7000000000000004e-254Initial program 82.7%
/-rgt-identity82.7%
metadata-eval82.7%
associate-/l*82.7%
associate-*r/82.6%
*-commutative82.6%
associate-*l/82.7%
associate-*r/82.7%
metadata-eval82.7%
metadata-eval82.7%
times-frac82.7%
neg-mul-182.7%
distribute-rgt-neg-in82.7%
times-frac82.8%
metadata-eval82.8%
neg-mul-182.8%
Simplified82.8%
fma-udef82.8%
associate-*r*82.8%
*-commutative82.8%
metadata-eval82.8%
cancel-sign-sub-inv82.8%
associate-*r*82.8%
*-commutative82.8%
*-commutative82.8%
Applied egg-rr82.8%
if -3.7000000000000004e-254 < b < 9.5000000000000008e-31Initial program 62.0%
neg-sub062.0%
associate-+l-62.0%
sub0-neg62.0%
neg-mul-162.0%
associate-*r/62.0%
*-commutative62.0%
metadata-eval62.0%
metadata-eval62.0%
times-frac62.0%
*-commutative62.0%
times-frac62.0%
Simplified61.7%
Applied egg-rr54.2%
*-commutative54.2%
associate-*r/54.1%
associate-/l*54.0%
*-commutative54.0%
*-commutative54.0%
associate-/r*61.7%
Simplified61.6%
Taylor expanded in c around 0 86.2%
mul-1-neg86.2%
Simplified86.2%
if 9.5000000000000008e-31 < b Initial program 15.4%
neg-sub015.4%
associate-+l-15.4%
sub0-neg15.4%
neg-mul-115.4%
associate-*r/15.4%
*-commutative15.4%
metadata-eval15.4%
metadata-eval15.4%
times-frac15.4%
*-commutative15.4%
times-frac15.4%
Simplified15.4%
Applied egg-rr13.4%
*-commutative13.4%
associate-*r/13.4%
associate-/l*13.4%
*-commutative13.4%
*-commutative13.4%
associate-/r*13.5%
Simplified13.4%
Taylor expanded in c around 0 59.2%
mul-1-neg59.2%
Simplified59.2%
Taylor expanded in b around inf 0.0%
fma-def0.0%
*-rgt-identity0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt87.5%
times-frac87.5%
associate-*l/89.9%
*-commutative89.9%
metadata-eval89.9%
*-commutative89.9%
Simplified89.9%
Final simplification89.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1.35e+42)
(/ (* b -0.6666666666666666) a)
(if (<= b 1.25e-137)
(* -0.3333333333333333 (/ (- b (sqrt (- (* b b) (* c (* a 3.0))))) a))
(/ (- c) (fma 0.5 (* -3.0 (* a (/ c b))) (* b 2.0))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e+42) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.25e-137) {
tmp = -0.3333333333333333 * ((b - sqrt(((b * b) - (c * (a * 3.0))))) / a);
} else {
tmp = -c / fma(0.5, (-3.0 * (a * (c / b))), (b * 2.0));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.35e+42) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1.25e-137) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0))))) / a)); else tmp = Float64(Float64(-c) / fma(0.5, Float64(-3.0 * Float64(a * Float64(c / b))), Float64(b * 2.0))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.35e+42], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.25e-137], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-c) / N[(0.5 * N[(-3.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.35 \cdot 10^{+42}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{-137}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{\mathsf{fma}\left(0.5, -3 \cdot \left(a \cdot \frac{c}{b}\right), b \cdot 2\right)}\\
\end{array}
\end{array}
if b < -1.35e42Initial program 62.6%
neg-sub062.6%
associate-+l-62.6%
sub0-neg62.6%
neg-mul-162.6%
associate-*r/62.6%
*-commutative62.6%
metadata-eval62.6%
metadata-eval62.6%
times-frac62.6%
*-commutative62.6%
times-frac62.5%
Simplified62.6%
Applied egg-rr0.0%
*-commutative0.0%
associate-*r/0.0%
associate-/l*0.0%
*-commutative0.0%
*-commutative0.0%
associate-/r*0.0%
Simplified0.0%
Taylor expanded in c around 0 12.9%
mul-1-neg12.9%
Simplified12.9%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt95.1%
metadata-eval95.1%
*-commutative95.1%
associate-*l/95.2%
Simplified95.2%
if -1.35e42 < b < 1.25e-137Initial program 81.6%
/-rgt-identity81.6%
metadata-eval81.6%
associate-/l*81.6%
associate-*r/81.6%
*-commutative81.6%
associate-*l/81.6%
associate-*r/81.6%
metadata-eval81.6%
metadata-eval81.6%
times-frac81.6%
neg-mul-181.6%
distribute-rgt-neg-in81.6%
times-frac81.7%
metadata-eval81.7%
neg-mul-181.7%
Simplified81.6%
fma-udef81.6%
associate-*r*81.6%
*-commutative81.6%
metadata-eval81.6%
cancel-sign-sub-inv81.6%
associate-*r*81.7%
*-commutative81.7%
*-commutative81.7%
Applied egg-rr81.7%
if 1.25e-137 < b Initial program 19.1%
neg-sub019.1%
associate-+l-19.1%
sub0-neg19.1%
neg-mul-119.1%
associate-*r/19.1%
*-commutative19.1%
metadata-eval19.1%
metadata-eval19.1%
times-frac19.1%
*-commutative19.1%
times-frac19.1%
Simplified19.1%
Applied egg-rr17.3%
*-commutative17.3%
associate-*r/17.3%
associate-/l*17.3%
*-commutative17.3%
*-commutative17.3%
associate-/r*17.5%
Simplified17.5%
Taylor expanded in c around 0 64.6%
mul-1-neg64.6%
Simplified64.6%
Taylor expanded in b around inf 0.0%
fma-def0.0%
*-rgt-identity0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt82.3%
times-frac82.3%
associate-*l/84.2%
*-commutative84.2%
metadata-eval84.2%
*-commutative84.2%
Simplified84.2%
Final simplification86.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2.1e-39)
(/ (* b -0.6666666666666666) a)
(if (<= b 1e-137)
(* -0.3333333333333333 (/ (- b (sqrt (* c (* a -3.0)))) a))
(/ (- c) (fma 0.5 (* -3.0 (* a (/ c b))) (* b 2.0))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.1e-39) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1e-137) {
tmp = -0.3333333333333333 * ((b - sqrt((c * (a * -3.0)))) / a);
} else {
tmp = -c / fma(0.5, (-3.0 * (a * (c / b))), (b * 2.0));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.1e-39) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1e-137) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(c * Float64(a * -3.0)))) / a)); else tmp = Float64(Float64(-c) / fma(0.5, Float64(-3.0 * Float64(a * Float64(c / b))), Float64(b * 2.0))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.1e-39], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1e-137], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-c) / N[(0.5 * N[(-3.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.1 \cdot 10^{-39}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 10^{-137}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{\mathsf{fma}\left(0.5, -3 \cdot \left(a \cdot \frac{c}{b}\right), b \cdot 2\right)}\\
\end{array}
\end{array}
if b < -2.09999999999999993e-39Initial program 67.3%
neg-sub067.3%
associate-+l-67.3%
sub0-neg67.3%
neg-mul-167.3%
associate-*r/67.3%
*-commutative67.3%
metadata-eval67.3%
metadata-eval67.3%
times-frac67.3%
*-commutative67.3%
times-frac67.1%
Simplified67.3%
Applied egg-rr2.7%
*-commutative2.7%
associate-*r/2.7%
associate-/l*2.7%
*-commutative2.7%
*-commutative2.7%
associate-/r*4.0%
Simplified4.0%
Taylor expanded in c around 0 15.0%
mul-1-neg15.0%
Simplified15.0%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt90.7%
metadata-eval90.7%
*-commutative90.7%
associate-*l/90.8%
Simplified90.8%
if -2.09999999999999993e-39 < b < 9.99999999999999978e-138Initial program 79.9%
/-rgt-identity79.9%
metadata-eval79.9%
associate-/l*79.9%
associate-*r/79.9%
*-commutative79.9%
associate-*l/79.9%
associate-*r/79.9%
metadata-eval79.9%
metadata-eval79.9%
times-frac79.9%
neg-mul-179.9%
distribute-rgt-neg-in79.9%
times-frac80.0%
metadata-eval80.0%
neg-mul-180.0%
Simplified80.0%
Taylor expanded in b around 0 72.9%
*-commutative72.9%
associate-*l*72.9%
Simplified72.9%
if 9.99999999999999978e-138 < b Initial program 19.1%
neg-sub019.1%
associate-+l-19.1%
sub0-neg19.1%
neg-mul-119.1%
associate-*r/19.1%
*-commutative19.1%
metadata-eval19.1%
metadata-eval19.1%
times-frac19.1%
*-commutative19.1%
times-frac19.1%
Simplified19.1%
Applied egg-rr17.3%
*-commutative17.3%
associate-*r/17.3%
associate-/l*17.3%
*-commutative17.3%
*-commutative17.3%
associate-/r*17.5%
Simplified17.5%
Taylor expanded in c around 0 64.6%
mul-1-neg64.6%
Simplified64.6%
Taylor expanded in b around inf 0.0%
fma-def0.0%
*-rgt-identity0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt82.3%
times-frac82.3%
associate-*l/84.2%
*-commutative84.2%
metadata-eval84.2%
*-commutative84.2%
Simplified84.2%
Final simplification82.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2e-40)
(/ (* b -0.6666666666666666) a)
(if (<= b 1.2e-137)
(* -0.3333333333333333 (/ (- b (sqrt (* c (* a -3.0)))) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-40) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.2e-137) {
tmp = -0.3333333333333333 * ((b - sqrt((c * (a * -3.0)))) / a);
} else {
tmp = (c / b) * -0.5;
}
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 <= (-2d-40)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 1.2d-137) then
tmp = (-0.3333333333333333d0) * ((b - sqrt((c * (a * (-3.0d0))))) / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-40) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1.2e-137) {
tmp = -0.3333333333333333 * ((b - Math.sqrt((c * (a * -3.0)))) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-40: tmp = (b * -0.6666666666666666) / a elif b <= 1.2e-137: tmp = -0.3333333333333333 * ((b - math.sqrt((c * (a * -3.0)))) / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-40) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1.2e-137) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(c * Float64(a * -3.0)))) / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-40) tmp = (b * -0.6666666666666666) / a; elseif (b <= 1.2e-137) tmp = -0.3333333333333333 * ((b - sqrt((c * (a * -3.0)))) / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-40], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.2e-137], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-40}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-137}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{c \cdot \left(a \cdot -3\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -1.9999999999999999e-40Initial program 67.3%
neg-sub067.3%
associate-+l-67.3%
sub0-neg67.3%
neg-mul-167.3%
associate-*r/67.3%
*-commutative67.3%
metadata-eval67.3%
metadata-eval67.3%
times-frac67.3%
*-commutative67.3%
times-frac67.1%
Simplified67.3%
Applied egg-rr2.7%
*-commutative2.7%
associate-*r/2.7%
associate-/l*2.7%
*-commutative2.7%
*-commutative2.7%
associate-/r*4.0%
Simplified4.0%
Taylor expanded in c around 0 15.0%
mul-1-neg15.0%
Simplified15.0%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt90.7%
metadata-eval90.7%
*-commutative90.7%
associate-*l/90.8%
Simplified90.8%
if -1.9999999999999999e-40 < b < 1.2e-137Initial program 79.9%
/-rgt-identity79.9%
metadata-eval79.9%
associate-/l*79.9%
associate-*r/79.9%
*-commutative79.9%
associate-*l/79.9%
associate-*r/79.9%
metadata-eval79.9%
metadata-eval79.9%
times-frac79.9%
neg-mul-179.9%
distribute-rgt-neg-in79.9%
times-frac80.0%
metadata-eval80.0%
neg-mul-180.0%
Simplified80.0%
Taylor expanded in b around 0 72.9%
*-commutative72.9%
associate-*l*72.9%
Simplified72.9%
if 1.2e-137 < b Initial program 19.1%
neg-sub019.1%
associate-+l-19.1%
sub0-neg19.1%
neg-mul-119.1%
associate-*r/19.1%
metadata-eval19.1%
metadata-eval19.1%
times-frac19.1%
*-commutative19.1%
times-frac19.1%
associate-*l/19.1%
Simplified19.1%
Taylor expanded in b around inf 83.9%
Final simplification82.8%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
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 = (-0.6666666666666666d0) * (b / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.8%
neg-sub072.8%
associate-+l-72.8%
sub0-neg72.8%
neg-mul-172.8%
associate-*r/72.8%
metadata-eval72.8%
metadata-eval72.8%
times-frac72.8%
*-commutative72.8%
times-frac72.7%
associate-*l/72.8%
Simplified72.7%
Taylor expanded in b around -inf 63.0%
*-commutative63.0%
Simplified63.0%
if -4.999999999999985e-310 < b Initial program 29.8%
neg-sub029.8%
associate-+l-29.8%
sub0-neg29.8%
neg-mul-129.8%
associate-*r/29.8%
metadata-eval29.8%
metadata-eval29.8%
times-frac29.8%
*-commutative29.8%
times-frac29.8%
associate-*l/29.8%
Simplified29.8%
Taylor expanded in b around inf 70.6%
Final simplification67.0%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (* b -0.6666666666666666) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c / b) * -0.5;
}
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 * (-0.6666666666666666d0)) / a
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (b * -0.6666666666666666) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(b * -0.6666666666666666) / a); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (b * -0.6666666666666666) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.8%
neg-sub072.8%
associate-+l-72.8%
sub0-neg72.8%
neg-mul-172.8%
associate-*r/72.8%
*-commutative72.8%
metadata-eval72.8%
metadata-eval72.8%
times-frac72.8%
*-commutative72.8%
times-frac72.7%
Simplified72.8%
Applied egg-rr23.5%
*-commutative23.5%
associate-*r/23.4%
associate-/l*23.4%
*-commutative23.4%
*-commutative23.4%
associate-/r*28.7%
Simplified28.7%
Taylor expanded in c around 0 35.8%
mul-1-neg35.8%
Simplified35.8%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt63.0%
metadata-eval63.0%
*-commutative63.0%
associate-*l/63.1%
Simplified63.1%
if -4.999999999999985e-310 < b Initial program 29.8%
neg-sub029.8%
associate-+l-29.8%
sub0-neg29.8%
neg-mul-129.8%
associate-*r/29.8%
metadata-eval29.8%
metadata-eval29.8%
times-frac29.8%
*-commutative29.8%
times-frac29.8%
associate-*l/29.8%
Simplified29.8%
Taylor expanded in b around inf 70.6%
Final simplification67.1%
(FPCore (a b c) :precision binary64 (* (/ c b) -0.5))
double code(double a, double b, double c) {
return (c / b) * -0.5;
}
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) * (-0.5d0)
end function
public static double code(double a, double b, double c) {
return (c / b) * -0.5;
}
def code(a, b, c): return (c / b) * -0.5
function code(a, b, c) return Float64(Float64(c / b) * -0.5) end
function tmp = code(a, b, c) tmp = (c / b) * -0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot -0.5
\end{array}
Initial program 50.1%
neg-sub050.1%
associate-+l-50.1%
sub0-neg50.1%
neg-mul-150.1%
associate-*r/50.1%
metadata-eval50.1%
metadata-eval50.1%
times-frac50.1%
*-commutative50.1%
times-frac50.1%
associate-*l/50.1%
Simplified50.1%
Taylor expanded in b around inf 38.4%
Final simplification38.4%
herbie shell --seed 2023257
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))