| Alternative 1 | |
|---|---|
| Accuracy | 88.4% |
| Cost | 42972 |
(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))
(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))))
(t_3 (/ (* c 2.0) t_0)))
(if (<= t_2 (- INFINITY))
(if (>= b 0.0) (- (/ c b) (/ b a)) t_3)
(if (<= t_2 -2e-213)
t_2
(if (<= t_2 0.0)
(if (>= b 0.0)
(/ 0.5 (/ a (- b (hypot b (* (sqrt (* c -4.0)) (sqrt a))))))
t_3)
(if (<= t_2 2e+212)
t_2
(if (>= b 0.0)
(/ t_0 (* a 2.0))
(*
(- b (hypot b (sqrt (* -4.0 (* a c)))))
(/ (+ c c) (fma c (* 4.0 a) (* b (+ b 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;
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 t_3 = (c * 2.0) / t_0;
double tmp_2;
if (t_2 <= -((double) INFINITY)) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c / b) - (b / a);
} else {
tmp_3 = t_3;
}
tmp_2 = tmp_3;
} else if (t_2 <= -2e-213) {
tmp_2 = t_2;
} else if (t_2 <= 0.0) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = 0.5 / (a / (b - hypot(b, (sqrt((c * -4.0)) * sqrt(a)))));
} else {
tmp_4 = t_3;
}
tmp_2 = tmp_4;
} else if (t_2 <= 2e+212) {
tmp_2 = t_2;
} else if (b >= 0.0) {
tmp_2 = t_0 / (a * 2.0);
} else {
tmp_2 = (b - hypot(b, sqrt((-4.0 * (a * c))))) * ((c + c) / fma(c, (4.0 * a), (b * (b + 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(-b) - b) 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 t_3 = Float64(Float64(c * 2.0) / t_0) tmp_2 = 0.0 if (t_2 <= Float64(-Inf)) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c / b) - Float64(b / a)); else tmp_3 = t_3; end tmp_2 = tmp_3; elseif (t_2 <= -2e-213) tmp_2 = t_2; elseif (t_2 <= 0.0) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(0.5 / Float64(a / Float64(b - hypot(b, Float64(sqrt(Float64(c * -4.0)) * sqrt(a)))))); else tmp_4 = t_3; end tmp_2 = tmp_4; elseif (t_2 <= 2e+212) tmp_2 = t_2; elseif (b >= 0.0) tmp_2 = Float64(t_0 / Float64(a * 2.0)); else tmp_2 = Float64(Float64(b - hypot(b, sqrt(Float64(-4.0 * Float64(a * c))))) * Float64(Float64(c + c) / fma(c, Float64(4.0 * a), Float64(b * Float64(b + 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[((-b) - b), $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]]}, Block[{t$95$3 = N[(N[(c * 2.0), $MachinePrecision] / t$95$0), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], t$95$3], If[LessEqual[t$95$2, -2e-213], t$95$2, If[LessEqual[t$95$2, 0.0], If[GreaterEqual[b, 0.0], N[(0.5 / N[(a / N[(b - N[Sqrt[b ^ 2 + N[(N[Sqrt[N[(c * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[a], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3], If[LessEqual[t$95$2, 2e+212], t$95$2, If[GreaterEqual[b, 0.0], N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[Sqrt[b ^ 2 + N[Sqrt[N[(-4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(c + c), $MachinePrecision] / N[(c * N[(4.0 * a), $MachinePrecision] + N[(b * N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 := \left(-b\right) - b\\
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}\\
t_3 := \frac{c \cdot 2}{t_0}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}\\
\mathbf{elif}\;t_2 \leq -2 \cdot 10^{-213}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{\frac{a}{b - \mathsf{hypot}\left(b, \sqrt{c \cdot -4} \cdot \sqrt{a}\right)}}\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+212}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{-4 \cdot \left(a \cdot c\right)}\right)\right) \cdot \frac{c + c}{\mathsf{fma}\left(c, 4 \cdot a, b \cdot \left(b + b\right)\right)}\\
\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)))))) < -inf.0Initial program 0.0%
Taylor expanded in b around -inf 0.0%
Taylor expanded in b around inf 71.8%
Simplified71.8%
[Start]71.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} + -1 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
|---|---|
mul-1-neg [=>]71.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} + \color{blue}{\left(-\frac{b}{a}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
unsub-neg [=>]71.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{c}{b} - \frac{b}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
if -inf.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)))))) < -1.9999999999999999e-213 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)))))) < 1.9999999999999998e212Initial program 96.0%
if -1.9999999999999999e-213 < (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 47.1%
Taylor expanded in b around -inf 83.0%
Applied egg-rr82.6%
[Start]83.0 | \[ \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) + -1 \cdot b}\\
\end{array}
\] |
|---|---|
clear-num [=>]83.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{1}{\frac{2 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
inv-pow [=>]83.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{{\left(\frac{2 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
Applied egg-rr82.6%
[Start]82.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;{\left(2 \cdot \frac{a}{b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
|---|---|
unpow-1 [=>]82.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{1}{2 \cdot \frac{a}{b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
associate-/r* [=>]82.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{\frac{1}{2}}{\frac{a}{b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
metadata-eval [=>]82.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{0.5}}{\frac{a}{b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
*-commutative [=>]82.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{\frac{a}{b - \mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(a \cdot -4\right) \cdot c}}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
associate-*l* [=>]82.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{\frac{a}{b - \mathsf{hypot}\left(b, \sqrt{\color{blue}{a \cdot \left(-4 \cdot c\right)}}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
Applied egg-rr82.6%
[Start]82.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{\frac{a}{b - \mathsf{hypot}\left(b, \sqrt{a \cdot \left(-4 \cdot c\right)}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
|---|---|
*-commutative [=>]82.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{\frac{a}{b - \mathsf{hypot}\left(b, \sqrt{\color{blue}{\left(-4 \cdot c\right) \cdot a}}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
sqrt-prod [=>]82.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{\frac{a}{b - \mathsf{hypot}\left(b, \color{blue}{\sqrt{-4 \cdot c} \cdot \sqrt{a}}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
Simplified82.6%
[Start]82.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{\frac{a}{b - \mathsf{hypot}\left(b, \sqrt{-4 \cdot c} \cdot \sqrt{a}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
|---|---|
*-commutative [=>]82.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{0.5}{\frac{a}{b - \mathsf{hypot}\left(b, \sqrt{\color{blue}{c \cdot -4}} \cdot \sqrt{a}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + -1 \cdot b}\\
\end{array}
\] |
if 1.9999999999999998e212 < (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 25.0%
Taylor expanded in b around inf 69.4%
Applied egg-rr68.5%
[Start]69.4 | \[ \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-+ [=>]68.6 | \[ \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/ [=>]68.6 | \[ \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}
\] |
Simplified68.5%
[Start]68.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 [=>]68.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* [=>]68.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}
\] |
rem-square-sqrt [<=]65.3 | \[ \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 \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 [<=]65.3 | \[ \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 {\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}
\] |
*-commutative [=>]65.3 | \[ \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(\sqrt{-4}\right)}^{2} \cdot \left(c \cdot a\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 [=>]65.3 | \[ \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(\sqrt{-4} \cdot \sqrt{-4}\right) \cdot \left(c \cdot a\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 [=>]68.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{-4 \cdot \left(c \cdot a\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}
\] |
*-commutative [=>]68.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{-4 \cdot \left(a \cdot c\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}
\] |
+-commutative [=>]68.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{-4 \cdot \left(a \cdot c\right)}\right)\right) \cdot \color{blue}{\frac{c + c}{c \cdot \left(4 \cdot a\right) + \mathsf{fma}\left(b, b, b \cdot b\right)}}\\
\end{array}
\] |
fma-def [=>]68.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{-4 \cdot \left(a \cdot c\right)}\right)\right) \cdot \color{blue}{\frac{c + c}{\mathsf{fma}\left(c, 4 \cdot a, \mathsf{fma}\left(b, b, b \cdot b\right)\right)}}\\
\end{array}
\] |
*-commutative [=>]68.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{-4 \cdot \left(a \cdot c\right)}\right)\right) \cdot \frac{c + c}{\color{blue}{\mathsf{fma}\left(c, a \cdot 4, \mathsf{fma}\left(b, b, b \cdot b\right)\right)}}\\
\end{array}
\] |
fma-udef [=>]68.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{-4 \cdot \left(a \cdot c\right)}\right)\right) \cdot \frac{c + c}{\mathsf{fma}\left(c, a \cdot 4, b \cdot b + b \cdot b\right)}\\
\end{array}
\] |
distribute-lft-out [=>]68.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{-4 \cdot \left(a \cdot c\right)}\right)\right) \cdot \frac{c + c}{\mathsf{fma}\left(c, a \cdot 4, b \cdot \left(b + b\right)\right)}\\
\end{array}
\] |
Final simplification88.0%
| Alternative 1 | |
|---|---|
| Accuracy | 88.4% |
| Cost | 42972 |
| Alternative 2 | |
|---|---|
| Accuracy | 88.6% |
| Cost | 38052 |
| Alternative 3 | |
|---|---|
| Accuracy | 88.7% |
| Cost | 38052 |
| Alternative 4 | |
|---|---|
| Accuracy | 84.1% |
| Cost | 7756 |
| Alternative 5 | |
|---|---|
| Accuracy | 78.9% |
| Cost | 7696 |
| Alternative 6 | |
|---|---|
| Accuracy | 71.5% |
| Cost | 7368 |
| Alternative 7 | |
|---|---|
| Accuracy | 64.5% |
| Cost | 1092 |
| Alternative 8 | |
|---|---|
| Accuracy | 64.6% |
| Cost | 1092 |
| Alternative 9 | |
|---|---|
| Accuracy | 29.5% |
| Cost | 644 |
| Alternative 10 | |
|---|---|
| Accuracy | 64.2% |
| Cost | 644 |
herbie shell --seed 2023146
(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)))))))