| Alternative 1 | |
|---|---|
| Error | 9.1 |
| Cost | 44196 |
(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 (/ (- (- b) t_0) (* a 2.0)))
(t_2 (if (>= b 0.0) t_1 (/ (* c 2.0) (- t_0 b)))))
(if (<= t_2 (- INFINITY))
(if (>= b 0.0) (/ (- b) a) (/ b a))
(if (<= t_2 -4e-259)
t_2
(if (<= t_2 5e-158)
(if (>= b 0.0) t_1 (/ (* c 2.0) (- (fma 2.0 (/ c (/ b a)) (- b)) b)))
(if (<= t_2 5e+191)
(if (>= b 0.0)
t_1
(/ (* c 2.0) (- (hypot b (* (sqrt (* a -4.0)) (sqrt c))) b)))
(if (>= b 0.0)
(- (/ c b) (/ b a))
(/ (* c 2.0) (* 2.0 (- (* c (/ a 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 = sqrt(((b * b) - ((4.0 * a) * c)));
double t_1 = (-b - t_0) / (a * 2.0);
double tmp;
if (b >= 0.0) {
tmp = t_1;
} else {
tmp = (c * 2.0) / (t_0 - b);
}
double t_2 = tmp;
double tmp_2;
if (t_2 <= -((double) INFINITY)) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -b / a;
} else {
tmp_3 = b / a;
}
tmp_2 = tmp_3;
} else if (t_2 <= -4e-259) {
tmp_2 = t_2;
} else if (t_2 <= 5e-158) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = t_1;
} else {
tmp_4 = (c * 2.0) / (fma(2.0, (c / (b / a)), -b) - b);
}
tmp_2 = tmp_4;
} else if (t_2 <= 5e+191) {
double tmp_5;
if (b >= 0.0) {
tmp_5 = t_1;
} else {
tmp_5 = (c * 2.0) / (hypot(b, (sqrt((a * -4.0)) * sqrt(c))) - b);
}
tmp_2 = tmp_5;
} else if (b >= 0.0) {
tmp_2 = (c / b) - (b / a);
} else {
tmp_2 = (c * 2.0) / (2.0 * ((c * (a / 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 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) t_1 = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)) tmp = 0.0 if (b >= 0.0) tmp = t_1; else tmp = Float64(Float64(c * 2.0) / Float64(t_0 - b)); end t_2 = tmp tmp_2 = 0.0 if (t_2 <= Float64(-Inf)) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(-b) / a); else tmp_3 = Float64(b / a); end tmp_2 = tmp_3; elseif (t_2 <= -4e-259) tmp_2 = t_2; elseif (t_2 <= 5e-158) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = t_1; 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+191) tmp_5 = 0.0 if (b >= 0.0) tmp_5 = t_1; else tmp_5 = Float64(Float64(c * 2.0) / Float64(hypot(b, Float64(sqrt(Float64(a * -4.0)) * sqrt(c))) - b)); end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = Float64(Float64(c / b) - Float64(b / a)); else tmp_2 = Float64(Float64(c * 2.0) / Float64(2.0 * Float64(Float64(c * Float64(a / 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[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[((-b) - t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = If[GreaterEqual[b, 0.0], t$95$1, N[(N[(c * 2.0), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$2, (-Infinity)], If[GreaterEqual[b, 0.0], N[((-b) / a), $MachinePrecision], N[(b / a), $MachinePrecision]], If[LessEqual[t$95$2, -4e-259], t$95$2, If[LessEqual[t$95$2, 5e-158], If[GreaterEqual[b, 0.0], t$95$1, 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+191], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(c * 2.0), $MachinePrecision] / N[(N[Sqrt[b ^ 2 + N[(N[Sqrt[N[(a * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[c], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] - b), $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 := \frac{\left(-b\right) - t_0}{a \cdot 2}\\
t_2 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{t_0 - b}\\
\end{array}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;t_2 \leq -4 \cdot 10^{-259}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{-158}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\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^{+191}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{\mathsf{hypot}\left(b, \sqrt{a \cdot -4} \cdot \sqrt{c}\right) - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \left(c \cdot \frac{a}{b} - b\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 64.0
Taylor expanded in b around inf 18.6
Simplified18.6
[Start]18.6 | \[ \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) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
|---|---|
+-commutative [=>]18.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{-1 \cdot \frac{b}{a} + \frac{c}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
associate-*r/ [=>]18.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{-1 \cdot b}{a}} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
mul-1-neg [=>]18.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{-b}}{a} + \frac{c}{b}\\
\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 18.6
Simplified18.6
[Start]18.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\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 [=>]18.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\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* [=>]18.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\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 [=>]18.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\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 18.6
Taylor expanded in b around inf 18.3
Simplified18.3
[Start]18.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{a}\\
\end{array}
\] |
|---|---|
mul-1-neg [=>]18.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{-\frac{b}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{a}\\
\end{array}
\] |
distribute-neg-frac [=>]18.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{-b}{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)))))) < -4.0000000000000003e-259Initial program 3.0
if -4.0000000000000003e-259 < (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)))))) < 4.99999999999999972e-158Initial program 28.4
Taylor expanded in b around -inf 11.7
Simplified9.8
[Start]11.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}{\left(-b\right) + \left(2 \cdot \frac{c \cdot a}{b} + -1 \cdot b\right)}\\
\end{array}
\] |
|---|---|
fma-def [=>]11.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}{\color{blue}{\left(-b\right) + \mathsf{fma}\left(2, \frac{c \cdot a}{b}, -1 \cdot b\right)}}\\
\end{array}
\] |
associate-/l* [=>]9.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 [=>]9.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}
\] |
if 4.99999999999999972e-158 < (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.0000000000000002e191Initial program 3.9
Applied egg-rr4.0
Applied egg-rr8.9
Applied egg-rr9.1
if 5.0000000000000002e191 < (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 43.0
Taylor expanded in b around inf 18.2
Simplified18.2
[Start]18.2 | \[ \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) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
|---|---|
+-commutative [=>]18.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{-1 \cdot \frac{b}{a} + \frac{c}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
associate-*r/ [=>]18.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{-1 \cdot b}{a}} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\end{array}
\] |
mul-1-neg [=>]18.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{-b}}{a} + \frac{c}{b}\\
\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 21.6
Simplified18.0
[Start]21.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\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 [=>]21.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\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* [=>]18.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\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 [=>]18.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\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 21.6
Simplified18.0
[Start]21.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{c \cdot a}{b} + -2 \cdot b}\\
\end{array}
\] |
|---|---|
associate-*r/ [<=]18.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot \color{blue}{c}}{2 \cdot \left(c \cdot \frac{a}{b}\right) + -2 \cdot b}\\
\end{array}
\] |
associate-*l* [<=]18.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\color{blue}{2 \cdot c}}{\left(2 \cdot c\right) \cdot \frac{a}{b} + -2 \cdot b}\\
\end{array}
\] |
metadata-eval [<=]18.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(2 \cdot c\right) \cdot \frac{a}{b}} + \left(-2\right) \cdot b}\\
\end{array}
\] |
cancel-sign-sub-inv [<=]18.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\color{blue}{\frac{2 \cdot c}{\left(2 \cdot c\right) \cdot \frac{a}{b} - 2 \cdot b}}\\
\end{array}
\] |
associate-*l* [=>]18.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\color{blue}{2 \cdot c}}{2 \cdot \left(c \cdot \frac{a}{b}\right) - 2 \cdot b}\\
\end{array}
\] |
distribute-lft-out-- [=>]18.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\color{blue}{\frac{2 \cdot c}{2 \cdot \left(c \cdot \frac{a}{b} - b\right)}}\\
\end{array}
\] |
Final simplification9.2
| Alternative 1 | |
|---|---|
| Error | 9.1 |
| Cost | 44196 |
| Alternative 2 | |
|---|---|
| Error | 7.5 |
| Cost | 38053 |
| Alternative 3 | |
|---|---|
| Error | 7.5 |
| Cost | 38052 |
| Alternative 4 | |
|---|---|
| Error | 14.5 |
| Cost | 7624 |
| Alternative 5 | |
|---|---|
| Error | 17.9 |
| Cost | 7368 |
| Alternative 6 | |
|---|---|
| Error | 17.9 |
| Cost | 7368 |
| Alternative 7 | |
|---|---|
| Error | 22.4 |
| Cost | 964 |
| Alternative 8 | |
|---|---|
| Error | 45.4 |
| Cost | 580 |
| Alternative 9 | |
|---|---|
| Error | 22.6 |
| Cost | 580 |
| Alternative 10 | |
|---|---|
| Error | 45.3 |
| Cost | 388 |
| Alternative 11 | |
|---|---|
| Error | 61.8 |
| Cost | 324 |
herbie shell --seed 2023237
(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)))))))