
(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 14 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 -4.1e+108)
(fma (/ c b) 0.5 (/ -0.6666666666666666 (/ a b)))
(if (<= b 5.4e-16)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.1e+108) {
tmp = fma((c / b), 0.5, (-0.6666666666666666 / (a / b)));
} else if (b <= 5.4e-16) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.1e+108) tmp = fma(Float64(c / b), 0.5, Float64(-0.6666666666666666 / Float64(a / b))); elseif (b <= 5.4e-16) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.1e+108], N[(N[(c / b), $MachinePrecision] * 0.5 + N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.4e-16], 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], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.1 \cdot 10^{+108}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b}, 0.5, \frac{-0.6666666666666666}{\frac{a}{b}}\right)\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-16}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.0999999999999999e108Initial program 52.0%
sqr-neg52.0%
sqr-neg52.0%
associate-*l*52.0%
Simplified52.0%
Taylor expanded in b around -inf 88.9%
+-commutative88.9%
*-commutative88.9%
fma-define88.9%
clear-num88.9%
un-div-inv89.1%
Applied egg-rr89.1%
if -4.0999999999999999e108 < b < 5.39999999999999999e-16Initial program 78.4%
if 5.39999999999999999e-16 < b Initial program 18.3%
sqr-neg18.3%
sqr-neg18.3%
associate-*l*18.3%
Simplified18.3%
Taylor expanded in b around inf 84.6%
*-commutative84.6%
associate-*l/84.6%
Simplified84.6%
Final simplification81.9%
(FPCore (a b c)
:precision binary64
(if (<= b -4.3e+106)
(fma (/ c b) 0.5 (/ -0.6666666666666666 (/ a b)))
(if (<= b 6.2e-16)
(/ (- (sqrt (- (* b b) (* 3.0 (* c a)))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.3e+106) {
tmp = fma((c / b), 0.5, (-0.6666666666666666 / (a / b)));
} else if (b <= 6.2e-16) {
tmp = (sqrt(((b * b) - (3.0 * (c * a)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.3e+106) tmp = fma(Float64(c / b), 0.5, Float64(-0.6666666666666666 / Float64(a / b))); elseif (b <= 6.2e-16) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(c * a)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.3e+106], N[(N[(c / b), $MachinePrecision] * 0.5 + N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.2e-16], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $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.3 \cdot 10^{+106}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b}, 0.5, \frac{-0.6666666666666666}{\frac{a}{b}}\right)\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-16}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.3e106Initial program 52.0%
sqr-neg52.0%
sqr-neg52.0%
associate-*l*52.0%
Simplified52.0%
Taylor expanded in b around -inf 88.9%
+-commutative88.9%
*-commutative88.9%
fma-define88.9%
clear-num88.9%
un-div-inv89.1%
Applied egg-rr89.1%
if -4.3e106 < b < 6.2000000000000002e-16Initial program 78.4%
sqr-neg78.4%
sqr-neg78.4%
associate-*l*78.3%
Simplified78.3%
if 6.2000000000000002e-16 < b Initial program 18.3%
sqr-neg18.3%
sqr-neg18.3%
associate-*l*18.3%
Simplified18.3%
Taylor expanded in b around inf 84.6%
*-commutative84.6%
associate-*l/84.6%
Simplified84.6%
Final simplification81.9%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e-25)
(fma (/ c b) 0.5 (/ -0.6666666666666666 (/ a b)))
(if (<= b 5.4e-16)
(* (/ -0.3333333333333333 a) (- b (sqrt (* a (* c -3.0)))))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.8e-25) {
tmp = fma((c / b), 0.5, (-0.6666666666666666 / (a / b)));
} else if (b <= 5.4e-16) {
tmp = (-0.3333333333333333 / a) * (b - sqrt((a * (c * -3.0))));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.8e-25) tmp = fma(Float64(c / b), 0.5, Float64(-0.6666666666666666 / Float64(a / b))); elseif (b <= 5.4e-16) tmp = Float64(Float64(-0.3333333333333333 / a) * Float64(b - sqrt(Float64(a * Float64(c * -3.0))))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.8e-25], N[(N[(c / b), $MachinePrecision] * 0.5 + N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.4e-16], N[(N[(-0.3333333333333333 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{-25}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b}, 0.5, \frac{-0.6666666666666666}{\frac{a}{b}}\right)\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-16}:\\
\;\;\;\;\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{a \cdot \left(c \cdot -3\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.80000000000000018e-25Initial program 69.5%
sqr-neg69.5%
sqr-neg69.5%
associate-*l*69.5%
Simplified69.5%
Taylor expanded in b around -inf 83.7%
+-commutative83.7%
*-commutative83.7%
fma-define83.7%
clear-num83.6%
un-div-inv83.8%
Applied egg-rr83.8%
if -4.80000000000000018e-25 < b < 5.39999999999999999e-16Initial program 75.1%
sqr-neg75.1%
sqr-neg75.1%
associate-*l*74.9%
Simplified74.9%
Taylor expanded in b around 0 64.6%
frac-2neg64.6%
div-inv64.6%
distribute-neg-in64.6%
add-sqr-sqrt32.2%
sqrt-unprod64.5%
sqr-neg64.5%
sqrt-unprod32.5%
add-sqr-sqrt63.0%
sub-neg63.0%
add-sqr-sqrt30.4%
sqrt-unprod62.8%
sqr-neg62.8%
sqrt-unprod32.4%
add-sqr-sqrt64.6%
*-commutative64.6%
associate-*r*64.6%
*-commutative64.6%
distribute-rgt-neg-in64.6%
metadata-eval64.6%
metadata-eval64.6%
div-inv64.6%
Applied egg-rr64.6%
*-commutative64.6%
Simplified64.6%
if 5.39999999999999999e-16 < b Initial program 18.3%
sqr-neg18.3%
sqr-neg18.3%
associate-*l*18.3%
Simplified18.3%
Taylor expanded in b around inf 84.6%
*-commutative84.6%
associate-*l/84.6%
Simplified84.6%
Final simplification75.9%
(FPCore (a b c)
:precision binary64
(if (<= b -5.6e-25)
(fma (/ c b) 0.5 (/ -0.6666666666666666 (/ a b)))
(if (<= b 5.4e-16)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.6e-25) {
tmp = fma((c / b), 0.5, (-0.6666666666666666 / (a / b)));
} else if (b <= 5.4e-16) {
tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5.6e-25) tmp = fma(Float64(c / b), 0.5, Float64(-0.6666666666666666 / Float64(a / b))); elseif (b <= 5.4e-16) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5.6e-25], N[(N[(c / b), $MachinePrecision] * 0.5 + N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.4e-16], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $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 -5.6 \cdot 10^{-25}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b}, 0.5, \frac{-0.6666666666666666}{\frac{a}{b}}\right)\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-16}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.59999999999999976e-25Initial program 69.5%
sqr-neg69.5%
sqr-neg69.5%
associate-*l*69.5%
Simplified69.5%
Taylor expanded in b around -inf 83.7%
+-commutative83.7%
*-commutative83.7%
fma-define83.7%
clear-num83.6%
un-div-inv83.8%
Applied egg-rr83.8%
if -5.59999999999999976e-25 < b < 5.39999999999999999e-16Initial program 75.1%
sqr-neg75.1%
sqr-neg75.1%
associate-*l*74.9%
Simplified74.9%
Taylor expanded in b around 0 64.6%
+-commutative64.6%
unsub-neg64.6%
*-commutative64.6%
associate-*r*64.7%
Applied egg-rr64.7%
if 5.39999999999999999e-16 < b Initial program 18.3%
sqr-neg18.3%
sqr-neg18.3%
associate-*l*18.3%
Simplified18.3%
Taylor expanded in b around inf 84.6%
*-commutative84.6%
associate-*l/84.6%
Simplified84.6%
Final simplification75.9%
(FPCore (a b c)
:precision binary64
(if (<= b -7.6e-25)
(/ (fma b -2.0 (* (* c (/ a b)) 1.5)) (* a 3.0))
(if (<= b 5.4e-16)
(/ (- (sqrt (* a (* c -3.0))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.6e-25) {
tmp = fma(b, -2.0, ((c * (a / b)) * 1.5)) / (a * 3.0);
} else if (b <= 5.4e-16) {
tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -7.6e-25) tmp = Float64(fma(b, -2.0, Float64(Float64(c * Float64(a / b)) * 1.5)) / Float64(a * 3.0)); elseif (b <= 5.4e-16) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -7.6e-25], N[(N[(b * -2.0 + N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.4e-16], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $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 -7.6 \cdot 10^{-25}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, -2, \left(c \cdot \frac{a}{b}\right) \cdot 1.5\right)}{a \cdot 3}\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-16}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -7.5999999999999996e-25Initial program 69.5%
sqr-neg69.5%
sqr-neg69.5%
associate-*l*69.5%
Simplified69.5%
Taylor expanded in b around -inf 80.4%
*-commutative80.4%
fma-define80.4%
*-commutative80.4%
*-commutative80.4%
associate-/l*84.0%
Simplified84.0%
if -7.5999999999999996e-25 < b < 5.39999999999999999e-16Initial program 75.1%
sqr-neg75.1%
sqr-neg75.1%
associate-*l*74.9%
Simplified74.9%
Taylor expanded in b around 0 64.6%
+-commutative64.6%
unsub-neg64.6%
*-commutative64.6%
associate-*r*64.7%
Applied egg-rr64.7%
if 5.39999999999999999e-16 < b Initial program 18.3%
sqr-neg18.3%
sqr-neg18.3%
associate-*l*18.3%
Simplified18.3%
Taylor expanded in b around inf 84.6%
*-commutative84.6%
associate-*l/84.6%
Simplified84.6%
Final simplification76.0%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (fma (/ c b) 0.5 (/ -0.6666666666666666 (/ a b))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = fma((c / b), 0.5, (-0.6666666666666666 / (a / b)));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = fma(Float64(c / b), 0.5, Float64(-0.6666666666666666 / Float64(a / b))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(N[(c / b), $MachinePrecision] * 0.5 + N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b}, 0.5, \frac{-0.6666666666666666}{\frac{a}{b}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 76.5%
sqr-neg76.5%
sqr-neg76.5%
associate-*l*76.5%
Simplified76.5%
Taylor expanded in b around -inf 57.6%
+-commutative57.6%
*-commutative57.6%
fma-define57.6%
clear-num57.5%
un-div-inv57.7%
Applied egg-rr57.7%
if -9.999999999999969e-311 < b Initial program 36.5%
sqr-neg36.5%
sqr-neg36.5%
associate-*l*36.4%
Simplified36.4%
Taylor expanded in b around inf 60.7%
*-commutative60.7%
associate-*l/60.7%
Simplified60.7%
Final simplification59.4%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (+ (* -0.6666666666666666 (/ b a)) (* (/ c b) 0.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} 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 <= (-1d-310)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + ((c / b) * 0.5d0)
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 <= -1e-310) {
tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(Float64(c / b) * 0.5)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-310) tmp = (-0.6666666666666666 * (b / a)) + ((c / b) * 0.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 76.5%
sqr-neg76.5%
sqr-neg76.5%
associate-*l*76.5%
Simplified76.5%
Taylor expanded in b around -inf 57.6%
if -9.999999999999969e-311 < b Initial program 36.5%
sqr-neg36.5%
sqr-neg36.5%
associate-*l*36.4%
Simplified36.4%
Taylor expanded in b around inf 60.7%
*-commutative60.7%
associate-*l/60.7%
Simplified60.7%
Final simplification59.3%
(FPCore (a b c) :precision binary64 (if (<= b 7e+72) (* b (/ -0.6666666666666666 a)) (* c (/ 0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7e+72) {
tmp = b * (-0.6666666666666666 / a);
} 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 <= 7d+72) then
tmp = b * ((-0.6666666666666666d0) / a)
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 <= 7e+72) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = c * (0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7e+72: tmp = b * (-0.6666666666666666 / a) else: tmp = c * (0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7e+72) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(c * Float64(0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 7e+72) tmp = b * (-0.6666666666666666 / a); else tmp = c * (0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7e+72], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7 \cdot 10^{+72}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if b < 7.0000000000000002e72Initial program 67.1%
sqr-neg67.1%
sqr-neg67.1%
associate-*l*67.0%
Simplified67.0%
Taylor expanded in b around -inf 35.9%
*-commutative35.9%
Simplified35.9%
*-commutative35.9%
clear-num35.9%
un-div-inv36.0%
Applied egg-rr36.0%
associate-/r/36.0%
Simplified36.0%
if 7.0000000000000002e72 < b Initial program 19.6%
sqr-neg19.6%
sqr-neg19.6%
associate-*l*19.6%
Simplified19.6%
Applied egg-rr6.3%
unpow-16.3%
associate-/r*6.2%
metadata-eval6.2%
Simplified6.2%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt28.5%
times-frac28.5%
metadata-eval28.5%
Simplified28.5%
Taylor expanded in b around 0 28.5%
associate-*r/28.5%
*-commutative28.5%
associate-/l*28.5%
Simplified28.5%
Final simplification34.0%
(FPCore (a b c) :precision binary64 (if (<= b 5.1e+72) (/ -0.6666666666666666 (/ a b)) (* c (/ 0.5 b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.1e+72) {
tmp = -0.6666666666666666 / (a / b);
} 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 <= 5.1d+72) then
tmp = (-0.6666666666666666d0) / (a / b)
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 <= 5.1e+72) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = c * (0.5 / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.1e+72: tmp = -0.6666666666666666 / (a / b) else: tmp = c * (0.5 / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.1e+72) tmp = Float64(-0.6666666666666666 / Float64(a / b)); else tmp = Float64(c * Float64(0.5 / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 5.1e+72) tmp = -0.6666666666666666 / (a / b); else tmp = c * (0.5 / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.1e+72], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(c * N[(0.5 / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.1 \cdot 10^{+72}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{0.5}{b}\\
\end{array}
\end{array}
if b < 5.09999999999999977e72Initial program 67.1%
sqr-neg67.1%
sqr-neg67.1%
associate-*l*67.0%
Simplified67.0%
Taylor expanded in b around -inf 35.9%
*-commutative35.9%
Simplified35.9%
*-commutative35.9%
clear-num35.9%
un-div-inv36.0%
Applied egg-rr36.0%
if 5.09999999999999977e72 < b Initial program 19.6%
sqr-neg19.6%
sqr-neg19.6%
associate-*l*19.6%
Simplified19.6%
Applied egg-rr6.3%
unpow-16.3%
associate-/r*6.2%
metadata-eval6.2%
Simplified6.2%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt28.5%
times-frac28.5%
metadata-eval28.5%
Simplified28.5%
Taylor expanded in b around 0 28.5%
associate-*r/28.5%
*-commutative28.5%
associate-/l*28.5%
Simplified28.5%
Final simplification34.0%
(FPCore (a b c) :precision binary64 (if (<= b 5.1e+72) (/ -0.6666666666666666 (/ a b)) (/ 0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.1e+72) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = 0.5 / (b / c);
}
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 <= 5.1d+72) then
tmp = (-0.6666666666666666d0) / (a / b)
else
tmp = 0.5d0 / (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 5.1e+72) {
tmp = -0.6666666666666666 / (a / b);
} else {
tmp = 0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.1e+72: tmp = -0.6666666666666666 / (a / b) else: tmp = 0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.1e+72) tmp = Float64(-0.6666666666666666 / Float64(a / b)); else tmp = Float64(0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 5.1e+72) tmp = -0.6666666666666666 / (a / b); else tmp = 0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.1e+72], N[(-0.6666666666666666 / N[(a / b), $MachinePrecision]), $MachinePrecision], N[(0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.1 \cdot 10^{+72}:\\
\;\;\;\;\frac{-0.6666666666666666}{\frac{a}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < 5.09999999999999977e72Initial program 67.1%
sqr-neg67.1%
sqr-neg67.1%
associate-*l*67.0%
Simplified67.0%
Taylor expanded in b around -inf 35.9%
*-commutative35.9%
Simplified35.9%
*-commutative35.9%
clear-num35.9%
un-div-inv36.0%
Applied egg-rr36.0%
if 5.09999999999999977e72 < b Initial program 19.6%
sqr-neg19.6%
sqr-neg19.6%
associate-*l*19.6%
Simplified19.6%
Applied egg-rr6.3%
unpow-16.3%
associate-/r*6.2%
metadata-eval6.2%
Simplified6.2%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt28.5%
times-frac28.5%
metadata-eval28.5%
Simplified28.5%
div-inv28.5%
associate-*r/28.5%
Applied egg-rr28.5%
associate-*r/28.5%
metadata-eval28.5%
associate-/l*28.5%
associate-/r*28.5%
metadata-eval28.5%
Simplified28.5%
Final simplification34.0%
(FPCore (a b c) :precision binary64 (if (<= b 5.2e+72) (/ b (* a -1.5)) (/ 0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.2e+72) {
tmp = b / (a * -1.5);
} else {
tmp = 0.5 / (b / c);
}
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 <= 5.2d+72) then
tmp = b / (a * (-1.5d0))
else
tmp = 0.5d0 / (b / c)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 5.2e+72) {
tmp = b / (a * -1.5);
} else {
tmp = 0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.2e+72: tmp = b / (a * -1.5) else: tmp = 0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.2e+72) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 5.2e+72) tmp = b / (a * -1.5); else tmp = 0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.2e+72], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.2 \cdot 10^{+72}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < 5.19999999999999963e72Initial program 67.1%
sqr-neg67.1%
sqr-neg67.1%
associate-*l*67.0%
Simplified67.0%
Taylor expanded in b around -inf 35.9%
*-commutative35.9%
Simplified35.9%
*-commutative35.9%
clear-num35.9%
un-div-inv36.0%
Applied egg-rr36.0%
associate-/r/36.0%
Simplified36.0%
*-commutative36.0%
clear-num35.9%
un-div-inv36.0%
div-inv36.0%
metadata-eval36.0%
Applied egg-rr36.0%
if 5.19999999999999963e72 < b Initial program 19.6%
sqr-neg19.6%
sqr-neg19.6%
associate-*l*19.6%
Simplified19.6%
Applied egg-rr6.3%
unpow-16.3%
associate-/r*6.2%
metadata-eval6.2%
Simplified6.2%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt28.5%
times-frac28.5%
metadata-eval28.5%
Simplified28.5%
div-inv28.5%
associate-*r/28.5%
Applied egg-rr28.5%
associate-*r/28.5%
metadata-eval28.5%
associate-/l*28.5%
associate-/r*28.5%
metadata-eval28.5%
Simplified28.5%
Final simplification34.0%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = b / (a * -1.5);
} 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 <= (-1d-310)) then
tmp = b / (a * (-1.5d0))
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 <= -1e-310) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(b / Float64(a * -1.5)); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-310) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(b / N[(a * -1.5), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 76.5%
sqr-neg76.5%
sqr-neg76.5%
associate-*l*76.5%
Simplified76.5%
Taylor expanded in b around -inf 57.0%
*-commutative57.0%
Simplified57.0%
*-commutative57.0%
clear-num56.9%
un-div-inv57.0%
Applied egg-rr57.0%
associate-/r/57.0%
Simplified57.0%
*-commutative57.0%
clear-num56.9%
un-div-inv57.0%
div-inv57.1%
metadata-eval57.1%
Applied egg-rr57.1%
if -9.999999999999969e-311 < b Initial program 36.5%
sqr-neg36.5%
sqr-neg36.5%
associate-*l*36.4%
Simplified36.4%
Taylor expanded in b around inf 60.7%
*-commutative60.7%
associate-*l/60.7%
Simplified60.7%
Final simplification59.1%
(FPCore (a b c) :precision binary64 (* b (/ 0.6666666666666666 a)))
double code(double a, double b, double c) {
return b * (0.6666666666666666 / 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 * (0.6666666666666666d0 / a)
end function
public static double code(double a, double b, double c) {
return b * (0.6666666666666666 / a);
}
def code(a, b, c): return b * (0.6666666666666666 / a)
function code(a, b, c) return Float64(b * Float64(0.6666666666666666 / a)) end
function tmp = code(a, b, c) tmp = b * (0.6666666666666666 / a); end
code[a_, b_, c_] := N[(b * N[(0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \frac{0.6666666666666666}{a}
\end{array}
Initial program 54.5%
sqr-neg54.5%
sqr-neg54.5%
associate-*l*54.4%
Simplified54.4%
Applied egg-rr31.1%
*-commutative31.1%
associate-*l/31.1%
associate-*r/31.1%
Simplified31.1%
Taylor expanded in b around inf 3.0%
associate-*r/3.0%
*-commutative3.0%
associate-/l*3.0%
Simplified3.0%
Final simplification3.0%
(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 54.5%
sqr-neg54.5%
sqr-neg54.5%
associate-*l*54.4%
Simplified54.4%
Applied egg-rr31.1%
unpow-131.1%
associate-/r*31.1%
metadata-eval31.1%
Simplified31.1%
Taylor expanded in b around -inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt9.9%
times-frac9.9%
metadata-eval9.9%
Simplified9.9%
Taylor expanded in b around 0 9.9%
associate-*r/9.9%
*-commutative9.9%
associate-/l*9.9%
Simplified9.9%
Final simplification9.9%
herbie shell --seed 2024045
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))