| Alternative 1 | |
|---|---|
| Accuracy | 89.2% |
| 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
(let* ((t_0 (cbrt (* c -4.0))) (t_1 (sqrt (+ (* b b) (* -4.0 (* c a))))))
(if (<= b -9e+134)
(if (>= b 0.0) (/ c b) (/ (- c) b))
(if (<= b 2.9e-172)
(if (>= b 0.0)
(/
1.0
(* (* a -2.0) (/ 1.0 (+ b (hypot b (* t_0 (sqrt (* a t_0))))))))
(* c (/ 2.0 (- (sqrt (fma b b (* a (* c -4.0)))) b))))
(if (<= b 1e+140)
(if (>= b 0.0) (/ (- (- b) t_1) (* a 2.0)) (/ (* c 2.0) (- t_1 b)))
(if (>= b 0.0) (- (/ c b) (/ b a)) (/ 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 t_0 = cbrt((c * -4.0));
double t_1 = sqrt(((b * b) + (-4.0 * (c * a))));
double tmp_1;
if (b <= -9e+134) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 2.9e-172) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 1.0 / ((a * -2.0) * (1.0 / (b + hypot(b, (t_0 * sqrt((a * t_0)))))));
} else {
tmp_3 = c * (2.0 / (sqrt(fma(b, b, (a * (c * -4.0)))) - b));
}
tmp_1 = tmp_3;
} else if (b <= 1e+140) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - t_1) / (a * 2.0);
} else {
tmp_4 = (c * 2.0) / (t_1 - b);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} 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) t_0 = cbrt(Float64(c * -4.0)) t_1 = sqrt(Float64(Float64(b * b) + Float64(-4.0 * Float64(c * a)))) tmp_1 = 0.0 if (b <= -9e+134) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / b); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= 2.9e-172) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(1.0 / Float64(Float64(a * -2.0) * Float64(1.0 / Float64(b + hypot(b, Float64(t_0 * sqrt(Float64(a * t_0)))))))); 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 <= 1e+140) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - t_1) / Float64(a * 2.0)); else tmp_4 = Float64(Float64(c * 2.0) / Float64(t_1 - b)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = 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_] := Block[{t$95$0 = N[Power[N[(c * -4.0), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -9e+134], If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], N[((-c) / b), $MachinePrecision]], If[LessEqual[b, 2.9e-172], If[GreaterEqual[b, 0.0], N[(1.0 / N[(N[(a * -2.0), $MachinePrecision] * N[(1.0 / N[(b + N[Sqrt[b ^ 2 + N[(t$95$0 * N[Sqrt[N[(a * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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[LessEqual[b, 1e+140], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$1), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * 2.0), $MachinePrecision] / N[(t$95$1 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $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}
t_0 := \sqrt[3]{c \cdot -4}\\
t_1 := \sqrt{b \cdot b + -4 \cdot \left(c \cdot a\right)}\\
\mathbf{if}\;b \leq -9 \cdot 10^{+134}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-172}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, t_0 \cdot \sqrt{a \cdot t_0}\right)}}\\
\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 \leq 10^{+140}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{t_1 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{a}\\
\end{array}
if b < -8.9999999999999995e134Initial program 45.7%
Taylor expanded in b around -inf 91.6%
Simplified97.8%
[Start]91.6 | \[ \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) + \left(2 \cdot \frac{c \cdot a}{b} + -1 \cdot b\right)}\\
\end{array}
\] |
|---|---|
fma-def [=>]91.6 | \[ \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}{\color{blue}{\left(-b\right) + \mathsf{fma}\left(2, \frac{c \cdot a}{b}, -1 \cdot b\right)}}\\
\end{array}
\] |
associate-/l* [=>]97.8 | \[ \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) + \color{blue}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -1 \cdot b\right)}}\\
\end{array}
\] |
mul-1-neg [=>]97.8 | \[ \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) + \mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right)}\\
\end{array}
\] |
Taylor expanded in b around inf 97.8%
Simplified97.8%
[Start]97.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot \frac{c \cdot a}{b} + -2 \cdot b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right)}\\
\end{array}
\] |
|---|---|
+-commutative [=>]97.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{-2 \cdot b + 2 \cdot \frac{c \cdot a}{b}}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right)}\\
\end{array}
\] |
*-commutative [=>]97.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{b \cdot -2} + 2 \cdot \frac{c \cdot a}{b}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right)}\\
\end{array}
\] |
fma-def [=>]97.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{\mathsf{fma}\left(b, -2, 2 \cdot \frac{c \cdot a}{b}\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right)}\\
\end{array}
\] |
associate-/l* [=>]97.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, -2, 2 \cdot \color{blue}{\frac{c}{\frac{b}{a}}}\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right)}\\
\end{array}
\] |
associate-*r/ [=>]97.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, -2, \color{blue}{\frac{2 \cdot c}{\frac{b}{a}}}\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right)}\\
\end{array}
\] |
Taylor expanded in b around 0 97.8%
Taylor expanded in c around 0 97.7%
Simplified97.7%
[Start]97.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\end{array}
\] |
|---|---|
associate-*r/ [=>]97.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot c}{b}\\
\end{array}
\] |
neg-mul-1 [<=]97.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\] |
if -8.9999999999999995e134 < b < 2.89999999999999997e-172Initial program 83.8%
Simplified83.7%
[Start]83.8 | \[ \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-rr84.7%
[Start]83.7 | \[ \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}
\] |
|---|---|
clear-num [=>]83.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{1}{\frac{a}{-0.5}}} \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}
\] |
associate-*l/ [=>]83.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{1 \cdot \left(b + \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)}\right)}{\frac{a}{-0.5}}}\\
\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-rr83.8%
[Start]84.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \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}
\] |
|---|---|
pow1/2 [=>]84.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, \color{blue}{{\left(a \cdot \left(c \cdot -4\right)\right)}^{0.5}}\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-to-exp [=>]83.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, \color{blue}{e^{\log \left(a \cdot \left(c \cdot -4\right)\right) \cdot 0.5}}\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-rr87.0%
[Start]83.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, e^{\log \left(a \cdot \left(c \cdot -4\right)\right) \cdot 0.5}\right)}}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}\\
\end{array}
\] |
|---|---|
exp-to-pow [=>]84.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, \color{blue}{{\left(a \cdot \left(c \cdot -4\right)\right)}^{0.5}}\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 [=>]84.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, \color{blue}{\sqrt{a \cdot \left(c \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 [=>]84.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(c \cdot -4\right) \cdot a}}\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 [=>]84.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(\left(\sqrt[3]{c \cdot -4} \cdot \sqrt[3]{c \cdot -4}\right) \cdot \sqrt[3]{c \cdot -4}\right)} \cdot a}\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* [=>]84.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(\sqrt[3]{c \cdot -4} \cdot \sqrt[3]{c \cdot -4}\right) \cdot \left(\sqrt[3]{c \cdot -4} \cdot a\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 [=>]87.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, \color{blue}{\sqrt{\sqrt[3]{c \cdot -4} \cdot \sqrt[3]{c \cdot -4}} \cdot \sqrt{\sqrt[3]{c \cdot -4} \cdot a}}\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 [=>]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, \color{blue}{\left(\sqrt{\sqrt[3]{c \cdot -4}} \cdot \sqrt{\sqrt[3]{c \cdot -4}}\right)} \cdot \sqrt{\sqrt[3]{c \cdot -4} \cdot a}\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 [<=]87.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, \color{blue}{\sqrt[3]{c \cdot -4}} \cdot \sqrt{\sqrt[3]{c \cdot -4} \cdot a}\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 [=>]87.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\left(a \cdot -2\right) \cdot \frac{1}{b + \mathsf{hypot}\left(b, \sqrt[3]{c \cdot -4} \cdot \sqrt{\color{blue}{a \cdot \sqrt[3]{c \cdot -4}}}\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 2.89999999999999997e-172 < b < 1.00000000000000006e140Initial program 91.3%
Simplified91.4%
[Start]91.3 | \[ \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}
\] |
|---|---|
associate-*l* [=>]91.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \color{blue}{4 \cdot \left(a \cdot c\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 [=>]91.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{\color{blue}{a \cdot 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
*-commutative [=>]91.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
associate-*l* [=>]91.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\\
\end{array}
\] |
if 1.00000000000000006e140 < b Initial program 8.4%
Taylor expanded in b around -inf 8.4%
Simplified8.4%
[Start]8.4 | \[ \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) + \left(2 \cdot \frac{c \cdot a}{b} + -1 \cdot b\right)}\\
\end{array}
\] |
|---|---|
fma-def [=>]8.4 | \[ \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}{\color{blue}{\left(-b\right) + \mathsf{fma}\left(2, \frac{c \cdot a}{b}, -1 \cdot b\right)}}\\
\end{array}
\] |
associate-/l* [=>]8.4 | \[ \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) + \color{blue}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -1 \cdot b\right)}}\\
\end{array}
\] |
mul-1-neg [=>]8.4 | \[ \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) + \mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right)}\\
\end{array}
\] |
Taylor expanded in c around inf 8.4%
Taylor expanded in b around inf 96.4%
Simplified96.4%
[Start]96.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} + -1 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{a}\\
\end{array}
\] |
|---|---|
mul-1-neg [=>]96.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} + \color{blue}{\left(-\frac{b}{a}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{a}\\
\end{array}
\] |
unsub-neg [=>]96.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{c}{b} - \frac{b}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{a}\\
\end{array}
\] |
Final simplification91.4%
| Alternative 1 | |
|---|---|
| Accuracy | 89.2% |
| Cost | 38052 |
| Alternative 2 | |
|---|---|
| Accuracy | 89.1% |
| Cost | 38052 |
| Alternative 3 | |
|---|---|
| Accuracy | 88.9% |
| Cost | 38052 |
| Alternative 4 | |
|---|---|
| Accuracy | 89.0% |
| Cost | 38052 |
| Alternative 5 | |
|---|---|
| Accuracy | 91.4% |
| Cost | 27148 |
| Alternative 6 | |
|---|---|
| Accuracy | 90.0% |
| Cost | 7820 |
| Alternative 7 | |
|---|---|
| Accuracy | 77.1% |
| Cost | 7624 |
| Alternative 8 | |
|---|---|
| Accuracy | 65.0% |
| Cost | 7428 |
| Alternative 9 | |
|---|---|
| Accuracy | 64.7% |
| Cost | 644 |
| Alternative 10 | |
|---|---|
| Accuracy | 64.8% |
| Cost | 520 |
| Alternative 11 | |
|---|---|
| Accuracy | 38.0% |
| Cost | 388 |
| Alternative 12 | |
|---|---|
| Accuracy | 3.5% |
| Cost | 324 |
herbie shell --seed 2023135
(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)))))))