| Alternative 1 | |
|---|---|
| Accuracy | 87.8% |
| Cost | 38052 |
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))
(FPCore (a b c)
:precision binary64
(if (<= b -3.8e+128)
(if (>= b 0.0)
(/ (- (- (/ (* c 2.0) (/ b a)) b) b) (* a 2.0))
(/ (* c 2.0) (fma 2.0 (/ c (/ b a)) (* b -2.0))))
(if (<= b 1.95e+29)
(if (>= b 0.0)
(* (+ b (hypot b (pow (* (cbrt (* a -4.0)) (cbrt c)) 1.5))) (/ -0.5 a))
(* c (/ 2.0 (- (sqrt (fma b b (* a (* c -4.0)))) b))))
(if (>= b 0.0) (/ (- (+ b b)) (* a 2.0)) (/ (- b) a)))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + sqrt(((b * b) - ((4.0 * a) * c))));
}
return tmp;
}
double code(double a, double b, double c) {
double tmp_1;
if (b <= -3.8e+128) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = ((((c * 2.0) / (b / a)) - b) - b) / (a * 2.0);
} else {
tmp_2 = (c * 2.0) / fma(2.0, (c / (b / a)), (b * -2.0));
}
tmp_1 = tmp_2;
} else if (b <= 1.95e+29) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (b + hypot(b, pow((cbrt((a * -4.0)) * cbrt(c)), 1.5))) * (-0.5 / a);
} else {
tmp_3 = c * (2.0 / (sqrt(fma(b, b, (a * (c * -4.0)))) - b));
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -(b + b) / (a * 2.0);
} else {
tmp_1 = -b / a;
}
return tmp_1;
}
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))))); end return tmp end
function code(a, b, c) tmp_1 = 0.0 if (b <= -3.8e+128) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(Float64(Float64(Float64(c * 2.0) / Float64(b / a)) - b) - b) / Float64(a * 2.0)); else tmp_2 = Float64(Float64(c * 2.0) / fma(2.0, Float64(c / Float64(b / a)), Float64(b * -2.0))); end tmp_1 = tmp_2; elseif (b <= 1.95e+29) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(b + hypot(b, (Float64(cbrt(Float64(a * -4.0)) * cbrt(c)) ^ 1.5))) * Float64(-0.5 / a)); else tmp_3 = Float64(c * Float64(2.0 / Float64(sqrt(fma(b, b, Float64(a * Float64(c * -4.0)))) - b))); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(-Float64(b + b)) / Float64(a * 2.0)); else tmp_1 = Float64(Float64(-b) / a); end return tmp_1 end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
code[a_, b_, c_] := If[LessEqual[b, -3.8e+128], If[GreaterEqual[b, 0.0], N[(N[(N[(N[(N[(c * 2.0), $MachinePrecision] / N[(b / a), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(b * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.95e+29], If[GreaterEqual[b, 0.0], N[(N[(b + N[Sqrt[b ^ 2 + N[Power[N[(N[Power[N[(a * -4.0), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[c, 1/3], $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(2.0 / N[(N[Sqrt[N[(b * b + N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[((-N[(b + b), $MachinePrecision]) / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]]
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{+128}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(\frac{c \cdot 2}{\frac{b}{a}} - b\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.95 \cdot 10^{+29}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\left(b + \mathsf{hypot}\left(b, {\left(\sqrt[3]{a \cdot -4} \cdot \sqrt[3]{c}\right)}^{1.5}\right)\right) \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-\left(b + b\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -3.7999999999999999e128Initial program 46.4%
Taylor expanded in b around inf 46.4%
Simplified46.4%
[Start]46.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + -2 \cdot \frac{c \cdot a}{b}\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
|---|---|
*-commutative [=>]46.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + \color{blue}{\frac{c \cdot a}{b} \cdot -2}\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
associate-/l* [=>]46.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + \color{blue}{\frac{c}{\frac{b}{a}}} \cdot -2\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
associate-*l/ [=>]46.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + \color{blue}{\frac{c \cdot -2}{\frac{b}{a}}}\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
Taylor expanded in b around -inf 90.1%
Simplified96.6%
[Start]90.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + \frac{c \cdot -2}{\frac{b}{a}}\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{c \cdot a}{b} + -2 \cdot b}\\
\end{array}
\] |
|---|---|
fma-def [=>]90.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + \frac{c \cdot -2}{\frac{b}{a}}\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\color{blue}{\frac{2 \cdot c}{\mathsf{fma}\left(2, \frac{c \cdot a}{b}, -2 \cdot b\right)}}\\
\end{array}
\] |
associate-/l* [=>]96.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + \frac{c \cdot -2}{\frac{b}{a}}\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\color{blue}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -2 \cdot b\right)}}\\
\end{array}
\] |
*-commutative [=>]96.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + \frac{c \cdot -2}{\frac{b}{a}}\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}\\
\end{array}
\] |
if -3.7999999999999999e128 < b < 1.94999999999999984e29Initial program 86.1%
Simplified85.9%
[Start]86.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
|---|
Applied egg-rr68.1%
[Start]85.9 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
|---|---|
expm1-log1p-u [=>]84.9 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)}\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
expm1-udef [=>]70.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)}\right)} - 1\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
fma-udef [=>]70.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \left(e^{\mathsf{log1p}\left(\sqrt{\color{blue}{b \cdot b + a \cdot \left(c \cdot -4\right)}}\right)} - 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
add-sqr-sqrt [=>]68.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \left(e^{\mathsf{log1p}\left(\sqrt{b \cdot b + \color{blue}{\sqrt{a \cdot \left(c \cdot -4\right)} \cdot \sqrt{a \cdot \left(c \cdot -4\right)}}}\right)} - 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
hypot-def [=>]68.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \left(e^{\mathsf{log1p}\left(\color{blue}{\mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)}\right)} - 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
Simplified82.5%
[Start]68.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \left(e^{\mathsf{log1p}\left(\mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right)} - 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
|---|---|
expm1-def [=>]81.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
expm1-log1p [=>]82.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \color{blue}{\mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
associate-*r* [=>]82.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(a \cdot c\right) \cdot -4}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
*-commutative [<=]82.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(c \cdot a\right)} \cdot -4}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
associate-*l* [=>]82.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \sqrt{\color{blue}{c \cdot \left(a \cdot -4\right)}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
Applied egg-rr82.3%
[Start]82.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
|---|---|
add-cube-cbrt [=>]82.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)} \cdot \sqrt[3]{c \cdot \left(a \cdot -4\right)}\right) \cdot \sqrt[3]{c \cdot \left(a \cdot -4\right)}}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
sqrt-prod [=>]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \color{blue}{\sqrt{\sqrt[3]{c \cdot \left(a \cdot -4\right)} \cdot \sqrt[3]{c \cdot \left(a \cdot -4\right)}} \cdot \sqrt{\sqrt[3]{c \cdot \left(a \cdot -4\right)}}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
pow2 [=>]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \sqrt{\color{blue}{{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{2}}} \cdot \sqrt{\sqrt[3]{c \cdot \left(a \cdot -4\right)}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
Simplified82.4%
[Start]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \sqrt{{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{2}} \cdot \sqrt{\sqrt[3]{c \cdot \left(a \cdot -4\right)}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
|---|---|
*-commutative [=>]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \color{blue}{\sqrt{\sqrt[3]{c \cdot \left(a \cdot -4\right)}} \cdot \sqrt{{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{2}}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
unpow1/2 [<=]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \color{blue}{{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5}} \cdot \sqrt{{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{2}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
sqr-pow [=>]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5} \cdot \sqrt{\color{blue}{{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{\left(\frac{2}{2}\right)} \cdot {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{\left(\frac{2}{2}\right)}}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
rem-sqrt-square [=>]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5} \cdot \color{blue}{\left|{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{\left(\frac{2}{2}\right)}\right|}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
metadata-eval [=>]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5} \cdot \left|{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{\color{blue}{1}}\right|\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
metadata-eval [<=]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5} \cdot \left|{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{\color{blue}{\left(2 \cdot 0.5\right)}}\right|\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
pow-sqr [<=]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5} \cdot \left|\color{blue}{{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5} \cdot {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5}}\right|\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
fabs-sqr [=>]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5} \cdot \color{blue}{\left({\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5} \cdot {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5}\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
pow-sqr [=>]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5} \cdot \color{blue}{{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{\left(2 \cdot 0.5\right)}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
metadata-eval [=>]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5} \cdot {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{\color{blue}{1}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
unpow1 [=>]82.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{0.5} \cdot \color{blue}{\sqrt[3]{c \cdot \left(a \cdot -4\right)}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
pow-plus [=>]82.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, \color{blue}{{\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{\left(0.5 + 1\right)}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
metadata-eval [=>]82.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{\color{blue}{1.5}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
Applied egg-rr85.0%
[Start]82.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\left(\sqrt[3]{c \cdot \left(a \cdot -4\right)}\right)}^{1.5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
|---|---|
cbrt-prod [=>]85.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\color{blue}{\left(\sqrt[3]{c} \cdot \sqrt[3]{a \cdot -4}\right)}}^{1.5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
*-commutative [=>]85.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \mathsf{hypot}\left(b, {\color{blue}{\left(\sqrt[3]{a \cdot -4} \cdot \sqrt[3]{c}\right)}}^{1.5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
if 1.94999999999999984e29 < b Initial program 45.5%
Taylor expanded in b around inf 90.2%
Taylor expanded in c around 0 90.2%
Simplified90.2%
[Start]90.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\end{array}
\] |
|---|---|
mul-1-neg [=>]90.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{b}{a}\\
\end{array}
\] |
distribute-neg-frac [=>]90.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\] |
Final simplification88.5%
| Alternative 1 | |
|---|---|
| Accuracy | 87.8% |
| Cost | 38052 |
| Alternative 2 | |
|---|---|
| Accuracy | 87.5% |
| Cost | 38052 |
| Alternative 3 | |
|---|---|
| Accuracy | 77.3% |
| Cost | 7756 |
| Alternative 4 | |
|---|---|
| Accuracy | 77.4% |
| Cost | 7624 |
| Alternative 5 | |
|---|---|
| Accuracy | 72.4% |
| Cost | 7496 |
| Alternative 6 | |
|---|---|
| Accuracy | 71.7% |
| Cost | 7368 |
| Alternative 7 | |
|---|---|
| Accuracy | 72.2% |
| Cost | 7368 |
| Alternative 8 | |
|---|---|
| Accuracy | 29.3% |
| Cost | 644 |
| Alternative 9 | |
|---|---|
| Accuracy | 64.7% |
| Cost | 644 |
herbie shell --seed 2023138
(FPCore (a b c)
:name "jeff quadratic root 1"
:precision binary64
(if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))