
(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 12 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 (* (* c (pow a 2.0)) -0.375))
(t_1 (* (* 3.0 a) c))
(t_2 (- (pow b 2.0) t_1)))
(if (<= (/ (- (sqrt (- (* b b) t_1)) b) (* 3.0 a)) -283.0)
(/ (/ (- t_2 (pow (- b) 2.0)) (+ b (sqrt t_2))) (* 3.0 a))
(/
1.0
(*
b
(-
(fma
-3.0
(/
(fma
-0.75
(* (* a c) t_0)
(fma
-0.2222222222222222
(/ (* (* (pow a 4.0) (pow c 4.0)) 6.328125) (* a (pow c 2.0)))
(* 0.5625 (* (pow c 2.0) (pow a 3.0)))))
(pow b 6.0))
(fma -3.0 (/ t_0 (pow b 4.0)) (/ (* a 1.5) (pow b 2.0))))
(/ 2.0 c)))))))
double code(double a, double b, double c) {
double t_0 = (c * pow(a, 2.0)) * -0.375;
double t_1 = (3.0 * a) * c;
double t_2 = pow(b, 2.0) - t_1;
double tmp;
if (((sqrt(((b * b) - t_1)) - b) / (3.0 * a)) <= -283.0) {
tmp = ((t_2 - pow(-b, 2.0)) / (b + sqrt(t_2))) / (3.0 * a);
} else {
tmp = 1.0 / (b * (fma(-3.0, (fma(-0.75, ((a * c) * t_0), fma(-0.2222222222222222, (((pow(a, 4.0) * pow(c, 4.0)) * 6.328125) / (a * pow(c, 2.0))), (0.5625 * (pow(c, 2.0) * pow(a, 3.0))))) / pow(b, 6.0)), fma(-3.0, (t_0 / pow(b, 4.0)), ((a * 1.5) / pow(b, 2.0)))) - (2.0 / c)));
}
return tmp;
}
function code(a, b, c) t_0 = Float64(Float64(c * (a ^ 2.0)) * -0.375) t_1 = Float64(Float64(3.0 * a) * c) t_2 = Float64((b ^ 2.0) - t_1) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - t_1)) - b) / Float64(3.0 * a)) <= -283.0) tmp = Float64(Float64(Float64(t_2 - (Float64(-b) ^ 2.0)) / Float64(b + sqrt(t_2))) / Float64(3.0 * a)); else tmp = Float64(1.0 / Float64(b * Float64(fma(-3.0, Float64(fma(-0.75, Float64(Float64(a * c) * t_0), fma(-0.2222222222222222, Float64(Float64(Float64((a ^ 4.0) * (c ^ 4.0)) * 6.328125) / Float64(a * (c ^ 2.0))), Float64(0.5625 * Float64((c ^ 2.0) * (a ^ 3.0))))) / (b ^ 6.0)), fma(-3.0, Float64(t_0 / (b ^ 4.0)), Float64(Float64(a * 1.5) / (b ^ 2.0)))) - Float64(2.0 / c)))); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]}, Block[{t$95$1 = N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[b, 2.0], $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -283.0], N[(N[(N[(t$95$2 - N[Power[(-b), 2.0], $MachinePrecision]), $MachinePrecision] / N[(b + N[Sqrt[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(N[(-3.0 * N[(N[(-0.75 * N[(N[(a * c), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-0.2222222222222222 * N[(N[(N[(N[Power[a, 4.0], $MachinePrecision] * N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision] * 6.328125), $MachinePrecision] / N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5625 * N[(N[Power[c, 2.0], $MachinePrecision] * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[b, 6.0], $MachinePrecision]), $MachinePrecision] + N[(-3.0 * N[(t$95$0 / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(a * 1.5), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(c \cdot {a}^{2}\right) \cdot -0.375\\
t_1 := \left(3 \cdot a\right) \cdot c\\
t_2 := {b}^{2} - t\_1\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - t\_1} - b}{3 \cdot a} \leq -283:\\
\;\;\;\;\frac{\frac{t\_2 - {\left(-b\right)}^{2}}{b + \sqrt{t\_2}}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(\mathsf{fma}\left(-3, \frac{\mathsf{fma}\left(-0.75, \left(a \cdot c\right) \cdot t\_0, \mathsf{fma}\left(-0.2222222222222222, \frac{\left({a}^{4} \cdot {c}^{4}\right) \cdot 6.328125}{a \cdot {c}^{2}}, 0.5625 \cdot \left({c}^{2} \cdot {a}^{3}\right)\right)\right)}{{b}^{6}}, \mathsf{fma}\left(-3, \frac{t\_0}{{b}^{4}}, \frac{a \cdot 1.5}{{b}^{2}}\right)\right) - \frac{2}{c}\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -283Initial program 92.2%
add-cbrt-cube90.4%
pow1/388.6%
pow388.6%
pow288.6%
pow-pow88.5%
metadata-eval88.5%
Applied egg-rr88.5%
unpow1/391.0%
Simplified91.0%
flip-+91.0%
pow291.0%
add-sqr-sqrt91.0%
pow1/389.1%
pow-pow93.1%
metadata-eval93.1%
*-commutative93.1%
pow1/392.4%
pow-pow92.9%
metadata-eval92.9%
*-commutative92.9%
Applied egg-rr92.9%
if -283 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 50.7%
add-cbrt-cube50.7%
pow350.7%
Applied egg-rr50.7%
rem-cbrt-cube50.7%
clear-num50.7%
inv-pow50.7%
*-commutative50.7%
neg-mul-150.7%
fma-define50.7%
pow250.7%
*-commutative50.7%
*-commutative50.7%
Applied egg-rr50.7%
unpow-150.7%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in b around inf 93.0%
Simplified93.0%
Final simplification93.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* (* 3.0 a) c)) (t_1 (- (pow b 2.0) t_0)))
(if (<= (/ (- (sqrt (- (* b b) t_0)) b) (* 3.0 a)) -283.0)
(/ (/ (- t_1 (pow (- b) 2.0)) (+ b (sqrt t_1))) (* 3.0 a))
(+
(* -0.5 (/ c b))
(*
a
(+
(* -0.375 (/ (pow c 2.0) (pow b 3.0)))
(*
a
(+
(* -0.5625 (/ (pow c 3.0) (pow b 5.0)))
(* -1.0546875 (/ (* a (pow c 4.0)) (pow b 7.0)))))))))))
double code(double a, double b, double c) {
double t_0 = (3.0 * a) * c;
double t_1 = pow(b, 2.0) - t_0;
double tmp;
if (((sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -283.0) {
tmp = ((t_1 - pow(-b, 2.0)) / (b + sqrt(t_1))) / (3.0 * a);
} else {
tmp = (-0.5 * (c / b)) + (a * ((-0.375 * (pow(c, 2.0) / pow(b, 3.0))) + (a * ((-0.5625 * (pow(c, 3.0) / pow(b, 5.0))) + (-1.0546875 * ((a * pow(c, 4.0)) / pow(b, 7.0)))))));
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (3.0d0 * a) * c
t_1 = (b ** 2.0d0) - t_0
if (((sqrt(((b * b) - t_0)) - b) / (3.0d0 * a)) <= (-283.0d0)) then
tmp = ((t_1 - (-b ** 2.0d0)) / (b + sqrt(t_1))) / (3.0d0 * a)
else
tmp = ((-0.5d0) * (c / b)) + (a * (((-0.375d0) * ((c ** 2.0d0) / (b ** 3.0d0))) + (a * (((-0.5625d0) * ((c ** 3.0d0) / (b ** 5.0d0))) + ((-1.0546875d0) * ((a * (c ** 4.0d0)) / (b ** 7.0d0)))))))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (3.0 * a) * c;
double t_1 = Math.pow(b, 2.0) - t_0;
double tmp;
if (((Math.sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -283.0) {
tmp = ((t_1 - Math.pow(-b, 2.0)) / (b + Math.sqrt(t_1))) / (3.0 * a);
} else {
tmp = (-0.5 * (c / b)) + (a * ((-0.375 * (Math.pow(c, 2.0) / Math.pow(b, 3.0))) + (a * ((-0.5625 * (Math.pow(c, 3.0) / Math.pow(b, 5.0))) + (-1.0546875 * ((a * Math.pow(c, 4.0)) / Math.pow(b, 7.0)))))));
}
return tmp;
}
def code(a, b, c): t_0 = (3.0 * a) * c t_1 = math.pow(b, 2.0) - t_0 tmp = 0 if ((math.sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -283.0: tmp = ((t_1 - math.pow(-b, 2.0)) / (b + math.sqrt(t_1))) / (3.0 * a) else: tmp = (-0.5 * (c / b)) + (a * ((-0.375 * (math.pow(c, 2.0) / math.pow(b, 3.0))) + (a * ((-0.5625 * (math.pow(c, 3.0) / math.pow(b, 5.0))) + (-1.0546875 * ((a * math.pow(c, 4.0)) / math.pow(b, 7.0))))))) return tmp
function code(a, b, c) t_0 = Float64(Float64(3.0 * a) * c) t_1 = Float64((b ^ 2.0) - t_0) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - t_0)) - b) / Float64(3.0 * a)) <= -283.0) tmp = Float64(Float64(Float64(t_1 - (Float64(-b) ^ 2.0)) / Float64(b + sqrt(t_1))) / Float64(3.0 * a)); else tmp = Float64(Float64(-0.5 * Float64(c / b)) + Float64(a * Float64(Float64(-0.375 * Float64((c ^ 2.0) / (b ^ 3.0))) + Float64(a * Float64(Float64(-0.5625 * Float64((c ^ 3.0) / (b ^ 5.0))) + Float64(-1.0546875 * Float64(Float64(a * (c ^ 4.0)) / (b ^ 7.0)))))))); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (3.0 * a) * c; t_1 = (b ^ 2.0) - t_0; tmp = 0.0; if (((sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -283.0) tmp = ((t_1 - (-b ^ 2.0)) / (b + sqrt(t_1))) / (3.0 * a); else tmp = (-0.5 * (c / b)) + (a * ((-0.375 * ((c ^ 2.0) / (b ^ 3.0))) + (a * ((-0.5625 * ((c ^ 3.0) / (b ^ 5.0))) + (-1.0546875 * ((a * (c ^ 4.0)) / (b ^ 7.0))))))); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[b, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -283.0], N[(N[(N[(t$95$1 - N[Power[(-b), 2.0], $MachinePrecision]), $MachinePrecision] / N[(b + N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(-0.375 * N[(N[Power[c, 2.0], $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(-0.5625 * N[(N[Power[c, 3.0], $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0546875 * N[(N[(a * N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(3 \cdot a\right) \cdot c\\
t_1 := {b}^{2} - t\_0\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - t\_0} - b}{3 \cdot a} \leq -283:\\
\;\;\;\;\frac{\frac{t\_1 - {\left(-b\right)}^{2}}{b + \sqrt{t\_1}}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b} + a \cdot \left(-0.375 \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}} + -1.0546875 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right)\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -283Initial program 92.2%
add-cbrt-cube90.4%
pow1/388.6%
pow388.6%
pow288.6%
pow-pow88.5%
metadata-eval88.5%
Applied egg-rr88.5%
unpow1/391.0%
Simplified91.0%
flip-+91.0%
pow291.0%
add-sqr-sqrt91.0%
pow1/389.1%
pow-pow93.1%
metadata-eval93.1%
*-commutative93.1%
pow1/392.4%
pow-pow92.9%
metadata-eval92.9%
*-commutative92.9%
Applied egg-rr92.9%
if -283 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 50.7%
Simplified50.7%
Taylor expanded in a around 0 92.8%
Taylor expanded in c around 0 92.8%
Final simplification92.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* (* 3.0 a) c)) (t_1 (- (pow b 2.0) t_0)))
(if (<= (/ (- (sqrt (- (* b b) t_0)) b) (* 3.0 a)) -283.0)
(/ (/ (- t_1 (pow (- b) 2.0)) (+ b (sqrt t_1))) (* 3.0 a))
(/
1.0
(*
b
(-
(fma
-3.0
(/ (* (* c (pow a 2.0)) -0.375) (pow b 4.0))
(/ (* a 1.5) (pow b 2.0)))
(/ 2.0 c)))))))
double code(double a, double b, double c) {
double t_0 = (3.0 * a) * c;
double t_1 = pow(b, 2.0) - t_0;
double tmp;
if (((sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -283.0) {
tmp = ((t_1 - pow(-b, 2.0)) / (b + sqrt(t_1))) / (3.0 * a);
} else {
tmp = 1.0 / (b * (fma(-3.0, (((c * pow(a, 2.0)) * -0.375) / pow(b, 4.0)), ((a * 1.5) / pow(b, 2.0))) - (2.0 / c)));
}
return tmp;
}
function code(a, b, c) t_0 = Float64(Float64(3.0 * a) * c) t_1 = Float64((b ^ 2.0) - t_0) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - t_0)) - b) / Float64(3.0 * a)) <= -283.0) tmp = Float64(Float64(Float64(t_1 - (Float64(-b) ^ 2.0)) / Float64(b + sqrt(t_1))) / Float64(3.0 * a)); else tmp = Float64(1.0 / Float64(b * Float64(fma(-3.0, Float64(Float64(Float64(c * (a ^ 2.0)) * -0.375) / (b ^ 4.0)), Float64(Float64(a * 1.5) / (b ^ 2.0))) - Float64(2.0 / c)))); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[b, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -283.0], N[(N[(N[(t$95$1 - N[Power[(-b), 2.0], $MachinePrecision]), $MachinePrecision] / N[(b + N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(N[(-3.0 * N[(N[(N[(c * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(a * 1.5), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(3 \cdot a\right) \cdot c\\
t_1 := {b}^{2} - t\_0\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - t\_0} - b}{3 \cdot a} \leq -283:\\
\;\;\;\;\frac{\frac{t\_1 - {\left(-b\right)}^{2}}{b + \sqrt{t\_1}}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(\mathsf{fma}\left(-3, \frac{\left(c \cdot {a}^{2}\right) \cdot -0.375}{{b}^{4}}, \frac{a \cdot 1.5}{{b}^{2}}\right) - \frac{2}{c}\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -283Initial program 92.2%
add-cbrt-cube90.4%
pow1/388.6%
pow388.6%
pow288.6%
pow-pow88.5%
metadata-eval88.5%
Applied egg-rr88.5%
unpow1/391.0%
Simplified91.0%
flip-+91.0%
pow291.0%
add-sqr-sqrt91.0%
pow1/389.1%
pow-pow93.1%
metadata-eval93.1%
*-commutative93.1%
pow1/392.4%
pow-pow92.9%
metadata-eval92.9%
*-commutative92.9%
Applied egg-rr92.9%
if -283 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 50.7%
add-cbrt-cube50.7%
pow350.7%
Applied egg-rr50.7%
rem-cbrt-cube50.7%
clear-num50.7%
inv-pow50.7%
*-commutative50.7%
neg-mul-150.7%
fma-define50.7%
pow250.7%
*-commutative50.7%
*-commutative50.7%
Applied egg-rr50.7%
unpow-150.7%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in b around inf 90.7%
fma-define90.7%
distribute-rgt-out90.7%
*-commutative90.7%
metadata-eval90.7%
associate-*r/90.7%
*-commutative90.7%
associate-*r/90.7%
metadata-eval90.7%
Simplified90.7%
Final simplification90.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (cbrt (* 3.0 a))) (t_1 (- (sqrt (- (* b b) (* (* 3.0 a) c))) b)))
(if (<= (/ t_1 (* 3.0 a)) -283.0)
(/ t_1 (* t_0 (pow t_0 2.0)))
(/
1.0
(*
b
(-
(fma
-3.0
(/ (* (* c (pow a 2.0)) -0.375) (pow b 4.0))
(/ (* a 1.5) (pow b 2.0)))
(/ 2.0 c)))))))
double code(double a, double b, double c) {
double t_0 = cbrt((3.0 * a));
double t_1 = sqrt(((b * b) - ((3.0 * a) * c))) - b;
double tmp;
if ((t_1 / (3.0 * a)) <= -283.0) {
tmp = t_1 / (t_0 * pow(t_0, 2.0));
} else {
tmp = 1.0 / (b * (fma(-3.0, (((c * pow(a, 2.0)) * -0.375) / pow(b, 4.0)), ((a * 1.5) / pow(b, 2.0))) - (2.0 / c)));
}
return tmp;
}
function code(a, b, c) t_0 = cbrt(Float64(3.0 * a)) t_1 = Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) tmp = 0.0 if (Float64(t_1 / Float64(3.0 * a)) <= -283.0) tmp = Float64(t_1 / Float64(t_0 * (t_0 ^ 2.0))); else tmp = Float64(1.0 / Float64(b * Float64(fma(-3.0, Float64(Float64(Float64(c * (a ^ 2.0)) * -0.375) / (b ^ 4.0)), Float64(Float64(a * 1.5) / (b ^ 2.0))) - Float64(2.0 / c)))); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[Power[N[(3.0 * a), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -283.0], N[(t$95$1 / N[(t$95$0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(N[(-3.0 * N[(N[(N[(c * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(a * 1.5), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{3 \cdot a}\\
t_1 := \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b\\
\mathbf{if}\;\frac{t\_1}{3 \cdot a} \leq -283:\\
\;\;\;\;\frac{t\_1}{t\_0 \cdot {t\_0}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(\mathsf{fma}\left(-3, \frac{\left(c \cdot {a}^{2}\right) \cdot -0.375}{{b}^{4}}, \frac{a \cdot 1.5}{{b}^{2}}\right) - \frac{2}{c}\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -283Initial program 92.2%
add-cbrt-cube92.0%
pow391.9%
Applied egg-rr91.9%
rem-cbrt-cube92.2%
add-cube-cbrt92.5%
pow292.5%
*-commutative92.5%
*-commutative92.5%
Applied egg-rr92.5%
if -283 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 50.7%
add-cbrt-cube50.7%
pow350.7%
Applied egg-rr50.7%
rem-cbrt-cube50.7%
clear-num50.7%
inv-pow50.7%
*-commutative50.7%
neg-mul-150.7%
fma-define50.7%
pow250.7%
*-commutative50.7%
*-commutative50.7%
Applied egg-rr50.7%
unpow-150.7%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in b around inf 90.7%
fma-define90.7%
distribute-rgt-out90.7%
*-commutative90.7%
metadata-eval90.7%
associate-*r/90.7%
*-commutative90.7%
associate-*r/90.7%
metadata-eval90.7%
Simplified90.7%
Final simplification90.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (cbrt (* 3.0 a))) (t_1 (- (sqrt (- (* b b) (* (* 3.0 a) c))) b)))
(if (<= (/ t_1 (* 3.0 a)) -283.0)
(/ t_1 (* t_0 (pow t_0 2.0)))
(/
-1.0
(*
a
(*
b
(+
(/ 2.0 (* a c))
(- (/ (* (* a c) -1.125) (pow b 4.0)) (/ 1.5 (pow b 2.0))))))))))
double code(double a, double b, double c) {
double t_0 = cbrt((3.0 * a));
double t_1 = sqrt(((b * b) - ((3.0 * a) * c))) - b;
double tmp;
if ((t_1 / (3.0 * a)) <= -283.0) {
tmp = t_1 / (t_0 * pow(t_0, 2.0));
} else {
tmp = -1.0 / (a * (b * ((2.0 / (a * c)) + ((((a * c) * -1.125) / pow(b, 4.0)) - (1.5 / pow(b, 2.0))))));
}
return tmp;
}
public static double code(double a, double b, double c) {
double t_0 = Math.cbrt((3.0 * a));
double t_1 = Math.sqrt(((b * b) - ((3.0 * a) * c))) - b;
double tmp;
if ((t_1 / (3.0 * a)) <= -283.0) {
tmp = t_1 / (t_0 * Math.pow(t_0, 2.0));
} else {
tmp = -1.0 / (a * (b * ((2.0 / (a * c)) + ((((a * c) * -1.125) / Math.pow(b, 4.0)) - (1.5 / Math.pow(b, 2.0))))));
}
return tmp;
}
function code(a, b, c) t_0 = cbrt(Float64(3.0 * a)) t_1 = Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) tmp = 0.0 if (Float64(t_1 / Float64(3.0 * a)) <= -283.0) tmp = Float64(t_1 / Float64(t_0 * (t_0 ^ 2.0))); else tmp = Float64(-1.0 / Float64(a * Float64(b * Float64(Float64(2.0 / Float64(a * c)) + Float64(Float64(Float64(Float64(a * c) * -1.125) / (b ^ 4.0)) - Float64(1.5 / (b ^ 2.0))))))); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[Power[N[(3.0 * a), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -283.0], N[(t$95$1 / N[(t$95$0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(a * N[(b * N[(N[(2.0 / N[(a * c), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(a * c), $MachinePrecision] * -1.125), $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] - N[(1.5 / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{3 \cdot a}\\
t_1 := \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b\\
\mathbf{if}\;\frac{t\_1}{3 \cdot a} \leq -283:\\
\;\;\;\;\frac{t\_1}{t\_0 \cdot {t\_0}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{a \cdot \left(b \cdot \left(\frac{2}{a \cdot c} + \left(\frac{\left(a \cdot c\right) \cdot -1.125}{{b}^{4}} - \frac{1.5}{{b}^{2}}\right)\right)\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -283Initial program 92.2%
add-cbrt-cube92.0%
pow391.9%
Applied egg-rr91.9%
rem-cbrt-cube92.2%
add-cube-cbrt92.5%
pow292.5%
*-commutative92.5%
*-commutative92.5%
Applied egg-rr92.5%
if -283 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 50.7%
add-cbrt-cube50.7%
pow350.7%
Applied egg-rr50.7%
rem-cbrt-cube50.7%
clear-num50.7%
inv-pow50.7%
*-commutative50.7%
neg-mul-150.7%
fma-define50.7%
pow250.7%
*-commutative50.7%
*-commutative50.7%
Applied egg-rr50.7%
unpow-150.7%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in b around inf 90.5%
+-commutative90.5%
mul-1-neg90.5%
unsub-neg90.5%
associate-*r/90.5%
metadata-eval90.5%
distribute-rgt-out90.5%
*-commutative90.5%
metadata-eval90.5%
associate-*r/90.5%
metadata-eval90.5%
*-commutative90.5%
Simplified90.5%
Final simplification90.7%
(FPCore (a b c)
:precision binary64
(if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -283.0)
(/ (- (sqrt (fma b b (* (* 3.0 a) (- c)))) b) (* 3.0 a))
(/
-1.0
(*
a
(*
b
(+
(/ 2.0 (* a c))
(- (/ (* (* a c) -1.125) (pow b 4.0)) (/ 1.5 (pow b 2.0)))))))))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -283.0) {
tmp = (sqrt(fma(b, b, ((3.0 * a) * -c))) - b) / (3.0 * a);
} else {
tmp = -1.0 / (a * (b * ((2.0 / (a * c)) + ((((a * c) * -1.125) / pow(b, 4.0)) - (1.5 / pow(b, 2.0))))));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -283.0) tmp = Float64(Float64(sqrt(fma(b, b, Float64(Float64(3.0 * a) * Float64(-c)))) - b) / Float64(3.0 * a)); else tmp = Float64(-1.0 / Float64(a * Float64(b * Float64(Float64(2.0 / Float64(a * c)) + Float64(Float64(Float64(Float64(a * c) * -1.125) / (b ^ 4.0)) - Float64(1.5 / (b ^ 2.0))))))); end return tmp end
code[a_, b_, c_] := If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -283.0], N[(N[(N[Sqrt[N[(b * b + N[(N[(3.0 * a), $MachinePrecision] * (-c)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(a * N[(b * N[(N[(2.0 / N[(a * c), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(a * c), $MachinePrecision] * -1.125), $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] - N[(1.5 / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -283:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot \left(-c\right)\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{a \cdot \left(b \cdot \left(\frac{2}{a \cdot c} + \left(\frac{\left(a \cdot c\right) \cdot -1.125}{{b}^{4}} - \frac{1.5}{{b}^{2}}\right)\right)\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -283Initial program 92.2%
add-cbrt-cube90.4%
pow1/388.6%
pow388.6%
pow288.6%
pow-pow88.5%
metadata-eval88.5%
Applied egg-rr88.5%
unpow1/391.0%
Simplified91.0%
pow1/388.5%
pow-pow92.2%
metadata-eval92.2%
pow292.2%
cancel-sign-sub-inv92.2%
fma-define92.4%
Applied egg-rr92.4%
if -283 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 50.7%
add-cbrt-cube50.7%
pow350.7%
Applied egg-rr50.7%
rem-cbrt-cube50.7%
clear-num50.7%
inv-pow50.7%
*-commutative50.7%
neg-mul-150.7%
fma-define50.7%
pow250.7%
*-commutative50.7%
*-commutative50.7%
Applied egg-rr50.7%
unpow-150.7%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in b around inf 90.5%
+-commutative90.5%
mul-1-neg90.5%
unsub-neg90.5%
associate-*r/90.5%
metadata-eval90.5%
distribute-rgt-out90.5%
*-commutative90.5%
metadata-eval90.5%
associate-*r/90.5%
metadata-eval90.5%
*-commutative90.5%
Simplified90.5%
Final simplification90.7%
(FPCore (a b c) :precision binary64 (if (<= b 36.0) (/ (- (sqrt (fma b b (* (* 3.0 a) (- c)))) b) (* 3.0 a)) (/ 1.0 (* b (- (/ (* a 1.5) (pow b 2.0)) (/ 2.0 c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= 36.0) {
tmp = (sqrt(fma(b, b, ((3.0 * a) * -c))) - b) / (3.0 * a);
} else {
tmp = 1.0 / (b * (((a * 1.5) / pow(b, 2.0)) - (2.0 / c)));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 36.0) tmp = Float64(Float64(sqrt(fma(b, b, Float64(Float64(3.0 * a) * Float64(-c)))) - b) / Float64(3.0 * a)); else tmp = Float64(1.0 / Float64(b * Float64(Float64(Float64(a * 1.5) / (b ^ 2.0)) - Float64(2.0 / c)))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 36.0], N[(N[(N[Sqrt[N[(b * b + N[(N[(3.0 * a), $MachinePrecision] * (-c)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(N[(N[(a * 1.5), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 36:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot \left(-c\right)\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(\frac{a \cdot 1.5}{{b}^{2}} - \frac{2}{c}\right)}\\
\end{array}
\end{array}
if b < 36Initial program 78.7%
add-cbrt-cube77.8%
pow1/376.0%
pow376.0%
pow276.0%
pow-pow76.1%
metadata-eval76.1%
Applied egg-rr76.1%
unpow1/378.0%
Simplified78.0%
pow1/376.1%
pow-pow78.7%
metadata-eval78.7%
pow278.7%
cancel-sign-sub-inv78.7%
fma-define78.8%
Applied egg-rr78.8%
if 36 < b Initial program 43.3%
add-cbrt-cube43.3%
pow343.3%
Applied egg-rr43.3%
rem-cbrt-cube43.3%
clear-num43.3%
inv-pow43.3%
*-commutative43.3%
neg-mul-143.3%
fma-define43.3%
pow243.3%
*-commutative43.3%
*-commutative43.3%
Applied egg-rr43.3%
unpow-143.3%
associate-/l*43.3%
Simplified43.3%
Taylor expanded in b around inf 89.6%
associate-*r/89.6%
*-commutative89.6%
associate-*r/89.6%
metadata-eval89.6%
Simplified89.6%
Final simplification86.6%
(FPCore (a b c) :precision binary64 (if (<= b 36.0) (/ (- (sqrt (fma b b (* a (* c -3.0)))) b) (* 3.0 a)) (/ 1.0 (* b (- (/ (* a 1.5) (pow b 2.0)) (/ 2.0 c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= 36.0) {
tmp = (sqrt(fma(b, b, (a * (c * -3.0)))) - b) / (3.0 * a);
} else {
tmp = 1.0 / (b * (((a * 1.5) / pow(b, 2.0)) - (2.0 / c)));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 36.0) tmp = Float64(Float64(sqrt(fma(b, b, Float64(a * Float64(c * -3.0)))) - b) / Float64(3.0 * a)); else tmp = Float64(1.0 / Float64(b * Float64(Float64(Float64(a * 1.5) / (b ^ 2.0)) - Float64(2.0 / c)))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 36.0], N[(N[(N[Sqrt[N[(b * b + N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(N[(N[(a * 1.5), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 36:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(\frac{a \cdot 1.5}{{b}^{2}} - \frac{2}{c}\right)}\\
\end{array}
\end{array}
if b < 36Initial program 78.7%
Simplified78.8%
if 36 < b Initial program 43.3%
add-cbrt-cube43.3%
pow343.3%
Applied egg-rr43.3%
rem-cbrt-cube43.3%
clear-num43.3%
inv-pow43.3%
*-commutative43.3%
neg-mul-143.3%
fma-define43.3%
pow243.3%
*-commutative43.3%
*-commutative43.3%
Applied egg-rr43.3%
unpow-143.3%
associate-/l*43.3%
Simplified43.3%
Taylor expanded in b around inf 89.6%
associate-*r/89.6%
*-commutative89.6%
associate-*r/89.6%
metadata-eval89.6%
Simplified89.6%
(FPCore (a b c) :precision binary64 (if (<= b 36.0) (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) (/ 1.0 (* b (- (/ (* a 1.5) (pow b 2.0)) (/ 2.0 c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= 36.0) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = 1.0 / (b * (((a * 1.5) / pow(b, 2.0)) - (2.0 / 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 <= 36.0d0) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * a)
else
tmp = 1.0d0 / (b * (((a * 1.5d0) / (b ** 2.0d0)) - (2.0d0 / c)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 36.0) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = 1.0 / (b * (((a * 1.5) / Math.pow(b, 2.0)) - (2.0 / c)));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 36.0: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = 1.0 / (b * (((a * 1.5) / math.pow(b, 2.0)) - (2.0 / c))) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 36.0) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(1.0 / Float64(b * Float64(Float64(Float64(a * 1.5) / (b ^ 2.0)) - Float64(2.0 / c)))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 36.0) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = 1.0 / (b * (((a * 1.5) / (b ^ 2.0)) - (2.0 / c))); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 36.0], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(N[(N[(a * 1.5), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 36:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(\frac{a \cdot 1.5}{{b}^{2}} - \frac{2}{c}\right)}\\
\end{array}
\end{array}
if b < 36Initial program 78.7%
if 36 < b Initial program 43.3%
add-cbrt-cube43.3%
pow343.3%
Applied egg-rr43.3%
rem-cbrt-cube43.3%
clear-num43.3%
inv-pow43.3%
*-commutative43.3%
neg-mul-143.3%
fma-define43.3%
pow243.3%
*-commutative43.3%
*-commutative43.3%
Applied egg-rr43.3%
unpow-143.3%
associate-/l*43.3%
Simplified43.3%
Taylor expanded in b around inf 89.6%
associate-*r/89.6%
*-commutative89.6%
associate-*r/89.6%
metadata-eval89.6%
Simplified89.6%
Final simplification86.6%
(FPCore (a b c) :precision binary64 (/ 1.0 (* b (- (/ (* a 1.5) (pow b 2.0)) (/ 2.0 c)))))
double code(double a, double b, double c) {
return 1.0 / (b * (((a * 1.5) / pow(b, 2.0)) - (2.0 / c)));
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 1.0d0 / (b * (((a * 1.5d0) / (b ** 2.0d0)) - (2.0d0 / c)))
end function
public static double code(double a, double b, double c) {
return 1.0 / (b * (((a * 1.5) / Math.pow(b, 2.0)) - (2.0 / c)));
}
def code(a, b, c): return 1.0 / (b * (((a * 1.5) / math.pow(b, 2.0)) - (2.0 / c)))
function code(a, b, c) return Float64(1.0 / Float64(b * Float64(Float64(Float64(a * 1.5) / (b ^ 2.0)) - Float64(2.0 / c)))) end
function tmp = code(a, b, c) tmp = 1.0 / (b * (((a * 1.5) / (b ^ 2.0)) - (2.0 / c))); end
code[a_, b_, c_] := N[(1.0 / N[(b * N[(N[(N[(a * 1.5), $MachinePrecision] / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{b \cdot \left(\frac{a \cdot 1.5}{{b}^{2}} - \frac{2}{c}\right)}
\end{array}
Initial program 53.1%
add-cbrt-cube53.1%
pow353.1%
Applied egg-rr53.1%
rem-cbrt-cube53.1%
clear-num53.1%
inv-pow53.1%
*-commutative53.1%
neg-mul-153.1%
fma-define53.1%
pow253.1%
*-commutative53.1%
*-commutative53.1%
Applied egg-rr53.1%
unpow-153.1%
associate-/l*53.1%
Simplified53.1%
Taylor expanded in b around inf 82.6%
associate-*r/82.6%
*-commutative82.6%
associate-*r/82.6%
metadata-eval82.6%
Simplified82.6%
(FPCore (a b c) :precision binary64 (* c (- (* -0.375 (/ (* a c) (pow b 3.0))) (/ 0.5 b))))
double code(double a, double b, double c) {
return c * ((-0.375 * ((a * c) / pow(b, 3.0))) - (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.375d0) * ((a * c) / (b ** 3.0d0))) - (0.5d0 / b))
end function
public static double code(double a, double b, double c) {
return c * ((-0.375 * ((a * c) / Math.pow(b, 3.0))) - (0.5 / b));
}
def code(a, b, c): return c * ((-0.375 * ((a * c) / math.pow(b, 3.0))) - (0.5 / b))
function code(a, b, c) return Float64(c * Float64(Float64(-0.375 * Float64(Float64(a * c) / (b ^ 3.0))) - Float64(0.5 / b))) end
function tmp = code(a, b, c) tmp = c * ((-0.375 * ((a * c) / (b ^ 3.0))) - (0.5 / b)); end
code[a_, b_, c_] := N[(c * N[(N[(-0.375 * N[(N[(a * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \left(-0.375 \cdot \frac{a \cdot c}{{b}^{3}} - \frac{0.5}{b}\right)
\end{array}
Initial program 53.1%
Simplified53.2%
Taylor expanded in c around 0 82.0%
associate-*r/82.0%
metadata-eval82.0%
Simplified82.0%
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
return -0.5 * (c / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.5d0) * (c / b)
end function
public static double code(double a, double b, double c) {
return -0.5 * (c / b);
}
def code(a, b, c): return -0.5 * (c / b)
function code(a, b, c) return Float64(-0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = -0.5 * (c / b); end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b}
\end{array}
Initial program 53.1%
Simplified53.2%
Taylor expanded in b around inf 66.0%
herbie shell --seed 2024154
(FPCore (a b c)
:name "Cubic critical, narrow range"
:precision binary64
:pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))