
(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 13 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 (/ (fma b -1.0 (sqrt (fma b b (* (* a c) -3.0)))) (* 3.0 a))))
(if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.395)
(* (cbrt t_0) (cbrt (pow t_0 2.0)))
(+
(* -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 = fma(b, -1.0, sqrt(fma(b, b, ((a * c) * -3.0)))) / (3.0 * a);
double tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.395) {
tmp = cbrt(t_0) * cbrt(pow(t_0, 2.0));
} 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;
}
function code(a, b, c) t_0 = Float64(fma(b, -1.0, sqrt(fma(b, b, Float64(Float64(a * c) * -3.0)))) / Float64(3.0 * a)) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.395) tmp = Float64(cbrt(t_0) * cbrt((t_0 ^ 2.0))); 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
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(b * -1.0 + N[Sqrt[N[(b * b + N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]}, 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], -0.395], N[(N[Power[t$95$0, 1/3], $MachinePrecision] * N[Power[N[Power[t$95$0, 2.0], $MachinePrecision], 1/3], $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 := \frac{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -3\right)}\right)}{3 \cdot a}\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.395:\\
\;\;\;\;\sqrt[3]{t\_0} \cdot \sqrt[3]{{t\_0}^{2}}\\
\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)) < -0.39500000000000002Initial program 85.9%
log1p-expm1-u74.8%
log1p-undefine68.9%
Applied egg-rr68.9%
log1p-define74.8%
log1p-expm1-u85.9%
add-cbrt-cube86.0%
cbrt-prod85.9%
Applied egg-rr85.9%
*-commutative85.9%
fma-undefine85.9%
*-commutative85.9%
fma-define85.9%
unpow285.9%
fmm-def86.0%
*-commutative86.0%
distribute-rgt-neg-in86.0%
metadata-eval86.0%
Simplified86.0%
if -0.39500000000000002 < (/.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.2%
Simplified50.4%
Taylor expanded in a around 0 92.8%
Taylor expanded in c around 0 92.8%
Final simplification91.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* 3.0 a) c)))))
(if (<= (/ (- t_0 b) (* 3.0 a)) -0.395)
(/ (- t_0 (/ (pow b 2.0) b)) (* 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 = sqrt(((b * b) - ((3.0 * a) * c)));
double tmp;
if (((t_0 - b) / (3.0 * a)) <= -0.395) {
tmp = (t_0 - (pow(b, 2.0) / b)) / (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) :: tmp
t_0 = sqrt(((b * b) - ((3.0d0 * a) * c)))
if (((t_0 - b) / (3.0d0 * a)) <= (-0.395d0)) then
tmp = (t_0 - ((b ** 2.0d0) / b)) / (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 = Math.sqrt(((b * b) - ((3.0 * a) * c)));
double tmp;
if (((t_0 - b) / (3.0 * a)) <= -0.395) {
tmp = (t_0 - (Math.pow(b, 2.0) / b)) / (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 = math.sqrt(((b * b) - ((3.0 * a) * c))) tmp = 0 if ((t_0 - b) / (3.0 * a)) <= -0.395: tmp = (t_0 - (math.pow(b, 2.0) / b)) / (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 = sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) tmp = 0.0 if (Float64(Float64(t_0 - b) / Float64(3.0 * a)) <= -0.395) tmp = Float64(Float64(t_0 - Float64((b ^ 2.0) / b)) / 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 = sqrt(((b * b) - ((3.0 * a) * c))); tmp = 0.0; if (((t_0 - b) / (3.0 * a)) <= -0.395) tmp = (t_0 - ((b ^ 2.0) / b)) / (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[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -0.395], N[(N[(t$95$0 - N[(N[Power[b, 2.0], $MachinePrecision] / b), $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 := \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\\
\mathbf{if}\;\frac{t\_0 - b}{3 \cdot a} \leq -0.395:\\
\;\;\;\;\frac{t\_0 - \frac{{b}^{2}}{b}}{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)) < -0.39500000000000002Initial program 85.9%
neg-sub085.9%
flip--86.0%
metadata-eval86.0%
pow286.0%
add-sqr-sqrt85.1%
sqrt-prod86.0%
sqr-neg86.0%
sqrt-unprod0.0%
add-sqr-sqrt1.5%
sub-neg1.5%
neg-sub01.5%
add-sqr-sqrt0.0%
sqrt-unprod86.0%
sqr-neg86.0%
sqrt-prod85.1%
add-sqr-sqrt86.0%
Applied egg-rr86.0%
neg-sub086.0%
Simplified86.0%
if -0.39500000000000002 < (/.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.2%
Simplified50.4%
Taylor expanded in a around 0 92.8%
Taylor expanded in c around 0 92.8%
Final simplification91.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* 3.0 a) c)))))
(if (<= (/ (- t_0 b) (* 3.0 a)) -0.395)
(/ (- t_0 (/ (pow b 2.0) b)) (* 3.0 a))
(+
(* -0.5 (/ 1.0 (/ b c)))
(*
a
(+
(*
a
(+
(* -0.5625 (/ (pow c 3.0) (pow b 5.0)))
(* -1.0546875 (/ (* a (pow c 4.0)) (pow b 7.0)))))
(* -0.375 (/ (* c c) (pow b 3.0)))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((3.0 * a) * c)));
double tmp;
if (((t_0 - b) / (3.0 * a)) <= -0.395) {
tmp = (t_0 - (pow(b, 2.0) / b)) / (3.0 * a);
} else {
tmp = (-0.5 * (1.0 / (b / c))) + (a * ((a * ((-0.5625 * (pow(c, 3.0) / pow(b, 5.0))) + (-1.0546875 * ((a * pow(c, 4.0)) / pow(b, 7.0))))) + (-0.375 * ((c * c) / pow(b, 3.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) :: tmp
t_0 = sqrt(((b * b) - ((3.0d0 * a) * c)))
if (((t_0 - b) / (3.0d0 * a)) <= (-0.395d0)) then
tmp = (t_0 - ((b ** 2.0d0) / b)) / (3.0d0 * a)
else
tmp = ((-0.5d0) * (1.0d0 / (b / c))) + (a * ((a * (((-0.5625d0) * ((c ** 3.0d0) / (b ** 5.0d0))) + ((-1.0546875d0) * ((a * (c ** 4.0d0)) / (b ** 7.0d0))))) + ((-0.375d0) * ((c * c) / (b ** 3.0d0)))))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((3.0 * a) * c)));
double tmp;
if (((t_0 - b) / (3.0 * a)) <= -0.395) {
tmp = (t_0 - (Math.pow(b, 2.0) / b)) / (3.0 * a);
} else {
tmp = (-0.5 * (1.0 / (b / c))) + (a * ((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))))) + (-0.375 * ((c * c) / Math.pow(b, 3.0)))));
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((3.0 * a) * c))) tmp = 0 if ((t_0 - b) / (3.0 * a)) <= -0.395: tmp = (t_0 - (math.pow(b, 2.0) / b)) / (3.0 * a) else: tmp = (-0.5 * (1.0 / (b / c))) + (a * ((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))))) + (-0.375 * ((c * c) / math.pow(b, 3.0))))) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) tmp = 0.0 if (Float64(Float64(t_0 - b) / Float64(3.0 * a)) <= -0.395) tmp = Float64(Float64(t_0 - Float64((b ^ 2.0) / b)) / Float64(3.0 * a)); else tmp = Float64(Float64(-0.5 * Float64(1.0 / Float64(b / c))) + Float64(a * Float64(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))))) + Float64(-0.375 * Float64(Float64(c * c) / (b ^ 3.0)))))); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((3.0 * a) * c))); tmp = 0.0; if (((t_0 - b) / (3.0 * a)) <= -0.395) tmp = (t_0 - ((b ^ 2.0) / b)) / (3.0 * a); else tmp = (-0.5 * (1.0 / (b / c))) + (a * ((a * ((-0.5625 * ((c ^ 3.0) / (b ^ 5.0))) + (-1.0546875 * ((a * (c ^ 4.0)) / (b ^ 7.0))))) + (-0.375 * ((c * c) / (b ^ 3.0))))); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -0.395], N[(N[(t$95$0 - N[(N[Power[b, 2.0], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(1.0 / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * N[(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] + N[(-0.375 * N[(N[(c * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\\
\mathbf{if}\;\frac{t\_0 - b}{3 \cdot a} \leq -0.395:\\
\;\;\;\;\frac{t\_0 - \frac{{b}^{2}}{b}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{1}{\frac{b}{c}} + a \cdot \left(a \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}} + -1.0546875 \cdot \frac{a \cdot {c}^{4}}{{b}^{7}}\right) + -0.375 \cdot \frac{c \cdot c}{{b}^{3}}\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)) < -0.39500000000000002Initial program 85.9%
neg-sub085.9%
flip--86.0%
metadata-eval86.0%
pow286.0%
add-sqr-sqrt85.1%
sqrt-prod86.0%
sqr-neg86.0%
sqrt-unprod0.0%
add-sqr-sqrt1.5%
sub-neg1.5%
neg-sub01.5%
add-sqr-sqrt0.0%
sqrt-unprod86.0%
sqr-neg86.0%
sqrt-prod85.1%
add-sqr-sqrt86.0%
Applied egg-rr86.0%
neg-sub086.0%
Simplified86.0%
if -0.39500000000000002 < (/.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.2%
Simplified50.4%
Taylor expanded in a around 0 92.8%
Taylor expanded in c around 0 92.8%
clear-num92.6%
inv-pow92.6%
Applied egg-rr92.6%
unpow-192.6%
Simplified92.6%
unpow292.6%
Applied egg-rr92.6%
Final simplification91.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* 3.0 a) c)))))
(if (<= (/ (- t_0 b) (* 3.0 a)) -0.2)
(/ (- t_0 (/ (pow b 2.0) b)) (* 3.0 a))
(+
(* -0.5 (/ c b))
(*
a
(*
(pow c 3.0)
(- (/ (* a -0.5625) (pow b 5.0)) (/ 0.375 (* c (pow b 3.0))))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((3.0 * a) * c)));
double tmp;
if (((t_0 - b) / (3.0 * a)) <= -0.2) {
tmp = (t_0 - (pow(b, 2.0) / b)) / (3.0 * a);
} else {
tmp = (-0.5 * (c / b)) + (a * (pow(c, 3.0) * (((a * -0.5625) / pow(b, 5.0)) - (0.375 / (c * pow(b, 3.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) :: tmp
t_0 = sqrt(((b * b) - ((3.0d0 * a) * c)))
if (((t_0 - b) / (3.0d0 * a)) <= (-0.2d0)) then
tmp = (t_0 - ((b ** 2.0d0) / b)) / (3.0d0 * a)
else
tmp = ((-0.5d0) * (c / b)) + (a * ((c ** 3.0d0) * (((a * (-0.5625d0)) / (b ** 5.0d0)) - (0.375d0 / (c * (b ** 3.0d0))))))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((3.0 * a) * c)));
double tmp;
if (((t_0 - b) / (3.0 * a)) <= -0.2) {
tmp = (t_0 - (Math.pow(b, 2.0) / b)) / (3.0 * a);
} else {
tmp = (-0.5 * (c / b)) + (a * (Math.pow(c, 3.0) * (((a * -0.5625) / Math.pow(b, 5.0)) - (0.375 / (c * Math.pow(b, 3.0))))));
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((3.0 * a) * c))) tmp = 0 if ((t_0 - b) / (3.0 * a)) <= -0.2: tmp = (t_0 - (math.pow(b, 2.0) / b)) / (3.0 * a) else: tmp = (-0.5 * (c / b)) + (a * (math.pow(c, 3.0) * (((a * -0.5625) / math.pow(b, 5.0)) - (0.375 / (c * math.pow(b, 3.0)))))) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) tmp = 0.0 if (Float64(Float64(t_0 - b) / Float64(3.0 * a)) <= -0.2) tmp = Float64(Float64(t_0 - Float64((b ^ 2.0) / b)) / Float64(3.0 * a)); else tmp = Float64(Float64(-0.5 * Float64(c / b)) + Float64(a * Float64((c ^ 3.0) * Float64(Float64(Float64(a * -0.5625) / (b ^ 5.0)) - Float64(0.375 / Float64(c * (b ^ 3.0))))))); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((3.0 * a) * c))); tmp = 0.0; if (((t_0 - b) / (3.0 * a)) <= -0.2) tmp = (t_0 - ((b ^ 2.0) / b)) / (3.0 * a); else tmp = (-0.5 * (c / b)) + (a * ((c ^ 3.0) * (((a * -0.5625) / (b ^ 5.0)) - (0.375 / (c * (b ^ 3.0)))))); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -0.2], N[(N[(t$95$0 - N[(N[Power[b, 2.0], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[Power[c, 3.0], $MachinePrecision] * N[(N[(N[(a * -0.5625), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] - N[(0.375 / N[(c * N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\\
\mathbf{if}\;\frac{t\_0 - b}{3 \cdot a} \leq -0.2:\\
\;\;\;\;\frac{t\_0 - \frac{{b}^{2}}{b}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b} + a \cdot \left({c}^{3} \cdot \left(\frac{a \cdot -0.5625}{{b}^{5}} - \frac{0.375}{c \cdot {b}^{3}}\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)) < -0.20000000000000001Initial program 84.7%
neg-sub084.7%
flip--84.7%
metadata-eval84.7%
pow284.7%
add-sqr-sqrt83.7%
sqrt-prod84.7%
sqr-neg84.7%
sqrt-unprod0.0%
add-sqr-sqrt1.5%
sub-neg1.5%
neg-sub01.5%
add-sqr-sqrt0.0%
sqrt-unprod84.7%
sqr-neg84.7%
sqrt-prod83.7%
add-sqr-sqrt84.7%
Applied egg-rr84.7%
neg-sub084.7%
Simplified84.7%
if -0.20000000000000001 < (/.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 49.5%
Simplified49.7%
Taylor expanded in a around 0 90.8%
Taylor expanded in c around inf 90.8%
associate-*r/90.8%
associate-*r/90.8%
metadata-eval90.8%
*-commutative90.8%
Simplified90.8%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* 3.0 a) c)))))
(if (<= (/ (- t_0 b) (* 3.0 a)) -0.069)
(/ (- t_0 (/ (pow b 2.0) b)) (* 3.0 a))
(+ (* -0.5 (/ c b)) (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((3.0 * a) * c)));
double tmp;
if (((t_0 - b) / (3.0 * a)) <= -0.069) {
tmp = (t_0 - (pow(b, 2.0) / b)) / (3.0 * a);
} else {
tmp = (-0.5 * (c / b)) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.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) :: tmp
t_0 = sqrt(((b * b) - ((3.0d0 * a) * c)))
if (((t_0 - b) / (3.0d0 * a)) <= (-0.069d0)) then
tmp = (t_0 - ((b ** 2.0d0) / b)) / (3.0d0 * a)
else
tmp = ((-0.5d0) * (c / b)) + ((-0.375d0) * ((a * (c ** 2.0d0)) / (b ** 3.0d0)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((3.0 * a) * c)));
double tmp;
if (((t_0 - b) / (3.0 * a)) <= -0.069) {
tmp = (t_0 - (Math.pow(b, 2.0) / b)) / (3.0 * a);
} else {
tmp = (-0.5 * (c / b)) + (-0.375 * ((a * Math.pow(c, 2.0)) / Math.pow(b, 3.0)));
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((3.0 * a) * c))) tmp = 0 if ((t_0 - b) / (3.0 * a)) <= -0.069: tmp = (t_0 - (math.pow(b, 2.0) / b)) / (3.0 * a) else: tmp = (-0.5 * (c / b)) + (-0.375 * ((a * math.pow(c, 2.0)) / math.pow(b, 3.0))) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) tmp = 0.0 if (Float64(Float64(t_0 - b) / Float64(3.0 * a)) <= -0.069) tmp = Float64(Float64(t_0 - Float64((b ^ 2.0) / b)) / Float64(3.0 * a)); else tmp = Float64(Float64(-0.5 * Float64(c / b)) + Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0)))); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((3.0 * a) * c))); tmp = 0.0; if (((t_0 - b) / (3.0 * a)) <= -0.069) tmp = (t_0 - ((b ^ 2.0) / b)) / (3.0 * a); else tmp = (-0.5 * (c / b)) + (-0.375 * ((a * (c ^ 2.0)) / (b ^ 3.0))); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -0.069], N[(N[(t$95$0 - N[(N[Power[b, 2.0], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\\
\mathbf{if}\;\frac{t\_0 - b}{3 \cdot a} \leq -0.069:\\
\;\;\;\;\frac{t\_0 - \frac{{b}^{2}}{b}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\
\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)) < -0.069000000000000006Initial program 83.9%
neg-sub083.9%
flip--83.9%
metadata-eval83.9%
pow283.9%
add-sqr-sqrt82.8%
sqrt-prod83.9%
sqr-neg83.9%
sqrt-unprod0.0%
add-sqr-sqrt1.5%
sub-neg1.5%
neg-sub01.5%
add-sqr-sqrt0.0%
sqrt-unprod83.9%
sqr-neg83.9%
sqrt-prod82.8%
add-sqr-sqrt83.9%
Applied egg-rr83.9%
neg-sub083.9%
Simplified83.9%
if -0.069000000000000006 < (/.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 48.7%
Simplified48.9%
Taylor expanded in a around 0 86.0%
Final simplification85.5%
(FPCore (a b c) :precision binary64 (if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.069) (/ (- (sqrt (* c (+ (* a -3.0) (/ (pow b 2.0) c)))) b) (* 3.0 a)) (+ (* -0.5 (/ c b)) (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0))))))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.069) {
tmp = (sqrt((c * ((a * -3.0) + (pow(b, 2.0) / c)))) - b) / (3.0 * a);
} else {
tmp = (-0.5 * (c / b)) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.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) :: tmp
if (((sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * a)) <= (-0.069d0)) then
tmp = (sqrt((c * ((a * (-3.0d0)) + ((b ** 2.0d0) / c)))) - b) / (3.0d0 * a)
else
tmp = ((-0.5d0) * (c / b)) + ((-0.375d0) * ((a * (c ** 2.0d0)) / (b ** 3.0d0)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (((Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.069) {
tmp = (Math.sqrt((c * ((a * -3.0) + (Math.pow(b, 2.0) / c)))) - b) / (3.0 * a);
} else {
tmp = (-0.5 * (c / b)) + (-0.375 * ((a * Math.pow(c, 2.0)) / Math.pow(b, 3.0)));
}
return tmp;
}
def code(a, b, c): tmp = 0 if ((math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.069: tmp = (math.sqrt((c * ((a * -3.0) + (math.pow(b, 2.0) / c)))) - b) / (3.0 * a) else: tmp = (-0.5 * (c / b)) + (-0.375 * ((a * math.pow(c, 2.0)) / math.pow(b, 3.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)) <= -0.069) tmp = Float64(Float64(sqrt(Float64(c * Float64(Float64(a * -3.0) + Float64((b ^ 2.0) / c)))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(-0.5 * Float64(c / b)) + Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0)))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.069) tmp = (sqrt((c * ((a * -3.0) + ((b ^ 2.0) / c)))) - b) / (3.0 * a); else tmp = (-0.5 * (c / b)) + (-0.375 * ((a * (c ^ 2.0)) / (b ^ 3.0))); end tmp_2 = 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], -0.069], N[(N[(N[Sqrt[N[(c * N[(N[(a * -3.0), $MachinePrecision] + N[(N[Power[b, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $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 -0.069:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3 + \frac{{b}^{2}}{c}\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\
\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)) < -0.069000000000000006Initial program 83.9%
Simplified83.9%
Taylor expanded in c around inf 83.9%
if -0.069000000000000006 < (/.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 48.7%
Simplified48.9%
Taylor expanded in a around 0 86.0%
Final simplification85.5%
(FPCore (a b c) :precision binary64 (if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.069) (/ (- (sqrt (fma b b (* a (* c -3.0)))) b) (* 3.0 a)) (+ (* -0.5 (/ c b)) (* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0))))))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.069) {
tmp = (sqrt(fma(b, b, (a * (c * -3.0)))) - b) / (3.0 * a);
} else {
tmp = (-0.5 * (c / b)) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.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)) <= -0.069) tmp = Float64(Float64(sqrt(fma(b, b, Float64(a * Float64(c * -3.0)))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(-0.5 * Float64(c / b)) + Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.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], -0.069], 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[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $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 -0.069:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\\
\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)) < -0.069000000000000006Initial program 83.9%
Simplified83.9%
if -0.069000000000000006 < (/.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 48.7%
Simplified48.9%
Taylor expanded in a around 0 86.0%
Final simplification85.5%
(FPCore (a b c) :precision binary64 (if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.069) (/ (- (sqrt (fma b b (* a (* c -3.0)))) b) (* 3.0 a)) (/ (fma -0.375 (* a (pow (/ c b) 2.0)) (* c -0.5)) b)))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.069) {
tmp = (sqrt(fma(b, b, (a * (c * -3.0)))) - b) / (3.0 * a);
} else {
tmp = fma(-0.375, (a * pow((c / b), 2.0)), (c * -0.5)) / b;
}
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)) <= -0.069) tmp = Float64(Float64(sqrt(fma(b, b, Float64(a * Float64(c * -3.0)))) - b) / Float64(3.0 * a)); else tmp = Float64(fma(-0.375, Float64(a * (Float64(c / b) ^ 2.0)), Float64(c * -0.5)) / b); 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], -0.069], 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[(N[(-0.375 * N[(a * N[Power[N[(c / b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(c * -0.5), $MachinePrecision]), $MachinePrecision] / b), $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 -0.069:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.375, a \cdot {\left(\frac{c}{b}\right)}^{2}, c \cdot -0.5\right)}{b}\\
\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)) < -0.069000000000000006Initial program 83.9%
Simplified83.9%
if -0.069000000000000006 < (/.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 48.7%
Simplified48.9%
Taylor expanded in a around 0 85.7%
Taylor expanded in b around inf 86.0%
+-commutative86.0%
fma-define86.0%
associate-/l*86.0%
unpow286.0%
unpow286.0%
times-frac86.0%
unpow286.0%
*-commutative86.0%
Simplified86.0%
Final simplification85.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))))
(if (<= t_0 -0.069)
t_0
(/ (fma -0.375 (* a (pow (/ c b) 2.0)) (* c -0.5)) b))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
double tmp;
if (t_0 <= -0.069) {
tmp = t_0;
} else {
tmp = fma(-0.375, (a * pow((c / b), 2.0)), (c * -0.5)) / b;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) tmp = 0.0 if (t_0 <= -0.069) tmp = t_0; else tmp = Float64(fma(-0.375, Float64(a * (Float64(c / b) ^ 2.0)), Float64(c * -0.5)) / b); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.069], t$95$0, N[(N[(-0.375 * N[(a * N[Power[N[(c / b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(c * -0.5), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{if}\;t\_0 \leq -0.069:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.375, a \cdot {\left(\frac{c}{b}\right)}^{2}, c \cdot -0.5\right)}{b}\\
\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)) < -0.069000000000000006Initial program 83.9%
if -0.069000000000000006 < (/.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 48.7%
Simplified48.9%
Taylor expanded in a around 0 85.7%
Taylor expanded in b around inf 86.0%
+-commutative86.0%
fma-define86.0%
associate-/l*86.0%
unpow286.0%
unpow286.0%
times-frac86.0%
unpow286.0%
*-commutative86.0%
Simplified86.0%
Final simplification85.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))))
(if (<= t_0 -0.069)
t_0
(* c (- (* -0.375 (* a (/ c (pow b 3.0)))) (/ 0.5 b))))))
double code(double a, double b, double c) {
double t_0 = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
double tmp;
if (t_0 <= -0.069) {
tmp = t_0;
} else {
tmp = c * ((-0.375 * (a * (c / pow(b, 3.0)))) - (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) :: t_0
real(8) :: tmp
t_0 = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * a)
if (t_0 <= (-0.069d0)) then
tmp = t_0
else
tmp = c * (((-0.375d0) * (a * (c / (b ** 3.0d0)))) - (0.5d0 / b))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
double tmp;
if (t_0 <= -0.069) {
tmp = t_0;
} else {
tmp = c * ((-0.375 * (a * (c / Math.pow(b, 3.0)))) - (0.5 / b));
}
return tmp;
}
def code(a, b, c): t_0 = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) tmp = 0 if t_0 <= -0.069: tmp = t_0 else: tmp = c * ((-0.375 * (a * (c / math.pow(b, 3.0)))) - (0.5 / b)) return tmp
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) tmp = 0.0 if (t_0 <= -0.069) tmp = t_0; else tmp = Float64(c * Float64(Float64(-0.375 * Float64(a * Float64(c / (b ^ 3.0)))) - Float64(0.5 / b))); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); tmp = 0.0; if (t_0 <= -0.069) tmp = t_0; else tmp = c * ((-0.375 * (a * (c / (b ^ 3.0)))) - (0.5 / b)); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$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]}, If[LessEqual[t$95$0, -0.069], t$95$0, N[(c * N[(N[(-0.375 * N[(a * N[(c / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{if}\;t\_0 \leq -0.069:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;c \cdot \left(-0.375 \cdot \left(a \cdot \frac{c}{{b}^{3}}\right) - \frac{0.5}{b}\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)) < -0.069000000000000006Initial program 83.9%
if -0.069000000000000006 < (/.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 48.7%
Simplified48.9%
Taylor expanded in c around 0 85.7%
associate-/l*85.7%
associate-*r/85.7%
metadata-eval85.7%
Simplified85.7%
Final simplification85.3%
(FPCore (a b c) :precision binary64 (if (<= b 3810.0) (/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* 3.0 a)) (* c (- (* -0.375 (* a (/ c (pow b 3.0)))) (/ 0.5 b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 3810.0) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
} else {
tmp = c * ((-0.375 * (a * (c / pow(b, 3.0)))) - (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 <= 3810.0d0) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (3.0d0 * a)
else
tmp = c * (((-0.375d0) * (a * (c / (b ** 3.0d0)))) - (0.5d0 / b))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 3810.0) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
} else {
tmp = c * ((-0.375 * (a * (c / Math.pow(b, 3.0)))) - (0.5 / b));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3810.0: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a) else: tmp = c * ((-0.375 * (a * (c / math.pow(b, 3.0)))) - (0.5 / b)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3810.0) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(3.0 * a)); else tmp = Float64(c * Float64(Float64(-0.375 * Float64(a * Float64(c / (b ^ 3.0)))) - Float64(0.5 / b))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3810.0) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a); else tmp = c * ((-0.375 * (a * (c / (b ^ 3.0)))) - (0.5 / b)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3810.0], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(c * N[(N[(-0.375 * N[(a * N[(c / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3810:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \left(-0.375 \cdot \left(a \cdot \frac{c}{{b}^{3}}\right) - \frac{0.5}{b}\right)\\
\end{array}
\end{array}
if b < 3810Initial program 77.5%
sqr-neg77.5%
sqr-neg77.5%
associate-*l*77.5%
Simplified77.5%
if 3810 < b Initial program 40.9%
Simplified41.0%
Taylor expanded in c around 0 90.9%
associate-/l*90.9%
associate-*r/90.9%
metadata-eval90.9%
Simplified90.9%
Final simplification84.9%
(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(a * Float64(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[(a * N[(c / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \left(-0.375 \cdot \left(a \cdot \frac{c}{{b}^{3}}\right) - \frac{0.5}{b}\right)
\end{array}
Initial program 57.2%
Simplified57.4%
Taylor expanded in c around 0 78.4%
associate-/l*78.4%
associate-*r/78.4%
metadata-eval78.4%
Simplified78.4%
(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 57.2%
Simplified57.4%
Taylor expanded in b around inf 62.3%
herbie shell --seed 2024149
(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)))