| Alternative 1 | |
|---|---|
| Error | 7.0 |
| Cost | 7952 |
(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 (sqrt (- (* b b) (* (* 4.0 a) c))))
(t_1
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ (* c 2.0) (- t_0 b)))))
(if (<= t_1 (- INFINITY))
(if (>= b 0.0) (/ (- (- b) b) (* a 2.0)) (/ (- b) a))
(if (<= t_1 -5e-265)
t_1
(if (<= t_1 0.0)
(if (>= b 0.0)
(/ (- (- (/ (* c 2.0) (/ b a)) b) b) (* a 2.0))
(/ (* c -2.0) (+ (* (* c -2.0) (/ a b)) (* b 2.0))))
(if (<= t_1 2e+240)
t_1
(if (>= b 0.0)
(- (/ c b) (/ b a))
(/ (* c 2.0) (+ (* b -2.0) (* 2.0 (* c (/ a 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 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (a * 2.0);
} else {
tmp = (c * 2.0) / (t_0 - b);
}
double t_1 = tmp;
double tmp_2;
if (t_1 <= -((double) INFINITY)) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - b) / (a * 2.0);
} else {
tmp_3 = -b / a;
}
tmp_2 = tmp_3;
} else if (t_1 <= -5e-265) {
tmp_2 = t_1;
} else if (t_1 <= 0.0) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = ((((c * 2.0) / (b / a)) - b) - b) / (a * 2.0);
} else {
tmp_4 = (c * -2.0) / (((c * -2.0) * (a / b)) + (b * 2.0));
}
tmp_2 = tmp_4;
} else if (t_1 <= 2e+240) {
tmp_2 = t_1;
} else if (b >= 0.0) {
tmp_2 = (c / b) - (b / a);
} else {
tmp_2 = (c * 2.0) / ((b * -2.0) + (2.0 * (c * (a / b))));
}
return tmp_2;
}
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + Math.sqrt(((b * b) - ((4.0 * a) * c))));
}
return tmp;
}
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (a * 2.0);
} else {
tmp = (c * 2.0) / (t_0 - b);
}
double t_1 = tmp;
double tmp_2;
if (t_1 <= -Double.POSITIVE_INFINITY) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - b) / (a * 2.0);
} else {
tmp_3 = -b / a;
}
tmp_2 = tmp_3;
} else if (t_1 <= -5e-265) {
tmp_2 = t_1;
} else if (t_1 <= 0.0) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = ((((c * 2.0) / (b / a)) - b) - b) / (a * 2.0);
} else {
tmp_4 = (c * -2.0) / (((c * -2.0) * (a / b)) + (b * 2.0));
}
tmp_2 = tmp_4;
} else if (t_1 <= 2e+240) {
tmp_2 = t_1;
} else if (b >= 0.0) {
tmp_2 = (c / b) - (b / a);
} else {
tmp_2 = (c * 2.0) / ((b * -2.0) + (2.0 * (c * (a / b))));
}
return tmp_2;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (-b - math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a) else: tmp = (2.0 * c) / (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) return tmp
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (a * 2.0) else: tmp = (c * 2.0) / (t_0 - b) t_1 = tmp tmp_2 = 0 if t_1 <= -math.inf: tmp_3 = 0 if b >= 0.0: tmp_3 = (-b - b) / (a * 2.0) else: tmp_3 = -b / a tmp_2 = tmp_3 elif t_1 <= -5e-265: tmp_2 = t_1 elif t_1 <= 0.0: tmp_4 = 0 if b >= 0.0: tmp_4 = ((((c * 2.0) / (b / a)) - b) - b) / (a * 2.0) else: tmp_4 = (c * -2.0) / (((c * -2.0) * (a / b)) + (b * 2.0)) tmp_2 = tmp_4 elif t_1 <= 2e+240: tmp_2 = t_1 elif b >= 0.0: tmp_2 = (c / b) - (b / a) else: tmp_2 = (c * 2.0) / ((b * -2.0) + (2.0 * (c * (a / 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 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)); else tmp = Float64(Float64(c * 2.0) / Float64(t_0 - b)); end t_1 = tmp tmp_2 = 0.0 if (t_1 <= Float64(-Inf)) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(-b) - b) / Float64(a * 2.0)); else tmp_3 = Float64(Float64(-b) / a); end tmp_2 = tmp_3; elseif (t_1 <= -5e-265) tmp_2 = t_1; elseif (t_1 <= 0.0) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(Float64(Float64(c * 2.0) / Float64(b / a)) - b) - b) / Float64(a * 2.0)); else tmp_4 = Float64(Float64(c * -2.0) / Float64(Float64(Float64(c * -2.0) * Float64(a / b)) + Float64(b * 2.0))); end tmp_2 = tmp_4; elseif (t_1 <= 2e+240) tmp_2 = t_1; elseif (b >= 0.0) tmp_2 = Float64(Float64(c / b) - Float64(b / a)); else tmp_2 = Float64(Float64(c * 2.0) / Float64(Float64(b * -2.0) + Float64(2.0 * Float64(c * Float64(a / b))))); end return tmp_2 end
function tmp_2 = code(a, b, c) tmp = 0.0; 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)))); end tmp_2 = tmp; end
function tmp_6 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (-b - t_0) / (a * 2.0); else tmp = (c * 2.0) / (t_0 - b); end t_1 = tmp; tmp_3 = 0.0; if (t_1 <= -Inf) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (-b - b) / (a * 2.0); else tmp_4 = -b / a; end tmp_3 = tmp_4; elseif (t_1 <= -5e-265) tmp_3 = t_1; elseif (t_1 <= 0.0) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = ((((c * 2.0) / (b / a)) - b) - b) / (a * 2.0); else tmp_5 = (c * -2.0) / (((c * -2.0) * (a / b)) + (b * 2.0)); end tmp_3 = tmp_5; elseif (t_1 <= 2e+240) tmp_3 = t_1; elseif (b >= 0.0) tmp_3 = (c / b) - (b / a); else tmp_3 = (c * 2.0) / ((b * -2.0) + (2.0 * (c * (a / b)))); end tmp_6 = tmp_3; 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[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * 2.0), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$1, (-Infinity)], If[GreaterEqual[b, 0.0], N[(N[((-b) - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]], If[LessEqual[t$95$1, -5e-265], t$95$1, If[LessEqual[t$95$1, 0.0], 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[(N[(N[(c * -2.0), $MachinePrecision] * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[t$95$1, 2e+240], t$95$1, If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * 2.0), $MachinePrecision] / N[(N[(b * -2.0), $MachinePrecision] + N[(2.0 * N[(c * N[(a / 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 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{t_0 - b}\\
\end{array}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}\\
\mathbf{elif}\;t_1 \leq -5 \cdot 10^{-265}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\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}{\left(c \cdot -2\right) \cdot \frac{a}{b} + b \cdot 2}\\
\end{array}\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+240}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{b \cdot -2 + 2 \cdot \left(c \cdot \frac{a}{b}\right)}\\
\end{array}
Results
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 64.0
Taylor expanded in b around inf 18.5
Taylor expanded in c around 0 18.5
Simplified18.5
[Start]18.5 | \[ \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 [=>]18.5 | \[ \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 [=>]18.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\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)))))) < -5.0000000000000001e-265 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)))))) < 2.00000000000000003e240Initial program 2.9
if -5.0000000000000001e-265 < (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 35.8
Taylor expanded in b around -inf 13.2
Simplified10.9
[Start]13.2 | \[ \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}{2 \cdot \frac{c \cdot a}{b} + -2 \cdot b}\\
\end{array}
\] |
|---|---|
fma-def [=>]13.2 | \[ \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}:\\
\;\;\;\;\color{blue}{\frac{2 \cdot c}{\mathsf{fma}\left(2, \frac{c \cdot a}{b}, -2 \cdot b\right)}}\\
\end{array}
\] |
associate-/l* [=>]10.9 | \[ \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}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -2 \cdot b\right)}}\\
\end{array}
\] |
*-commutative [=>]10.9 | \[ \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}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}\\
\end{array}
\] |
Taylor expanded in b around inf 11.1
Simplified11.1
[Start]11.1 | \[ \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}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}\\
\end{array}
\] |
|---|---|
associate-/l* [=>]11.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + -2 \cdot \color{blue}{\frac{c}{\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}
\] |
associate-*r/ [=>]11.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + \color{blue}{\frac{-2 \cdot c}{\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}
\] |
Applied egg-rr11.1
if 2.00000000000000003e240 < (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 52.2
Taylor expanded in b around -inf 53.7
Simplified49.6
[Start]53.7 | \[ \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}{2 \cdot \frac{c \cdot a}{b} + -2 \cdot b}\\
\end{array}
\] |
|---|---|
fma-def [=>]53.7 | \[ \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}:\\
\;\;\;\;\color{blue}{\frac{2 \cdot c}{\mathsf{fma}\left(2, \frac{c \cdot a}{b}, -2 \cdot b\right)}}\\
\end{array}
\] |
associate-/l* [=>]49.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}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, -2 \cdot b\right)}}\\
\end{array}
\] |
*-commutative [=>]49.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}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}\\
\end{array}
\] |
Taylor expanded in b around inf 22.4
Simplified15.3
[Start]22.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}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}\\
\end{array}
\] |
|---|---|
associate-/l* [=>]15.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + -2 \cdot \color{blue}{\frac{c}{\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}
\] |
associate-*r/ [=>]15.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b + \color{blue}{\frac{-2 \cdot c}{\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}
\] |
Taylor expanded in b around 0 14.9
Simplified14.9
[Start]14.9 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} + -1 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}\\
\end{array}
\] |
|---|---|
mul-1-neg [=>]14.9 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} + \color{blue}{\left(-\frac{b}{a}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}\\
\end{array}
\] |
unsub-neg [=>]14.9 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{c}{b} - \frac{b}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(2, \frac{c}{\frac{b}{a}}, b \cdot -2\right)}\\
\end{array}
\] |
Applied egg-rr14.9
Final simplification7.2
| Alternative 1 | |
|---|---|
| Error | 7.0 |
| Cost | 7952 |
| Alternative 2 | |
|---|---|
| Error | 10.3 |
| Cost | 7756 |
| Alternative 3 | |
|---|---|
| Error | 13.7 |
| Cost | 7696 |
| Alternative 4 | |
|---|---|
| Error | 18.4 |
| Cost | 7368 |
| Alternative 5 | |
|---|---|
| Error | 18.0 |
| Cost | 7368 |
| Alternative 6 | |
|---|---|
| Error | 18.0 |
| Cost | 7368 |
| Alternative 7 | |
|---|---|
| Error | 22.8 |
| Cost | 1092 |
| Alternative 8 | |
|---|---|
| Error | 45.3 |
| Cost | 580 |
| Alternative 9 | |
|---|---|
| Error | 23.0 |
| Cost | 580 |
herbie shell --seed 2023010
(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)))))))