| Alternative 1 | |
|---|---|
| Error | 6.9 |
| Cost | 38052 |
(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 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (/ (- t_0 b) (* 2.0 a)))
(t_2 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) t_1)))
(if (<= t_2 (- INFINITY))
(if (>= b 0.0)
(* c (/ 2.0 (- (- b) (sqrt (fma b b (* a (* c -4.0)))))))
(pow (* 2.0 (/ a (- (hypot b (* (sqrt (* a -4.0)) (sqrt c))) b))) -1.0))
(if (<= t_2 -5e-181)
t_2
(if (<= t_2 0.0)
(if (>= b 0.0) (/ (* 2.0 c) (- (- (/ (* 2.0 c) (/ b a)) b) b)) t_1)
(if (<= t_2 5e+290) t_2 (if (>= b 0.0) (/ b a) (/ (- b) a))))))))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 t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (t_0 - b) / (2.0 * a);
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = t_1;
}
double t_2 = tmp;
double tmp_2;
if (t_2 <= -((double) INFINITY)) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (2.0 / (-b - sqrt(fma(b, b, (a * (c * -4.0))))));
} else {
tmp_3 = pow((2.0 * (a / (hypot(b, (sqrt((a * -4.0)) * sqrt(c))) - b))), -1.0);
}
tmp_2 = tmp_3;
} else if (t_2 <= -5e-181) {
tmp_2 = t_2;
} else if (t_2 <= 0.0) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / ((((2.0 * c) / (b / a)) - b) - b);
} else {
tmp_4 = t_1;
}
tmp_2 = tmp_4;
} else if (t_2 <= 5e+290) {
tmp_2 = t_2;
} else if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = -b / a;
}
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) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(t_0 - b) / Float64(2.0 * a)) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = t_1; end t_2 = tmp tmp_2 = 0.0 if (t_2 <= Float64(-Inf)) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * Float64(2.0 / Float64(Float64(-b) - sqrt(fma(b, b, Float64(a * Float64(c * -4.0))))))); else tmp_3 = Float64(2.0 * Float64(a / Float64(hypot(b, Float64(sqrt(Float64(a * -4.0)) * sqrt(c))) - b))) ^ -1.0; end tmp_2 = tmp_3; elseif (t_2 <= -5e-181) tmp_2 = t_2; elseif (t_2 <= 0.0) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(Float64(Float64(2.0 * c) / Float64(b / a)) - b) - b)); else tmp_4 = t_1; end tmp_2 = tmp_4; elseif (t_2 <= 5e+290) tmp_2 = t_2; elseif (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(Float64(-b) / a); end return tmp_2 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 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]}, If[LessEqual[t$95$2, (-Infinity)], If[GreaterEqual[b, 0.0], N[(c * N[(2.0 / N[((-b) - N[Sqrt[N[(b * b + N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(2.0 * N[(a / N[(N[Sqrt[b ^ 2 + N[(N[Sqrt[N[(a * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[c], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]], If[LessEqual[t$95$2, -5e-181], t$95$2, If[LessEqual[t$95$2, 0.0], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(N[(N[(N[(2.0 * c), $MachinePrecision] / N[(b / a), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], t$95$1], If[LessEqual[t$95$2, 5e+290], t$95$2, If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]]]]]]]
\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 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{t_0 - b}{2 \cdot a}\\
t_2 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;{\left(2 \cdot \frac{a}{\mathsf{hypot}\left(b, \sqrt{a \cdot -4} \cdot \sqrt{c}\right) - b}\right)}^{-1}\\
\end{array}\\
\mathbf{elif}\;t_2 \leq -5 \cdot 10^{-181}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(\frac{2 \cdot c}{\frac{b}{a}} - b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+290}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
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.0Initial program 64.0
Simplified63.9
[Start]64.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}
\] |
|---|---|
*-commutative [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{c \cdot 2}}{\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}
\] |
associate-*r/ [<=]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{c \cdot \frac{2}{\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}
\] |
fma-neg [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\color{blue}{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
distribute-lft-neg-in [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(-4 \cdot a\right) \cdot c}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
*-commutative [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \left(-\color{blue}{a \cdot 4}\right) \cdot c\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
distribute-rgt-neg-in [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{\left(a \cdot \left(-4\right)\right)} \cdot c\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* [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, \color{blue}{a \cdot \left(\left(-4\right) \cdot c\right)}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
metadata-eval [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(\color{blue}{-4} \cdot c\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
+-commutative [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-4 \cdot c\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a}\\
\end{array}
\] |
unsub-neg [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-4 \cdot c\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\
\end{array}
\] |
fma-neg [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-4 \cdot c\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, -\left(4 \cdot a\right) \cdot c\right)} - b}{2 \cdot a}\\
\end{array}
\] |
distribute-lft-neg-in [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-4 \cdot c\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-4 \cdot a\right) \cdot c\right)} - b}{2 \cdot a}\\
\end{array}
\] |
*-commutative [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-4 \cdot c\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-a \cdot 4\right) \cdot c\right)} - b}{2 \cdot a}\\
\end{array}
\] |
distribute-rgt-neg-in [=>]64.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-4 \cdot c\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot \left(-4\right)\right) \cdot c\right)} - b}{2 \cdot a}\\
\end{array}
\] |
associate-*l* [=>]63.9 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-4 \cdot c\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(\left(-4\right) \cdot c\right)\right)} - b}{2 \cdot a}\\
\end{array}
\] |
metadata-eval [=>]63.9 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-4 \cdot c\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-4 \cdot c\right)\right)} - b}{2 \cdot a}\\
\end{array}
\] |
Applied egg-rr44.0
Applied egg-rr23.2
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))) < -5.0000000000000001e-181 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))) < 4.9999999999999998e290Initial program 2.7
if -5.0000000000000001e-181 < (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.8
Taylor expanded in b around inf 11.7
Simplified9.8
[Start]11.7 | \[ \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}
\] |
|---|---|
associate-/l* [=>]9.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + -2 \cdot \color{blue}{\frac{c}{\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}
\] |
associate-*r/ [=>]9.8 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + \color{blue}{\frac{-2 \cdot c}{\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}
\] |
if 4.9999999999999998e290 < (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 61.7
Taylor expanded in b around inf 61.4
Simplified55.3
[Start]61.4 | \[ \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}
\] |
|---|---|
associate-/l* [=>]55.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + -2 \cdot \color{blue}{\frac{c}{\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}
\] |
associate-*r/ [=>]55.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + \color{blue}{\frac{-2 \cdot c}{\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 61.6
Taylor expanded in b around -inf 21.0
Simplified21.0
[Start]21.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\end{array}
\] |
|---|---|
associate-*r/ [=>]21.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot b}{a}\\
\end{array}
\] |
mul-1-neg [=>]21.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\] |
Final simplification7.5
| Alternative 1 | |
|---|---|
| Error | 6.9 |
| Cost | 38052 |
| Alternative 2 | |
|---|---|
| Error | 7.2 |
| Cost | 38052 |
| Alternative 3 | |
|---|---|
| Error | 7.0 |
| Cost | 7952 |
| Alternative 4 | |
|---|---|
| Error | 14.8 |
| Cost | 7756 |
| Alternative 5 | |
|---|---|
| Error | 14.9 |
| Cost | 7624 |
| Alternative 6 | |
|---|---|
| Error | 18.6 |
| Cost | 7368 |
| Alternative 7 | |
|---|---|
| Error | 23.3 |
| Cost | 644 |
| Alternative 8 | |
|---|---|
| Error | 23.3 |
| Cost | 644 |
| Alternative 9 | |
|---|---|
| Error | 45.3 |
| Cost | 388 |
herbie shell --seed 2022354
(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))))