| Alternative 1 | |
|---|---|
| Accuracy | 81.9% |
| 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 (/ (- (- b) b) (* a 2.0)))
(t_1 (sqrt (- (* b b) (* (* 4.0 a) c))))
(t_2
(if (>= b 0.0) (/ (- (- b) t_1) (* a 2.0)) (/ (* c 2.0) (- t_1 b)))))
(if (<= t_2 -1e+228)
(if (>= b 0.0)
t_0
(*
(- b (hypot b (sqrt (* a (* c -4.0)))))
(/ 2.0 (/ (fma c (* 4.0 a) (* b (+ b b))) c))))
(if (<= t_2 -2e-283)
t_2
(if (<= t_2 0.0)
(if (>= b 0.0)
(/ (/ (* c (* a -2.0)) b) (* a 2.0))
(/ (* c 2.0) (- (fma 2.0 (/ c (/ b a)) (- b)) b)))
(if (<= t_2 5e+269) t_2 (if (>= b 0.0) t_0 (/ (- c) b))))))))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 = (-b - b) / (a * 2.0);
double t_1 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_1) / (a * 2.0);
} else {
tmp = (c * 2.0) / (t_1 - b);
}
double t_2 = tmp;
double tmp_2;
if (t_2 <= -1e+228) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = (b - hypot(b, sqrt((a * (c * -4.0))))) * (2.0 / (fma(c, (4.0 * a), (b * (b + b))) / c));
}
tmp_2 = tmp_3;
} else if (t_2 <= -2e-283) {
tmp_2 = t_2;
} else if (t_2 <= 0.0) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = ((c * (a * -2.0)) / b) / (a * 2.0);
} else {
tmp_4 = (c * 2.0) / (fma(2.0, (c / (b / a)), -b) - b);
}
tmp_2 = tmp_4;
} else if (t_2 <= 5e+269) {
tmp_2 = t_2;
} else if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = -c / b;
}
return tmp_2;
}
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 = Float64(Float64(Float64(-b) - b) / Float64(a * 2.0)) t_1 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_1) / Float64(a * 2.0)); else tmp = Float64(Float64(c * 2.0) / Float64(t_1 - b)); end t_2 = tmp tmp_2 = 0.0 if (t_2 <= -1e+228) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_0; else tmp_3 = Float64(Float64(b - hypot(b, sqrt(Float64(a * Float64(c * -4.0))))) * Float64(2.0 / Float64(fma(c, Float64(4.0 * a), Float64(b * Float64(b + b))) / c))); end tmp_2 = tmp_3; elseif (t_2 <= -2e-283) tmp_2 = t_2; elseif (t_2 <= 0.0) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(c * Float64(a * -2.0)) / b) / Float64(a * 2.0)); else tmp_4 = Float64(Float64(c * 2.0) / Float64(fma(2.0, Float64(c / Float64(b / a)), Float64(-b)) - b)); end tmp_2 = tmp_4; elseif (t_2 <= 5e+269) tmp_2 = t_2; elseif (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(Float64(-c) / b); end return tmp_2 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[(N[((-b) - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = 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[LessEqual[t$95$2, -1e+228], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(b - N[Sqrt[b ^ 2 + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(2.0 / N[(N[(c * N[(4.0 * a), $MachinePrecision] + N[(b * N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[t$95$2, -2e-283], t$95$2, If[LessEqual[t$95$2, 0.0], If[GreaterEqual[b, 0.0], N[(N[(N[(c * N[(a * -2.0), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * 2.0), $MachinePrecision] / N[(N[(2.0 * N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision] + (-b)), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[t$95$2, 5e+269], t$95$2, If[GreaterEqual[b, 0.0], t$95$0, N[((-c) / b), $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 := \frac{\left(-b\right) - b}{a \cdot 2}\\
t_1 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
t_2 := \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{if}\;t_2 \leq -1 \cdot 10^{+228}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right) \cdot \frac{2}{\frac{\mathsf{fma}\left(c, 4 \cdot a, b \cdot \left(b + b\right)\right)}{c}}\\
\end{array}\\
\mathbf{elif}\;t_2 \leq -2 \cdot 10^{-283}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\frac{c \cdot \left(a \cdot -2\right)}{b}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -b\right) - b}\\
\end{array}\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+269}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
if (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < -9.9999999999999992e227Initial program 17.0%
Taylor expanded in b around inf 49.1%
Applied egg-rr48.5%
[Start]49.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{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}
\] |
|---|---|
flip-+ [=>]48.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\color{blue}{\frac{2 \cdot c}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\\
\end{array}
\] |
associate-/r/ [=>]48.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)\\
\end{array}
\] |
Simplified48.5%
[Start]48.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c + c}{\mathsf{fma}\left(b, b, b \cdot b\right) + c \cdot \left(4 \cdot a\right)} \cdot \left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)\right)\\
\end{array}
\] |
|---|---|
*-commutative [=>]48.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)\right) \cdot \frac{c + c}{\mathsf{fma}\left(b, b, b \cdot b\right) + c \cdot \left(4 \cdot a\right)}\\
\end{array}
\] |
associate-*r* [=>]48.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{\left(c \cdot a\right) \cdot -4}\right)\right) \cdot \frac{c + c}{\mathsf{fma}\left(b, b, b \cdot b\right) + c \cdot \left(4 \cdot a\right)}\\
\end{array}
\] |
*-commutative [=>]48.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{\left(a \cdot c\right) \cdot -4}\right)\right) \cdot \frac{c + c}{\mathsf{fma}\left(b, b, b \cdot b\right) + c \cdot \left(4 \cdot a\right)}\\
\end{array}
\] |
rem-square-sqrt [<=]46.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{\left(a \cdot c\right) \cdot \left(\sqrt{-4} \cdot \sqrt{-4}\right)}\right)\right) \cdot \frac{c + c}{\mathsf{fma}\left(b, b, b \cdot b\right) + c \cdot \left(4 \cdot a\right)}\\
\end{array}
\] |
unpow2 [<=]46.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{\left(a \cdot c\right) \cdot {\left(\sqrt{-4}\right)}^{2}}\right)\right) \cdot \frac{c + c}{\mathsf{fma}\left(b, b, b \cdot b\right) + c \cdot \left(4 \cdot a\right)}\\
\end{array}
\] |
associate-*l* [=>]46.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot {\left(\sqrt{-4}\right)}^{2}\right)}\right)\right) \cdot \frac{c + c}{\mathsf{fma}\left(b, b, b \cdot b\right) + c \cdot \left(4 \cdot a\right)}\\
\end{array}
\] |
unpow2 [=>]46.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot \left(\sqrt{-4} \cdot \sqrt{-4}\right)\right)}\right)\right) \cdot \frac{c + c}{\mathsf{fma}\left(b, b, b \cdot b\right) + c \cdot \left(4 \cdot a\right)}\\
\end{array}
\] |
rem-square-sqrt [=>]48.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right) \cdot \frac{c + c}{\mathsf{fma}\left(b, b, b \cdot b\right) + c \cdot \left(4 \cdot a\right)}\\
\end{array}
\] |
count-2 [=>]48.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\color{blue}{\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right)} \cdot \frac{2 \cdot c}{\mathsf{fma}\left(b, b, b \cdot b\right) + c \cdot \left(4 \cdot a\right)}\\
\end{array}
\] |
associate-/l* [=>]48.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\color{blue}{\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right) \cdot \frac{2}{\frac{\mathsf{fma}\left(b, b, b \cdot b\right) + c \cdot \left(4 \cdot a\right)}{c}}}\\
\end{array}
\] |
+-commutative [=>]48.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right) \cdot \frac{\color{blue}{2}}{\frac{c \cdot \left(4 \cdot a\right) + \mathsf{fma}\left(b, b, b \cdot b\right)}{c}}\\
\end{array}
\] |
fma-def [=>]48.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right) \cdot \frac{\color{blue}{2}}{\frac{\mathsf{fma}\left(c, 4 \cdot a, \mathsf{fma}\left(b, b, b \cdot b\right)\right)}{c}}\\
\end{array}
\] |
*-commutative [=>]48.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right) \cdot \frac{2}{\frac{\mathsf{fma}\left(c, a \cdot 4, \mathsf{fma}\left(b, b, b \cdot b\right)\right)}{c}}\\
\end{array}
\] |
fma-udef [=>]48.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right) \cdot \frac{2}{\frac{\mathsf{fma}\left(c, a \cdot 4, b \cdot b + b \cdot b\right)}{c}}\\
\end{array}
\] |
distribute-lft-out [=>]48.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)\right) \cdot \frac{2}{\frac{\mathsf{fma}\left(c, a \cdot 4, b \cdot \left(b + b\right)\right)}{c}}\\
\end{array}
\] |
if -9.9999999999999992e227 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < -1.99999999999999989e-283 or 0.0 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < 5.0000000000000002e269Initial program 95.5%
if -1.99999999999999989e-283 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) < 0.0Initial program 42.7%
Taylor expanded in b around -inf 42.4%
Simplified42.4%
[Start]42.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-2 \cdot \frac{c \cdot a}{b}}{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-*r/ [=>]42.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{\frac{-2 \cdot \left(c \cdot a\right)}{b}}}{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 [<=]42.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\frac{-2 \cdot \color{blue}{\left(a \cdot c\right)}}{b}}{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-*r* [=>]42.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\frac{\color{blue}{\left(-2 \cdot a\right) \cdot c}}{b}}{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 80.1%
Simplified82.5%
[Start]80.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\frac{\left(-2 \cdot a\right) \cdot c}{b}}{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 [=>]80.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\frac{\left(-2 \cdot a\right) \cdot c}{b}}{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* [=>]82.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\frac{\left(-2 \cdot a\right) \cdot c}{b}}{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 [=>]82.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\frac{\left(-2 \cdot a\right) \cdot c}{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}
\] |
if 5.0000000000000002e269 < (if (>=.f64 b 0) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a)) (/.f64 (*.f64 2 c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))))) Initial program 6.0%
Taylor expanded in b around inf 48.0%
Taylor expanded in b around -inf 52.0%
Simplified52.0%
[Start]52.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\end{array}
\] |
|---|---|
associate-*r/ [=>]52.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot c}{b}\\
\end{array}
\] |
mul-1-neg [=>]52.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\] |
Final simplification81.5%
| Alternative 1 | |
|---|---|
| Accuracy | 81.9% |
| Cost | 38052 |
| Alternative 2 | |
|---|---|
| Accuracy | 81.3% |
| Cost | 7820 |
| Alternative 3 | |
|---|---|
| Accuracy | 77.4% |
| Cost | 7756 |
| Alternative 4 | |
|---|---|
| Accuracy | 72.7% |
| Cost | 7696 |
| Alternative 5 | |
|---|---|
| Accuracy | 72.8% |
| Cost | 7696 |
| Alternative 6 | |
|---|---|
| Accuracy | 66.2% |
| Cost | 7368 |
| Alternative 7 | |
|---|---|
| Accuracy | 26.5% |
| Cost | 644 |
| Alternative 8 | |
|---|---|
| Accuracy | 59.3% |
| Cost | 644 |
| Alternative 9 | |
|---|---|
| Accuracy | 1.1% |
| Cost | 580 |
herbie shell --seed 2023153
(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)))))))