| Alternative 1 | |
|---|---|
| Error | 15.3 |
| Cost | 7756 |
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0.0) (/ b a) (/ (- b) a)))
(t_1 (sqrt (+ (* b b) (* c (* a -4.0)))))
(t_2
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_1)) (/ (- t_1 b) (* 2.0 a)))))
(if (<= t_2 (- INFINITY))
t_0
(if (<= t_2 -1e-192)
t_2
(if (<= t_2 0.0)
(if (>= b 0.0)
(/ (* 2.0 c) (- (* (* 2.0 a) (/ c b)) (+ b b)))
(/ (/ (* c -2.0) (/ b a)) (* 2.0 a)))
(if (<= t_2 5e+251) t_2 t_0))))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - sqrt(((b * b) - ((4.0 * a) * c))));
} else {
tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
return tmp;
}
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = b / a;
} else {
tmp = -b / a;
}
double t_0 = tmp;
double t_1 = sqrt(((b * b) + (c * (a * -4.0))));
double tmp_1;
if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - t_1);
} else {
tmp_1 = (t_1 - b) / (2.0 * a);
}
double t_2 = tmp_1;
double tmp_2;
if (t_2 <= -((double) INFINITY)) {
tmp_2 = t_0;
} else if (t_2 <= -1e-192) {
tmp_2 = t_2;
} else if (t_2 <= 0.0) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (((2.0 * a) * (c / b)) - (b + b));
} else {
tmp_3 = ((c * -2.0) / (b / a)) / (2.0 * a);
}
tmp_2 = tmp_3;
} else if (t_2 <= 5e+251) {
tmp_2 = t_2;
} else {
tmp_2 = t_0;
}
return tmp_2;
}
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - Math.sqrt(((b * b) - ((4.0 * a) * c))));
} else {
tmp = (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
return tmp;
}
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = b / a;
} else {
tmp = -b / a;
}
double t_0 = tmp;
double t_1 = Math.sqrt(((b * b) + (c * (a * -4.0))));
double tmp_1;
if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - t_1);
} else {
tmp_1 = (t_1 - b) / (2.0 * a);
}
double t_2 = tmp_1;
double tmp_2;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp_2 = t_0;
} else if (t_2 <= -1e-192) {
tmp_2 = t_2;
} else if (t_2 <= 0.0) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (((2.0 * a) * (c / b)) - (b + b));
} else {
tmp_3 = ((c * -2.0) / (b / a)) / (2.0 * a);
}
tmp_2 = tmp_3;
} else if (t_2 <= 5e+251) {
tmp_2 = t_2;
} else {
tmp_2 = t_0;
}
return tmp_2;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - math.sqrt(((b * b) - ((4.0 * a) * c)))) else: tmp = (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a) return tmp
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = b / a else: tmp = -b / a t_0 = tmp t_1 = math.sqrt(((b * b) + (c * (a * -4.0)))) tmp_1 = 0 if b >= 0.0: tmp_1 = (2.0 * c) / (-b - t_1) else: tmp_1 = (t_1 - b) / (2.0 * a) t_2 = tmp_1 tmp_2 = 0 if t_2 <= -math.inf: tmp_2 = t_0 elif t_2 <= -1e-192: tmp_2 = t_2 elif t_2 <= 0.0: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) / (((2.0 * a) * (c / b)) - (b + b)) else: tmp_3 = ((c * -2.0) / (b / a)) / (2.0 * a) tmp_2 = tmp_3 elif t_2 <= 5e+251: tmp_2 = t_2 else: tmp_2 = t_0 return tmp_2
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))))); else tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)); end return tmp end
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(b / a); else tmp = Float64(Float64(-b) / a); end t_0 = tmp t_1 = sqrt(Float64(Float64(b * b) + Float64(c * Float64(a * -4.0)))) tmp_1 = 0.0 if (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_1)); else tmp_1 = Float64(Float64(t_1 - b) / Float64(2.0 * a)); end t_2 = tmp_1 tmp_2 = 0.0 if (t_2 <= Float64(-Inf)) tmp_2 = t_0; elseif (t_2 <= -1e-192) tmp_2 = t_2; elseif (t_2 <= 0.0) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(Float64(2.0 * a) * Float64(c / b)) - Float64(b + b))); else tmp_3 = Float64(Float64(Float64(c * -2.0) / Float64(b / a)) / Float64(2.0 * a)); end tmp_2 = tmp_3; elseif (t_2 <= 5e+251) tmp_2 = t_2; else tmp_2 = t_0; end return tmp_2 end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - sqrt(((b * b) - ((4.0 * a) * c)))); else tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end tmp_2 = tmp; end
function tmp_5 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = b / a; else tmp = -b / a; end t_0 = tmp; t_1 = sqrt(((b * b) + (c * (a * -4.0)))); tmp_2 = 0.0; if (b >= 0.0) tmp_2 = (2.0 * c) / (-b - t_1); else tmp_2 = (t_1 - b) / (2.0 * a); end t_2 = tmp_2; tmp_3 = 0.0; if (t_2 <= -Inf) tmp_3 = t_0; elseif (t_2 <= -1e-192) tmp_3 = t_2; elseif (t_2 <= 0.0) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) / (((2.0 * a) * (c / b)) - (b + b)); else tmp_4 = ((c * -2.0) / (b / a)) / (2.0 * a); end tmp_3 = tmp_4; elseif (t_2 <= 5e+251) tmp_3 = t_2; else tmp_3 = t_0; end tmp_5 = tmp_3; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], 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], 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]]
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[((-b) / a), $MachinePrecision]]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$2, (-Infinity)], t$95$0, If[LessEqual[t$95$2, -1e-192], t$95$2, If[LessEqual[t$95$2, 0.0], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(N[(N[(2.0 * a), $MachinePrecision] * N[(c / b), $MachinePrecision]), $MachinePrecision] - N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * -2.0), $MachinePrecision] / N[(b / a), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[t$95$2, 5e+251], t$95$2, t$95$0]]]]]]]
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}\\
t_1 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\
t_2 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_2 \leq -1 \cdot 10^{-192}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(2 \cdot a\right) \cdot \frac{c}{b} - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+251}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
Results
if (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < -inf.0 or 5.0000000000000005e251 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) Initial program 59.3
Taylor expanded in b around inf 59.8
Simplified57.4
[Start]59.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + -2 \cdot \frac{c \cdot a}{b}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
|---|---|
*-commutative [=>]59.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + \color{blue}{\frac{c \cdot a}{b} \cdot -2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
associate-/l* [=>]57.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + \color{blue}{\frac{c}{\frac{b}{a}}} \cdot -2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
associate-*l/ [=>]57.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + \color{blue}{\frac{c \cdot -2}{\frac{b}{a}}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
Taylor expanded in c around inf 60.0
Taylor expanded in b around -inf 19.9
Simplified19.9
[Start]19.9 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\end{array}
\] |
|---|---|
mul-1-neg [=>]19.9 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{b}{a}\\
\end{array}
\] |
distribute-neg-frac [=>]19.9 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\] |
if -inf.0 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < -1.0000000000000001e-192 or 0.0 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < 5.0000000000000005e251Initial program 2.9
Applied egg-rr16.0
Simplified21.7
[Start]16.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\frac{{b}^{4} - \left(c \cdot \left(a \cdot -4\right)\right) \cdot \left(c \cdot \left(a \cdot -4\right)\right)}{b \cdot b - c \cdot \left(a \cdot -4\right)}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
|---|---|
swap-sqr [=>]21.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\frac{{b}^{4} - \color{blue}{\left(c \cdot c\right) \cdot \left(\left(a \cdot -4\right) \cdot \left(a \cdot -4\right)\right)}}{b \cdot b - c \cdot \left(a \cdot -4\right)}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
Applied egg-rr2.9
if -1.0000000000000001e-192 < (if (>=.f64 b 0) (/.f64 (*.f64 2 c) (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c))))) (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 4 a) c)))) (*.f64 2 a))) < 0.0Initial program 31.9
Taylor expanded in b around inf 12.6
Simplified10.5
[Start]12.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + -2 \cdot \frac{c \cdot a}{b}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
|---|---|
*-commutative [=>]12.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + \color{blue}{\frac{c \cdot a}{b} \cdot -2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
associate-/l* [=>]10.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + \color{blue}{\frac{c}{\frac{b}{a}}} \cdot -2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
associate-*l/ [=>]10.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + \color{blue}{\frac{c \cdot -2}{\frac{b}{a}}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
Taylor expanded in b around inf 12.4
Simplified12.4
[Start]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + \frac{c \cdot -2}{\frac{b}{a}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{c \cdot a}{b}}{2 \cdot a}\\
\end{array}
\] |
|---|---|
*-commutative [=>]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + \frac{c \cdot -2}{\frac{b}{a}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot a}{b} \cdot -2}{2 \cdot a}\\
\end{array}
\] |
associate-/l* [=>]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + \frac{c \cdot -2}{\frac{b}{a}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c}{\frac{b}{a}} \cdot -2}{2 \cdot a}\\
\end{array}
\] |
associate-*l/ [=>]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + \frac{c \cdot -2}{\frac{b}{a}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
Applied egg-rr16.4
Simplified12.4
[Start]16.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(0 - e^{\mathsf{log1p}\left(b + \mathsf{fma}\left(c \cdot -2, \frac{a}{b}, b\right)\right)}\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
|---|---|
associate-+l- [=>]16.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\color{blue}{0 - \left(e^{\mathsf{log1p}\left(b + \mathsf{fma}\left(c \cdot -2, \frac{a}{b}, b\right)\right)} - 1\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
expm1-def [=>]15.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{0 - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(b + \mathsf{fma}\left(c \cdot -2, \frac{a}{b}, b\right)\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
expm1-log1p [=>]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{0 - \color{blue}{\left(b + \mathsf{fma}\left(c \cdot -2, \frac{a}{b}, b\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
+-commutative [<=]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{0 - \color{blue}{\left(\mathsf{fma}\left(c \cdot -2, \frac{a}{b}, b\right) + b\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
fma-udef [=>]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{0 - \left(\color{blue}{\left(\left(c \cdot -2\right) \cdot \frac{a}{b} + b\right)} + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
associate-+r+ [<=]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{0 - \color{blue}{\left(\left(c \cdot -2\right) \cdot \frac{a}{b} + \left(b + b\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
associate--r+ [=>]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(0 - \left(c \cdot -2\right) \cdot \frac{a}{b}\right) - \left(b + b\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
sub0-neg [=>]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(-\left(c \cdot -2\right) \cdot \frac{a}{b}\right)} - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
distribute-lft-neg-in [=>]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(-c \cdot -2\right) \cdot \frac{a}{b}} - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
associate-*r/ [=>]14.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\color{blue}{\frac{\left(-c \cdot -2\right) \cdot a}{b}} - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
*-commutative [=>]14.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\frac{\left(-\color{blue}{-2 \cdot c}\right) \cdot a}{b} - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
distribute-lft-neg-in [=>]14.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\frac{\color{blue}{\left(\left(--2\right) \cdot c\right)} \cdot a}{b} - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
metadata-eval [=>]14.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\frac{\left(\color{blue}{2} \cdot c\right) \cdot a}{b} - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
associate-*r* [<=]14.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\frac{\color{blue}{2 \cdot \left(c \cdot a\right)}}{b} - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
associate-*r/ [<=]14.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\color{blue}{2 \cdot \frac{c \cdot a}{b}} - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
*-commutative [=>]14.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\color{blue}{\frac{c \cdot a}{b} \cdot 2} - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
associate-*l/ [<=]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(\frac{c}{b} \cdot a\right)} \cdot 2 - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
associate-*l* [=>]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\color{blue}{\frac{c}{b} \cdot \left(a \cdot 2\right)} - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
*-commutative [=>]12.4 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\frac{c}{b} \cdot \color{blue}{\left(2 \cdot a\right)} - \left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot -2}{\frac{b}{a}}}{2 \cdot a}\\
\end{array}
\] |
Final simplification8.2
| Alternative 1 | |
|---|---|
| Error | 15.3 |
| Cost | 7756 |
| Alternative 2 | |
|---|---|
| Error | 15.5 |
| Cost | 7756 |
| Alternative 3 | |
|---|---|
| Error | 15.4 |
| Cost | 7624 |
| Alternative 4 | |
|---|---|
| Error | 18.5 |
| Cost | 7368 |
| Alternative 5 | |
|---|---|
| Error | 23.2 |
| Cost | 644 |
| Alternative 6 | |
|---|---|
| Error | 45.1 |
| Cost | 580 |
| Alternative 7 | |
|---|---|
| Error | 45.1 |
| Cost | 388 |
herbie shell --seed 2023027
(FPCore (a b c)
:name "jeff quadratic root 2"
:precision binary64
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))