
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma a (* c -3.0) (pow b 2.0))))
(if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.15)
(/ (/ (- (pow b 2.0) t_0) (- (- b) (sqrt t_0))) (* 3.0 a))
(+
(* -0.5625 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.0)))
(+
(* -0.5 (/ c b))
(+
(* -0.375 (/ (* a (pow c 2.0)) (pow b 3.0)))
(/ (* -1.0546875 (pow (* a c) 4.0)) (* a (pow b 7.0)))))))))
double code(double a, double b, double c) {
double t_0 = fma(a, (c * -3.0), pow(b, 2.0));
double tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.15) {
tmp = ((pow(b, 2.0) - t_0) / (-b - sqrt(t_0))) / (3.0 * a);
} else {
tmp = (-0.5625 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.0))) + ((-0.5 * (c / b)) + ((-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0))) + ((-1.0546875 * pow((a * c), 4.0)) / (a * pow(b, 7.0)))));
}
return tmp;
}
function code(a, b, c) t_0 = fma(a, Float64(c * -3.0), (b ^ 2.0)) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.15) tmp = Float64(Float64(Float64((b ^ 2.0) - t_0) / Float64(Float64(-b) - sqrt(t_0))) / Float64(3.0 * a)); else tmp = Float64(Float64(-0.5625 * Float64(Float64((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + Float64(Float64(-0.5 * Float64(c / b)) + Float64(Float64(-0.375 * Float64(Float64(a * (c ^ 2.0)) / (b ^ 3.0))) + Float64(Float64(-1.0546875 * (Float64(a * c) ^ 4.0)) / Float64(a * (b ^ 7.0)))))); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * -3.0), $MachinePrecision] + N[Power[b, 2.0], $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.15], N[(N[(N[(N[Power[b, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] / N[((-b) - N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5625 * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.375 * N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0546875 * N[Power[N[(a * c), $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / N[(a * N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.15:\\
\;\;\;\;\frac{\frac{{b}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + \left(-0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}} + \frac{-1.0546875 \cdot {\left(a \cdot c\right)}^{4}}{a \cdot {b}^{7}}\right)\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.149999999999999994Initial program 84.2%
Taylor expanded in a around 0 84.3%
flip-+84.0%
pow284.0%
add-sqr-sqrt85.6%
cancel-sign-sub-inv85.6%
fma-def85.1%
metadata-eval85.1%
cancel-sign-sub-inv85.1%
fma-def85.1%
metadata-eval85.1%
Applied egg-rr85.1%
unpow285.1%
sqr-neg85.1%
unpow285.1%
fma-udef85.6%
unpow285.6%
*-commutative85.6%
associate-*r*85.7%
+-commutative85.7%
fma-def85.7%
fma-udef85.7%
unpow285.7%
*-commutative85.7%
associate-*r*85.6%
+-commutative85.6%
fma-def85.6%
Simplified85.6%
if -0.149999999999999994 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) Initial program 54.0%
Taylor expanded in b around inf 93.9%
Taylor expanded in c around 0 93.9%
distribute-rgt-out93.9%
associate-*r*93.9%
*-commutative93.9%
*-commutative93.9%
times-frac93.9%
Simplified93.9%
expm1-log1p-u93.9%
expm1-udef92.9%
frac-times92.9%
Applied egg-rr92.9%
expm1-def93.9%
expm1-log1p93.9%
associate-*r/93.9%
*-commutative93.9%
associate-*r*93.9%
metadata-eval93.9%
*-commutative93.9%
Simplified93.9%
Final simplification92.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma a (* c -3.0) (pow b 2.0))))
(if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.15)
(/ (/ (- (pow b 2.0) t_0) (- (- b) (sqrt t_0))) (* 3.0 a))
(+
(* -0.5625 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.0)))
(+ (* -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 = fma(a, (c * -3.0), pow(b, 2.0));
double tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.15) {
tmp = ((pow(b, 2.0) - t_0) / (-b - sqrt(t_0))) / (3.0 * a);
} else {
tmp = (-0.5625 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.0))) + ((-0.5 * (c / b)) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0))));
}
return tmp;
}
function code(a, b, c) t_0 = fma(a, Float64(c * -3.0), (b ^ 2.0)) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.15) tmp = Float64(Float64(Float64((b ^ 2.0) - t_0) / Float64(Float64(-b) - sqrt(t_0))) / Float64(3.0 * a)); else tmp = Float64(Float64(-0.5625 * Float64(Float64((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + 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_] := Block[{t$95$0 = N[(a * N[(c * -3.0), $MachinePrecision] + N[Power[b, 2.0], $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.15], N[(N[(N[(N[Power[b, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] / N[((-b) - N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5625 * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $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]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, c \cdot -3, {b}^{2}\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.15:\\
\;\;\;\;\frac{\frac{{b}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.149999999999999994Initial program 84.2%
Taylor expanded in a around 0 84.3%
flip-+84.0%
pow284.0%
add-sqr-sqrt85.6%
cancel-sign-sub-inv85.6%
fma-def85.1%
metadata-eval85.1%
cancel-sign-sub-inv85.1%
fma-def85.1%
metadata-eval85.1%
Applied egg-rr85.1%
unpow285.1%
sqr-neg85.1%
unpow285.1%
fma-udef85.6%
unpow285.6%
*-commutative85.6%
associate-*r*85.7%
+-commutative85.7%
fma-def85.7%
fma-udef85.7%
unpow285.7%
*-commutative85.7%
associate-*r*85.6%
+-commutative85.6%
fma-def85.6%
Simplified85.6%
if -0.149999999999999994 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) Initial program 54.0%
Taylor expanded in b around inf 91.2%
Final simplification90.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma b b (* -3.0 (* a c)))))
(if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.15)
(/ (/ (- (pow (- b) 2.0) t_0) (- (- b) (sqrt t_0))) (* 3.0 a))
(+
(* -0.5625 (/ (* (pow a 2.0) (pow c 3.0)) (pow b 5.0)))
(+ (* -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 = fma(b, b, (-3.0 * (a * c)));
double tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.15) {
tmp = ((pow(-b, 2.0) - t_0) / (-b - sqrt(t_0))) / (3.0 * a);
} else {
tmp = (-0.5625 * ((pow(a, 2.0) * pow(c, 3.0)) / pow(b, 5.0))) + ((-0.5 * (c / b)) + (-0.375 * ((a * pow(c, 2.0)) / pow(b, 3.0))));
}
return tmp;
}
function code(a, b, c) t_0 = fma(b, b, Float64(-3.0 * Float64(a * c))) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.15) tmp = Float64(Float64(Float64((Float64(-b) ^ 2.0) - t_0) / Float64(Float64(-b) - sqrt(t_0))) / Float64(3.0 * a)); else tmp = Float64(Float64(-0.5625 * Float64(Float64((a ^ 2.0) * (c ^ 3.0)) / (b ^ 5.0))) + 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_] := Block[{t$95$0 = N[(b * b + N[(-3.0 * N[(a * c), $MachinePrecision]), $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.15], N[(N[(N[(N[Power[(-b), 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] / N[((-b) - N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5625 * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $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]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.15:\\
\;\;\;\;\frac{\frac{{\left(-b\right)}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5625 \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{a \cdot {c}^{2}}{{b}^{3}}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.149999999999999994Initial program 84.2%
Taylor expanded in a around 0 84.3%
flip-+84.0%
pow284.0%
add-sqr-sqrt85.6%
cancel-sign-sub-inv85.6%
fma-def85.1%
metadata-eval85.1%
cancel-sign-sub-inv85.1%
fma-def85.1%
metadata-eval85.1%
Applied egg-rr85.1%
if -0.149999999999999994 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) Initial program 54.0%
Taylor expanded in b around inf 91.2%
Final simplification89.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma b b (* -3.0 (* a c)))))
(if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.0034)
(/ (/ (- (pow (- b) 2.0) t_0) (- (- b) (sqrt t_0))) (* 3.0 a))
(fma
(* (* a (pow c 2.0)) (pow b -3.0))
-0.375
(log1p (expm1 (/ c (* b -2.0))))))))
double code(double a, double b, double c) {
double t_0 = fma(b, b, (-3.0 * (a * c)));
double tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.0034) {
tmp = ((pow(-b, 2.0) - t_0) / (-b - sqrt(t_0))) / (3.0 * a);
} else {
tmp = fma(((a * pow(c, 2.0)) * pow(b, -3.0)), -0.375, log1p(expm1((c / (b * -2.0)))));
}
return tmp;
}
function code(a, b, c) t_0 = fma(b, b, Float64(-3.0 * Float64(a * c))) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.0034) tmp = Float64(Float64(Float64((Float64(-b) ^ 2.0) - t_0) / Float64(Float64(-b) - sqrt(t_0))) / Float64(3.0 * a)); else tmp = fma(Float64(Float64(a * (c ^ 2.0)) * (b ^ -3.0)), -0.375, log1p(expm1(Float64(c / Float64(b * -2.0))))); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(b * b + N[(-3.0 * N[(a * c), $MachinePrecision]), $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.0034], N[(N[(N[(N[Power[(-b), 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] / N[((-b) - N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[b, -3.0], $MachinePrecision]), $MachinePrecision] * -0.375 + N[Log[1 + N[(Exp[N[(c / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0034:\\
\;\;\;\;\frac{\frac{{\left(-b\right)}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(a \cdot {c}^{2}\right) \cdot {b}^{-3}, -0.375, \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{c}{b \cdot -2}\right)\right)\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -0.00339999999999999981Initial program 80.6%
Taylor expanded in a around 0 80.6%
flip-+80.3%
pow280.3%
add-sqr-sqrt81.8%
cancel-sign-sub-inv81.8%
fma-def81.3%
metadata-eval81.3%
cancel-sign-sub-inv81.3%
fma-def81.3%
metadata-eval81.3%
Applied egg-rr81.3%
if -0.00339999999999999981 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) Initial program 48.8%
Taylor expanded in b around inf 88.7%
+-commutative88.7%
*-commutative88.7%
fma-def88.7%
div-inv88.7%
pow-flip88.7%
metadata-eval88.7%
associate-*r/88.7%
associate-*l/88.5%
*-commutative88.5%
Applied egg-rr88.5%
log1p-expm1-u88.5%
clear-num88.5%
un-div-inv88.7%
div-inv88.7%
metadata-eval88.7%
Applied egg-rr88.7%
Final simplification86.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma b b (* -3.0 (* a c)))))
(if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.0034)
(/ (/ (- (pow (- b) 2.0) t_0) (- (- b) (sqrt t_0))) (* 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 = fma(b, b, (-3.0 * (a * c)));
double tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.0034) {
tmp = ((pow(-b, 2.0) - t_0) / (-b - sqrt(t_0))) / (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) t_0 = fma(b, b, Float64(-3.0 * Float64(a * c))) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)) <= -0.0034) tmp = Float64(Float64(Float64((Float64(-b) ^ 2.0) - t_0) / Float64(Float64(-b) - sqrt(t_0))) / 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_] := Block[{t$95$0 = N[(b * b + N[(-3.0 * N[(a * c), $MachinePrecision]), $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.0034], N[(N[(N[(N[Power[(-b), 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] / N[((-b) - N[Sqrt[t$95$0], $MachinePrecision]), $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 := \mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a} \leq -0.0034:\\
\;\;\;\;\frac{\frac{{\left(-b\right)}^{2} - t_0}{\left(-b\right) - \sqrt{t_0}}}{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 3 a) c)))) (*.f64 3 a)) < -0.00339999999999999981Initial program 80.6%
Taylor expanded in a around 0 80.6%
flip-+80.3%
pow280.3%
add-sqr-sqrt81.8%
cancel-sign-sub-inv81.8%
fma-def81.3%
metadata-eval81.3%
cancel-sign-sub-inv81.3%
fma-def81.3%
metadata-eval81.3%
Applied egg-rr81.3%
if -0.00339999999999999981 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) Initial program 48.8%
Taylor expanded in b around inf 88.7%
Final simplification86.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* (* 3.0 a) c)) (t_1 (sqrt t_0)))
(if (<= (/ (- (sqrt (- (* b b) t_0)) b) (* 3.0 a)) -0.0034)
(/ (- (sqrt (* (+ b t_1) (- b t_1))) 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 = (3.0 * a) * c;
double t_1 = sqrt(t_0);
double tmp;
if (((sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -0.0034) {
tmp = (sqrt(((b + t_1) * (b - t_1))) - 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) :: t_1
real(8) :: tmp
t_0 = (3.0d0 * a) * c
t_1 = sqrt(t_0)
if (((sqrt(((b * b) - t_0)) - b) / (3.0d0 * a)) <= (-0.0034d0)) then
tmp = (sqrt(((b + t_1) * (b - t_1))) - 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 = (3.0 * a) * c;
double t_1 = Math.sqrt(t_0);
double tmp;
if (((Math.sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -0.0034) {
tmp = (Math.sqrt(((b + t_1) * (b - t_1))) - 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 = (3.0 * a) * c t_1 = math.sqrt(t_0) tmp = 0 if ((math.sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -0.0034: tmp = (math.sqrt(((b + t_1) * (b - t_1))) - 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 = Float64(Float64(3.0 * a) * c) t_1 = sqrt(t_0) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - t_0)) - b) / Float64(3.0 * a)) <= -0.0034) tmp = Float64(Float64(sqrt(Float64(Float64(b + t_1) * Float64(b - t_1))) - 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 = (3.0 * a) * c; t_1 = sqrt(t_0); tmp = 0.0; if (((sqrt(((b * b) - t_0)) - b) / (3.0 * a)) <= -0.0034) tmp = (sqrt(((b + t_1) * (b - t_1))) - 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[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[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], -0.0034], N[(N[(N[Sqrt[N[(N[(b + t$95$1), $MachinePrecision] * N[(b - t$95$1), $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}
t_0 := \left(3 \cdot a\right) \cdot c\\
t_1 := \sqrt{t_0}\\
\mathbf{if}\;\frac{\sqrt{b \cdot b - t_0} - b}{3 \cdot a} \leq -0.0034:\\
\;\;\;\;\frac{\sqrt{\left(b + t_1\right) \cdot \left(b - t_1\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 3 a) c)))) (*.f64 3 a)) < -0.00339999999999999981Initial program 80.6%
add-sqr-sqrt80.6%
difference-of-squares80.6%
associate-*l*80.6%
associate-*l*80.6%
Applied egg-rr80.6%
associate-*r*80.6%
*-commutative80.6%
associate-*r*80.6%
*-commutative80.6%
Simplified80.6%
if -0.00339999999999999981 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) Initial program 48.8%
Taylor expanded in b around inf 88.7%
Final simplification85.7%
(FPCore (a b c) :precision binary64 (if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.0034) (/ (- (sqrt (fma a (* c -3.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 tmp;
if (((sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a)) <= -0.0034) {
tmp = (sqrt(fma(a, (c * -3.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;
}
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.0034) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -3.0), (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
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.0034], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision] + N[Power[b, 2.0], $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.0034:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -3, {b}^{2}\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 3 a) c)))) (*.f64 3 a)) < -0.00339999999999999981Initial program 80.6%
Taylor expanded in a around 0 80.6%
expm1-log1p-u59.5%
expm1-udef56.2%
neg-mul-156.2%
fma-def56.2%
cancel-sign-sub-inv56.2%
fma-def56.1%
metadata-eval56.1%
Applied egg-rr56.1%
expm1-def59.5%
expm1-log1p80.6%
fma-udef80.6%
neg-mul-180.6%
+-commutative80.6%
unsub-neg80.6%
fma-udef80.6%
unpow280.6%
*-commutative80.6%
associate-*r*80.5%
+-commutative80.5%
fma-def80.6%
Simplified80.6%
if -0.00339999999999999981 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) Initial program 48.8%
Taylor expanded in b around inf 88.7%
Final simplification85.7%
(FPCore (a b c) :precision binary64 (if (<= (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)) -0.0034) (/ (- (sqrt (- (* b b) (* 3.0 (* a 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.0034) {
tmp = (sqrt(((b * b) - (3.0 * (a * 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.0034d0)) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * 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.0034) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * 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.0034: tmp = (math.sqrt(((b * b) - (3.0 * (a * 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.0034) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * 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.0034) tmp = (sqrt(((b * b) - (3.0 * (a * 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.0034], 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[(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.0034:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot 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 3 a) c)))) (*.f64 3 a)) < -0.00339999999999999981Initial program 80.6%
Taylor expanded in a around 0 80.6%
if -0.00339999999999999981 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) Initial program 48.8%
Taylor expanded in b around inf 88.7%
Final simplification85.7%
(FPCore (a b c) :precision binary64 (let* ((t_0 (/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a)))) (if (<= t_0 -4e-7) t_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 <= -4e-7) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * a)
if (t_0 <= (-4d-7)) then
tmp = t_0
else
tmp = (c * (-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 <= -4e-7) {
tmp = t_0;
} else {
tmp = (c * -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 <= -4e-7: tmp = t_0 else: tmp = (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 <= -4e-7) tmp = t_0; else tmp = Float64(Float64(c * -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 <= -4e-7) tmp = t_0; else tmp = (c * -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, -4e-7], t$95$0, N[(N[(c * -0.5), $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 -4 \cdot 10^{-7}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -3.9999999999999998e-7Initial program 74.9%
if -3.9999999999999998e-7 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) Initial program 34.8%
Taylor expanded in b around inf 82.3%
associate-*r/82.3%
Simplified82.3%
Final simplification77.6%
(FPCore (a b c) :precision binary64 (if (or (<= b 155.0) (and (not (<= b 718.0)) (<= b 3000.0))) (/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* 3.0 a)) (/ (* c -0.5) b)))
double code(double a, double b, double c) {
double tmp;
if ((b <= 155.0) || (!(b <= 718.0) && (b <= 3000.0))) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * 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 <= 155.0d0) .or. (.not. (b <= 718.0d0)) .and. (b <= 3000.0d0)) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (3.0d0 * 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 <= 155.0) || (!(b <= 718.0) && (b <= 3000.0))) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
} else {
tmp = (c * -0.5) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if (b <= 155.0) or (not (b <= 718.0) and (b <= 3000.0)): tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a) else: tmp = (c * -0.5) / b return tmp
function code(a, b, c) tmp = 0.0 if ((b <= 155.0) || (!(b <= 718.0) && (b <= 3000.0))) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(3.0 * 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 <= 155.0) || (~((b <= 718.0)) && (b <= 3000.0))) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a); else tmp = (c * -0.5) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[Or[LessEqual[b, 155.0], And[N[Not[LessEqual[b, 718.0]], $MachinePrecision], LessEqual[b, 3000.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[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 155 \lor \neg \left(b \leq 718\right) \land b \leq 3000:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\
\end{array}
\end{array}
if b < 155 or 718 < b < 3e3Initial program 77.7%
Taylor expanded in a around 0 77.7%
if 155 < b < 718 or 3e3 < b Initial program 47.5%
Taylor expanded in b around inf 72.1%
associate-*r/72.1%
Simplified72.1%
Final simplification74.5%
(FPCore (a b c) :precision binary64 (* c (/ -0.5 b)))
double code(double a, double b, double c) {
return c * (-0.5 / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c * ((-0.5d0) / b)
end function
public static double code(double a, double b, double c) {
return c * (-0.5 / b);
}
def code(a, b, c): return c * (-0.5 / b)
function code(a, b, c) return Float64(c * Float64(-0.5 / b)) end
function tmp = code(a, b, c) tmp = c * (-0.5 / b); end
code[a_, b_, c_] := N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \frac{-0.5}{b}
\end{array}
Initial program 60.5%
Taylor expanded in b around inf 60.3%
associate-*r/60.3%
associate-/l*60.3%
Simplified60.3%
associate-/r/60.3%
Applied egg-rr60.3%
Final simplification60.3%
(FPCore (a b c) :precision binary64 (/ -0.5 (/ b c)))
double code(double a, double b, double c) {
return -0.5 / (b / c);
}
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) / (b / c)
end function
public static double code(double a, double b, double c) {
return -0.5 / (b / c);
}
def code(a, b, c): return -0.5 / (b / c)
function code(a, b, c) return Float64(-0.5 / Float64(b / c)) end
function tmp = code(a, b, c) tmp = -0.5 / (b / c); end
code[a_, b_, c_] := N[(-0.5 / N[(b / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.5}{\frac{b}{c}}
\end{array}
Initial program 60.5%
Taylor expanded in b around inf 60.3%
associate-*r/60.3%
associate-/l*60.3%
Simplified60.3%
Final simplification60.3%
(FPCore (a b c) :precision binary64 (/ (* c -0.5) b))
double code(double a, double b, double c) {
return (c * -0.5) / b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c * (-0.5d0)) / b
end function
public static double code(double a, double b, double c) {
return (c * -0.5) / b;
}
def code(a, b, c): return (c * -0.5) / b
function code(a, b, c) return Float64(Float64(c * -0.5) / b) end
function tmp = code(a, b, c) tmp = (c * -0.5) / b; end
code[a_, b_, c_] := N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c \cdot -0.5}{b}
\end{array}
Initial program 60.5%
Taylor expanded in b around inf 60.3%
associate-*r/60.3%
Simplified60.3%
Final simplification60.3%
(FPCore (a b c) :precision binary64 (/ 0.0 a))
double code(double a, double b, double c) {
return 0.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 = 0.0d0 / a
end function
public static double code(double a, double b, double c) {
return 0.0 / a;
}
def code(a, b, c): return 0.0 / a
function code(a, b, c) return Float64(0.0 / a) end
function tmp = code(a, b, c) tmp = 0.0 / a; end
code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{a}
\end{array}
Initial program 60.5%
Taylor expanded in a around 0 60.5%
add-log-exp55.8%
neg-mul-155.8%
fma-def55.8%
cancel-sign-sub-inv55.8%
fma-def55.7%
metadata-eval55.7%
Applied egg-rr55.7%
Taylor expanded in a around 0 3.2%
associate-*r/3.2%
distribute-rgt1-in3.2%
metadata-eval3.2%
mul0-lft3.2%
metadata-eval3.2%
Simplified3.2%
Final simplification3.2%
herbie shell --seed 2024017
(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)))