
(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 11 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 -5.2e+94)
(/ (* b -0.6666666666666666) a)
(if (<= b 1e-80)
(/ (- (sqrt (fma b b (* 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.2e+94) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 1e-80) {
tmp = (sqrt(fma(b, b, (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.2e+94) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 1e-80) tmp = Float64(Float64(sqrt(fma(b, b, 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.2e+94], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1e-80], N[(N[(N[Sqrt[N[(b * b + N[(a * N[(c * -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 -5.2 \cdot 10^{+94}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 10^{-80}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.1999999999999998e94Initial program 54.1%
fma-neg54.1%
associate-*l*54.1%
distribute-lft-neg-in54.1%
metadata-eval54.1%
*-commutative54.1%
associate-*r*54.1%
add-cube-cbrt54.1%
pow354.1%
*-commutative54.1%
associate-*r*54.1%
metadata-eval54.1%
distribute-rgt-neg-in54.1%
*-commutative54.1%
*-commutative54.1%
*-commutative54.1%
distribute-rgt-neg-in54.1%
metadata-eval54.1%
Applied egg-rr54.1%
Taylor expanded in b around -inf 93.6%
associate-*r/93.8%
*-commutative93.8%
Simplified93.8%
if -5.1999999999999998e94 < b < 9.99999999999999961e-81Initial program 86.4%
+-commutative86.4%
sqr-neg86.4%
unsub-neg86.4%
div-sub86.3%
--rgt-identity86.3%
div-sub86.4%
Simplified86.4%
if 9.99999999999999961e-81 < b Initial program 15.5%
Taylor expanded in b around inf 84.7%
associate-*r/84.7%
Simplified84.7%
Final simplification87.6%
(FPCore (a b c)
:precision binary64
(if (<= b -2.2e+94)
(/ (* b -0.6666666666666666) a)
(if (<= b 7e-68)
(/ (- (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 <= -2.2e+94) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 7e-68) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (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 <= (-2.2d+94)) then
tmp = (b * (-0.6666666666666666d0)) / a
else if (b <= 7d-68) then
tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (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 <= -2.2e+94) {
tmp = (b * -0.6666666666666666) / a;
} else if (b <= 7e-68) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.2e+94: tmp = (b * -0.6666666666666666) / a elif b <= 7e-68: tmp = (math.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 <= -2.2e+94) tmp = Float64(Float64(b * -0.6666666666666666) / a); elseif (b <= 7e-68) 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
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.2e+94) tmp = (b * -0.6666666666666666) / a; elseif (b <= 7e-68) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.2e+94], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 7e-68], 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 -2.2 \cdot 10^{+94}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{-68}:\\
\;\;\;\;\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 < -2.20000000000000012e94Initial program 54.1%
fma-neg54.1%
associate-*l*54.1%
distribute-lft-neg-in54.1%
metadata-eval54.1%
*-commutative54.1%
associate-*r*54.1%
add-cube-cbrt54.1%
pow354.1%
*-commutative54.1%
associate-*r*54.1%
metadata-eval54.1%
distribute-rgt-neg-in54.1%
*-commutative54.1%
*-commutative54.1%
*-commutative54.1%
distribute-rgt-neg-in54.1%
metadata-eval54.1%
Applied egg-rr54.1%
Taylor expanded in b around -inf 93.6%
associate-*r/93.8%
*-commutative93.8%
Simplified93.8%
if -2.20000000000000012e94 < b < 7.00000000000000026e-68Initial program 84.9%
if 7.00000000000000026e-68 < b Initial program 14.8%
Taylor expanded in b around inf 86.3%
associate-*r/86.3%
Simplified86.3%
Final simplification87.6%
(FPCore (a b c)
:precision binary64
(if (<= b -5.2e-16)
(/ (- (- (* a (* c (/ 1.5 b))) b) b) (* a 3.0))
(if (<= b 6.8e-89)
(/ (- (sqrt (* -3.0 (* a c))) b) (* a 3.0))
(/ (* c -0.5) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2e-16) {
tmp = (((a * (c * (1.5 / b))) - b) - b) / (a * 3.0);
} else if (b <= 6.8e-89) {
tmp = (sqrt((-3.0 * (a * c))) - b) / (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 <= (-5.2d-16)) then
tmp = (((a * (c * (1.5d0 / b))) - b) - b) / (a * 3.0d0)
else if (b <= 6.8d-89) then
tmp = (sqrt(((-3.0d0) * (a * c))) - b) / (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 <= -5.2e-16) {
tmp = (((a * (c * (1.5 / b))) - b) - b) / (a * 3.0);
} else if (b <= 6.8e-89) {
tmp = (Math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.2e-16: tmp = (((a * (c * (1.5 / b))) - b) - b) / (a * 3.0) elif b <= 6.8e-89: tmp = (math.sqrt((-3.0 * (a * c))) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.2e-16) tmp = Float64(Float64(Float64(Float64(a * Float64(c * Float64(1.5 / b))) - b) - b) / Float64(a * 3.0)); elseif (b <= 6.8e-89) tmp = Float64(Float64(sqrt(Float64(-3.0 * Float64(a * c))) - b) / 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 <= -5.2e-16) tmp = (((a * (c * (1.5 / b))) - b) - b) / (a * 3.0); elseif (b <= 6.8e-89) tmp = (sqrt((-3.0 * (a * c))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.2e-16], N[(N[(N[(N[(a * N[(c * N[(1.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.8e-89], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $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.2 \cdot 10^{-16}:\\
\;\;\;\;\frac{\left(a \cdot \left(c \cdot \frac{1.5}{b}\right) - b\right) - b}{a \cdot 3}\\
\mathbf{elif}\;b \leq 6.8 \cdot 10^{-89}:\\
\;\;\;\;\frac{\sqrt{-3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -5.1999999999999997e-16Initial program 66.7%
fma-neg66.7%
associate-*l*66.7%
distribute-lft-neg-in66.7%
metadata-eval66.7%
*-commutative66.7%
associate-*r*66.7%
add-cube-cbrt66.6%
pow366.6%
*-commutative66.6%
associate-*r*66.6%
metadata-eval66.6%
distribute-rgt-neg-in66.6%
*-commutative66.6%
*-commutative66.6%
*-commutative66.6%
distribute-rgt-neg-in66.6%
metadata-eval66.6%
Applied egg-rr66.6%
Taylor expanded in b around -inf 91.5%
+-commutative91.5%
mul-1-neg91.5%
unsub-neg91.5%
associate-/l*92.8%
associate-*r/92.8%
*-commutative92.8%
associate-*r/92.8%
associate-/r/92.8%
Simplified92.8%
if -5.1999999999999997e-16 < b < 6.8000000000000001e-89Initial program 82.2%
Taylor expanded in b around 0 69.1%
if 6.8000000000000001e-89 < b Initial program 15.5%
Taylor expanded in b around inf 84.7%
associate-*r/84.7%
Simplified84.7%
Final simplification82.8%
(FPCore (a b c)
:precision binary64
(if (<= b -2e-14)
(/ (- (- (* a (* c (/ 1.5 b))) b) b) (* a 3.0))
(if (<= b 3.7e-85)
(/ (- (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 <= -2e-14) {
tmp = (((a * (c * (1.5 / b))) - b) - b) / (a * 3.0);
} else if (b <= 3.7e-85) {
tmp = (sqrt((a * (c * -3.0))) - b) / (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 <= (-2d-14)) then
tmp = (((a * (c * (1.5d0 / b))) - b) - b) / (a * 3.0d0)
else if (b <= 3.7d-85) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (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 <= -2e-14) {
tmp = (((a * (c * (1.5 / b))) - b) - b) / (a * 3.0);
} else if (b <= 3.7e-85) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-14: tmp = (((a * (c * (1.5 / b))) - b) - b) / (a * 3.0) elif b <= 3.7e-85: tmp = (math.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 <= -2e-14) tmp = Float64(Float64(Float64(Float64(a * Float64(c * Float64(1.5 / b))) - b) - b) / Float64(a * 3.0)); elseif (b <= 3.7e-85) 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
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-14) tmp = (((a * (c * (1.5 / b))) - b) - b) / (a * 3.0); elseif (b <= 3.7e-85) tmp = (sqrt((a * (c * -3.0))) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-14], N[(N[(N[(N[(a * N[(c * N[(1.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.7e-85], 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 -2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\left(a \cdot \left(c \cdot \frac{1.5}{b}\right) - b\right) - b}{a \cdot 3}\\
\mathbf{elif}\;b \leq 3.7 \cdot 10^{-85}:\\
\;\;\;\;\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 < -2e-14Initial program 66.7%
fma-neg66.7%
associate-*l*66.7%
distribute-lft-neg-in66.7%
metadata-eval66.7%
*-commutative66.7%
associate-*r*66.7%
add-cube-cbrt66.6%
pow366.6%
*-commutative66.6%
associate-*r*66.6%
metadata-eval66.6%
distribute-rgt-neg-in66.6%
*-commutative66.6%
*-commutative66.6%
*-commutative66.6%
distribute-rgt-neg-in66.6%
metadata-eval66.6%
Applied egg-rr66.6%
Taylor expanded in b around -inf 91.5%
+-commutative91.5%
mul-1-neg91.5%
unsub-neg91.5%
associate-/l*92.8%
associate-*r/92.8%
*-commutative92.8%
associate-*r/92.8%
associate-/r/92.8%
Simplified92.8%
if -2e-14 < b < 3.69999999999999983e-85Initial program 82.2%
Taylor expanded in b around 0 69.1%
*-commutative69.1%
associate-*l*69.2%
Simplified69.2%
if 3.69999999999999983e-85 < b Initial program 15.5%
Taylor expanded in b around inf 84.7%
associate-*r/84.7%
Simplified84.7%
Final simplification82.8%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (- (- (* a (* c (/ 1.5 b))) b) b) (* a 3.0)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (((a * (c * (1.5 / b))) - b) - b) / (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 <= (-5d-310)) then
tmp = (((a * (c * (1.5d0 / b))) - b) - b) / (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 <= -5e-310) {
tmp = (((a * (c * (1.5 / b))) - b) - b) / (a * 3.0);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (((a * (c * (1.5 / b))) - b) - b) / (a * 3.0) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(Float64(Float64(a * Float64(c * Float64(1.5 / b))) - b) - b) / 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 <= -5e-310) tmp = (((a * (c * (1.5 / b))) - b) - b) / (a * 3.0); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(N[(N[(a * N[(c * N[(1.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $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 \cdot 10^{-310}:\\
\;\;\;\;\frac{\left(a \cdot \left(c \cdot \frac{1.5}{b}\right) - b\right) - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.3%
fma-neg74.3%
associate-*l*74.3%
distribute-lft-neg-in74.3%
metadata-eval74.3%
*-commutative74.3%
associate-*r*74.3%
add-cube-cbrt74.1%
pow374.1%
*-commutative74.1%
associate-*r*74.1%
metadata-eval74.1%
distribute-rgt-neg-in74.1%
*-commutative74.1%
*-commutative74.1%
*-commutative74.1%
distribute-rgt-neg-in74.1%
metadata-eval74.1%
Applied egg-rr74.1%
Taylor expanded in b around -inf 69.4%
+-commutative69.4%
mul-1-neg69.4%
unsub-neg69.4%
associate-/l*70.3%
associate-*r/70.3%
*-commutative70.3%
associate-*r/70.3%
associate-/r/70.3%
Simplified70.3%
if -4.999999999999985e-310 < b Initial program 27.8%
Taylor expanded in b around inf 69.8%
associate-*r/69.8%
Simplified69.8%
Final simplification70.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / 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 <= (-5d-310)) then
tmp = ((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / 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 <= -5e-310) {
tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b));
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = (-0.6666666666666666 * (b / a)) + (0.5 * (c / b)); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.3%
Taylor expanded in b around -inf 70.2%
if -4.999999999999985e-310 < b Initial program 27.8%
Taylor expanded in b around inf 69.8%
associate-*r/69.8%
Simplified69.8%
Final simplification70.1%
(FPCore (a b c) :precision binary64 (if (<= b 9e-278) (* b (/ -0.6666666666666666 a)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= 9e-278) {
tmp = b * (-0.6666666666666666 / a);
} 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 <= 9d-278) then
tmp = b * ((-0.6666666666666666d0) / a)
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 <= 9e-278) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 9e-278: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 9e-278) tmp = Float64(b * Float64(-0.6666666666666666 / a)); else tmp = Float64(-0.5 / Float64(b / c)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 9e-278) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 9e-278], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9 \cdot 10^{-278}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < 8.9999999999999996e-278Initial program 73.3%
Taylor expanded in b around -inf 68.7%
*-commutative68.7%
Simplified68.7%
associate-*l/68.8%
clear-num68.7%
Applied egg-rr68.7%
Taylor expanded in a around 0 68.7%
associate-*r/68.8%
*-commutative68.8%
associate-*r/68.8%
Simplified68.8%
if 8.9999999999999996e-278 < b Initial program 28.2%
Taylor expanded in b around inf 71.0%
associate-*r/71.0%
associate-/l*69.7%
Simplified69.7%
Final simplification69.2%
(FPCore (a b c) :precision binary64 (if (<= b 9e-278) (/ b (* a -1.5)) (/ -0.5 (/ b c))))
double code(double a, double b, double c) {
double tmp;
if (b <= 9e-278) {
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 <= 9d-278) 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 <= 9e-278) {
tmp = b / (a * -1.5);
} else {
tmp = -0.5 / (b / c);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 9e-278: tmp = b / (a * -1.5) else: tmp = -0.5 / (b / c) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 9e-278) 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 <= 9e-278) tmp = b / (a * -1.5); else tmp = -0.5 / (b / c); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 9e-278], 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 9 \cdot 10^{-278}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{\frac{b}{c}}\\
\end{array}
\end{array}
if b < 8.9999999999999996e-278Initial program 73.3%
Taylor expanded in b around -inf 68.7%
*-commutative68.7%
Simplified68.7%
associate-*l/68.8%
clear-num68.7%
Applied egg-rr68.7%
Taylor expanded in a around 0 68.7%
associate-*r/68.8%
*-commutative68.8%
associate-*r/68.8%
Simplified68.8%
clear-num68.7%
un-div-inv68.7%
div-inv68.8%
metadata-eval68.8%
Applied egg-rr68.8%
if 8.9999999999999996e-278 < b Initial program 28.2%
Taylor expanded in b around inf 71.0%
associate-*r/71.0%
associate-/l*69.7%
Simplified69.7%
Final simplification69.2%
(FPCore (a b c) :precision binary64 (if (<= b 9e-278) (/ b (* a -1.5)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 9e-278) {
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 <= 9d-278) 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 <= 9e-278) {
tmp = b / (a * -1.5);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 9e-278: tmp = b / (a * -1.5) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 9e-278) 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 <= 9e-278) tmp = b / (a * -1.5); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 9e-278], 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 9 \cdot 10^{-278}:\\
\;\;\;\;\frac{b}{a \cdot -1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 8.9999999999999996e-278Initial program 73.3%
Taylor expanded in b around -inf 68.7%
*-commutative68.7%
Simplified68.7%
associate-*l/68.8%
clear-num68.7%
Applied egg-rr68.7%
Taylor expanded in a around 0 68.7%
associate-*r/68.8%
*-commutative68.8%
associate-*r/68.8%
Simplified68.8%
clear-num68.7%
un-div-inv68.7%
div-inv68.8%
metadata-eval68.8%
Applied egg-rr68.8%
if 8.9999999999999996e-278 < b Initial program 28.2%
Taylor expanded in b around inf 71.0%
associate-*r/71.0%
Simplified71.0%
Final simplification69.8%
(FPCore (a b c) :precision binary64 (if (<= b 9e-278) (/ (* b -0.6666666666666666) a) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 9e-278) {
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 <= 9d-278) 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 <= 9e-278) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 9e-278: tmp = (b * -0.6666666666666666) / a else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 9e-278) tmp = Float64(Float64(b * -0.6666666666666666) / a); else tmp = Float64(Float64(c * -0.5) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 9e-278) tmp = (b * -0.6666666666666666) / a; else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 9e-278], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9 \cdot 10^{-278}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 8.9999999999999996e-278Initial program 73.3%
fma-neg73.3%
associate-*l*73.3%
distribute-lft-neg-in73.3%
metadata-eval73.3%
*-commutative73.3%
associate-*r*73.3%
add-cube-cbrt73.1%
pow373.0%
*-commutative73.0%
associate-*r*73.0%
metadata-eval73.0%
distribute-rgt-neg-in73.0%
*-commutative73.0%
*-commutative73.0%
*-commutative73.0%
distribute-rgt-neg-in73.0%
metadata-eval73.0%
Applied egg-rr73.0%
Taylor expanded in b around -inf 68.7%
associate-*r/68.8%
*-commutative68.8%
Simplified68.8%
if 8.9999999999999996e-278 < b Initial program 28.2%
Taylor expanded in b around inf 71.0%
associate-*r/71.0%
Simplified71.0%
Final simplification69.8%
(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 52.5%
Taylor expanded in b around -inf 38.3%
*-commutative38.3%
Simplified38.3%
associate-*l/38.3%
clear-num38.2%
Applied egg-rr38.2%
Taylor expanded in a around 0 38.3%
associate-*r/38.3%
*-commutative38.3%
associate-*r/38.3%
Simplified38.3%
Final simplification38.3%
herbie shell --seed 2024020
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))