| Alternative 1 | |
|---|---|
| Accuracy | 88.5% |
| 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 (if (>= b 0.0) (* c (/ -1.0 b)) (/ (- b) a)))
(t_1 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_2 (/ (- t_1 b) (* 2.0 a)))
(t_3 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_1)) t_2)))
(if (<= t_3 (- INFINITY))
t_0
(if (<= t_3 -8e-300)
t_3
(if (<= t_3 0.0)
(if (>= b 0.0) (/ (* 2.0 c) (- (- (/ (* 2.0 c) (/ b a)) b) b)) t_2)
(if (<= t_3 2e+159) t_3 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 = c * (-1.0 / b);
} else {
tmp = -b / a;
}
double t_0 = tmp;
double t_1 = sqrt(((b * b) - (c * (4.0 * a))));
double t_2 = (t_1 - b) / (2.0 * a);
double tmp_1;
if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - t_1);
} else {
tmp_1 = t_2;
}
double t_3 = tmp_1;
double tmp_2;
if (t_3 <= -((double) INFINITY)) {
tmp_2 = t_0;
} else if (t_3 <= -8e-300) {
tmp_2 = t_3;
} else if (t_3 <= 0.0) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / ((((2.0 * c) / (b / a)) - b) - b);
} else {
tmp_3 = t_2;
}
tmp_2 = tmp_3;
} else if (t_3 <= 2e+159) {
tmp_2 = t_3;
} 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 = c * (-1.0 / b);
} else {
tmp = -b / a;
}
double t_0 = tmp;
double t_1 = Math.sqrt(((b * b) - (c * (4.0 * a))));
double t_2 = (t_1 - b) / (2.0 * a);
double tmp_1;
if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - t_1);
} else {
tmp_1 = t_2;
}
double t_3 = tmp_1;
double tmp_2;
if (t_3 <= -Double.POSITIVE_INFINITY) {
tmp_2 = t_0;
} else if (t_3 <= -8e-300) {
tmp_2 = t_3;
} else if (t_3 <= 0.0) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / ((((2.0 * c) / (b / a)) - b) - b);
} else {
tmp_3 = t_2;
}
tmp_2 = tmp_3;
} else if (t_3 <= 2e+159) {
tmp_2 = t_3;
} 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 = c * (-1.0 / b) else: tmp = -b / a t_0 = tmp t_1 = math.sqrt(((b * b) - (c * (4.0 * a)))) t_2 = (t_1 - b) / (2.0 * a) tmp_1 = 0 if b >= 0.0: tmp_1 = (2.0 * c) / (-b - t_1) else: tmp_1 = t_2 t_3 = tmp_1 tmp_2 = 0 if t_3 <= -math.inf: tmp_2 = t_0 elif t_3 <= -8e-300: tmp_2 = t_3 elif t_3 <= 0.0: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) / ((((2.0 * c) / (b / a)) - b) - b) else: tmp_3 = t_2 tmp_2 = tmp_3 elif t_3 <= 2e+159: tmp_2 = t_3 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(c * Float64(-1.0 / b)); else tmp = Float64(Float64(-b) / a); end t_0 = tmp t_1 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_2 = Float64(Float64(t_1 - b) / Float64(2.0 * a)) tmp_1 = 0.0 if (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_1)); else tmp_1 = t_2; end t_3 = tmp_1 tmp_2 = 0.0 if (t_3 <= Float64(-Inf)) tmp_2 = t_0; elseif (t_3 <= -8e-300) tmp_2 = t_3; elseif (t_3 <= 0.0) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(Float64(Float64(2.0 * c) / Float64(b / a)) - b) - b)); else tmp_3 = t_2; end tmp_2 = tmp_3; elseif (t_3 <= 2e+159) tmp_2 = t_3; 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 = c * (-1.0 / b); else tmp = -b / a; end t_0 = tmp; t_1 = sqrt(((b * b) - (c * (4.0 * a)))); t_2 = (t_1 - b) / (2.0 * a); tmp_2 = 0.0; if (b >= 0.0) tmp_2 = (2.0 * c) / (-b - t_1); else tmp_2 = t_2; end t_3 = tmp_2; tmp_3 = 0.0; if (t_3 <= -Inf) tmp_3 = t_0; elseif (t_3 <= -8e-300) tmp_3 = t_3; elseif (t_3 <= 0.0) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) / ((((2.0 * c) / (b / a)) - b) - b); else tmp_4 = t_2; end tmp_3 = tmp_4; elseif (t_3 <= 2e+159) tmp_3 = t_3; 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[(c * N[(-1.0 / b), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$1), $MachinePrecision]), $MachinePrecision], t$95$2]}, If[LessEqual[t$95$3, (-Infinity)], t$95$0, If[LessEqual[t$95$3, -8e-300], t$95$3, If[LessEqual[t$95$3, 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$2], If[LessEqual[t$95$3, 2e+159], t$95$3, 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:\\
\;\;\;\;c \cdot \frac{-1}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}\\
t_1 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_2 := \frac{t_1 - b}{2 \cdot a}\\
t_3 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_1}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_3 \leq -8 \cdot 10^{-300}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_3 \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_2\\
\end{array}\\
\mathbf{elif}\;t_3 \leq 2 \cdot 10^{+159}:\\
\;\;\;\;t_3\\
\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 1.9999999999999999e159 < (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 27.2%
Taylor expanded in b around inf 26.5%
Taylor expanded in b around -inf 73.0%
Simplified73.0%
[Start]73.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} + -1 \cdot \frac{b}{a}\\
\end{array}
\] |
|---|---|
mul-1-neg [=>]73.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\color{blue}{\frac{c}{b} + \left(-\frac{b}{a}\right)}\\
\end{array}
\] |
unsub-neg [=>]73.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
Applied egg-rr73.0%
[Start]73.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
|---|---|
frac-2neg [=>]73.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{-2 \cdot c}{-\left(\left(-b\right) - b\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
clear-num [=>]73.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{1}{\frac{-\left(\left(-b\right) - b\right)}{-2 \cdot c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
sub-neg [=>]73.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{-\color{blue}{\left(\left(-b\right) + \left(-b\right)\right)}}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
distribute-neg-in [=>]73.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\color{blue}{\left(-\left(-b\right)\right) + \left(-\left(-b\right)\right)}}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
add-sqr-sqrt [=>]67.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(-\color{blue}{\sqrt{-b} \cdot \sqrt{-b}}\right) + \left(-\left(-b\right)\right)}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
sqrt-unprod [=>]67.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(-\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}}\right) + \left(-\left(-b\right)\right)}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
sqr-neg [=>]67.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(-\sqrt{\color{blue}{b \cdot b}}\right) + \left(-\left(-b\right)\right)}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
sqrt-unprod [<=]67.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(-\color{blue}{\sqrt{b} \cdot \sqrt{b}}\right) + \left(-\left(-b\right)\right)}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
add-sqr-sqrt [<=]67.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(-\color{blue}{b}\right) + \left(-\left(-b\right)\right)}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
add-sqr-sqrt [=>]67.5 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(-b\right) + \left(-\color{blue}{\sqrt{-b} \cdot \sqrt{-b}}\right)}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
sqrt-unprod [=>]67.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(-b\right) + \left(-\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}}\right)}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
sqr-neg [=>]67.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(-b\right) + \left(-\sqrt{\color{blue}{b \cdot b}}\right)}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
sqrt-unprod [<=]67.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(-b\right) + \left(-\color{blue}{\sqrt{b} \cdot \sqrt{b}}\right)}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
add-sqr-sqrt [<=]67.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(-b\right) + \left(-\color{blue}{b}\right)}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
sub-neg [<=]67.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\color{blue}{\left(-b\right) - b}}{-2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
associate-/r/ [=>]67.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{1}{\left(-b\right) - b} \cdot \left(-2 \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
Simplified73.1%
[Start]73.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{b + b} \cdot \left(c \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
|---|---|
*-commutative [=>]73.0 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\left(c \cdot -2\right) \cdot \frac{1}{b + b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
associate-*l* [=>]73.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{c \cdot \left(-2 \cdot \frac{1}{b + b}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
associate-*r/ [=>]73.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \color{blue}{\frac{-2 \cdot 1}{b + b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
metadata-eval [=>]73.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{\color{blue}{-2}}{b + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
count-2 [=>]73.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{\color{blue}{2 \cdot b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
associate-/r* [=>]73.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \color{blue}{\frac{\frac{-2}{2}}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
metadata-eval [=>]73.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{\color{blue}{-1}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\] |
Taylor expanded in c around 0 73.4%
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))) < -8.0000000000000002e-300 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))) < 1.9999999999999999e159Initial program 95.3%
Applied egg-rr74.6%
[Start]95.3 | \[ \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}
\] |
|---|---|
sub-neg [=>]95.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{b \cdot b + \left(-\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}
\] |
flip-+ [=>]74.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{\frac{\left(b \cdot b\right) \cdot \left(b \cdot b\right) - \left(-\left(4 \cdot a\right) \cdot c\right) \cdot \left(-\left(4 \cdot a\right) \cdot c\right)}{b \cdot b - \left(-\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}
\] |
Simplified65.2%
[Start]74.6 | \[ \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 [=>]65.2 | \[ \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-rr95.3%
[Start]65.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\frac{{b}^{4} - \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}
\] |
|---|---|
sqr-pow [=>]65.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\frac{\color{blue}{{b}^{\left(\frac{4}{2}\right)} \cdot {b}^{\left(\frac{4}{2}\right)}} - \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}
\] |
metadata-eval [=>]65.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\frac{{b}^{\color{blue}{2}} \cdot {b}^{\left(\frac{4}{2}\right)} - \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}
\] |
pow2 [<=]65.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\frac{\color{blue}{\left(b \cdot b\right)} \cdot {b}^{\left(\frac{4}{2}\right)} - \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}
\] |
metadata-eval [=>]65.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\frac{\left(b \cdot b\right) \cdot {b}^{\color{blue}{2}} - \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}
\] |
pow2 [<=]65.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\frac{\left(b \cdot b\right) \cdot \color{blue}{\left(b \cdot b\right)} - \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}
\] |
unswap-sqr [=>]74.6 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\frac{\left(b \cdot b\right) \cdot \left(b \cdot b\right) - \color{blue}{\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}
\] |
flip-+ [<=]95.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{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}
\] |
+-commutative [=>]95.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{c \cdot \left(a \cdot -4\right) + b \cdot b}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
if -8.0000000000000002e-300 < (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 42.6%
Taylor expanded in b around inf 82.1%
Simplified85.4%
[Start]82.1 | \[ \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* [=>]85.4 | \[ \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/ [=>]85.4 | \[ \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}
\] |
Final simplification88.6%
| Alternative 1 | |
|---|---|
| Accuracy | 88.5% |
| Cost | 38052 |
| Alternative 2 | |
|---|---|
| Accuracy | 78.9% |
| Cost | 7764 |
| Alternative 3 | |
|---|---|
| Accuracy | 78.9% |
| Cost | 7764 |
| Alternative 4 | |
|---|---|
| Accuracy | 85.1% |
| Cost | 7756 |
| Alternative 5 | |
|---|---|
| Accuracy | 65.4% |
| Cost | 644 |
| Alternative 6 | |
|---|---|
| Accuracy | 65.3% |
| Cost | 452 |
herbie shell --seed 2023138
(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))))