| Alternative 1 | |
|---|---|
| Accuracy | 90.6% |
| 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 (- (- b) b))
(t_1 (/ (* 2.0 c) t_0))
(t_2 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_3
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_2)) (/ (- t_2 b) (* 2.0 a)))))
(if (<= t_3 (- INFINITY))
(if (>= b 0.0) (* c (/ (- 2.0) (+ b b))) (/ t_0 (* 2.0 a)))
(if (<= t_3 -2e-205)
t_3
(if (<= t_3 0.0)
(if (>= b 0.0)
t_1
(/
(/ (+ b (hypot b (sqrt (* c (* a -4.0))))) (cbrt (+ a a)))
(cbrt (* 4.0 (* a a)))))
(if (<= t_3 5e+256) t_3 (if (>= b 0.0) t_1 (- (/ c b) (/ 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 = -b - b;
double t_1 = (2.0 * c) / t_0;
double t_2 = sqrt(((b * b) - (c * (4.0 * a))));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_2);
} else {
tmp = (t_2 - b) / (2.0 * a);
}
double t_3 = tmp;
double tmp_2;
if (t_3 <= -((double) INFINITY)) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / (b + b));
} else {
tmp_3 = t_0 / (2.0 * a);
}
tmp_2 = tmp_3;
} else if (t_3 <= -2e-205) {
tmp_2 = t_3;
} else if (t_3 <= 0.0) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = t_1;
} else {
tmp_4 = ((b + hypot(b, sqrt((c * (a * -4.0))))) / cbrt((a + a))) / cbrt((4.0 * (a * a)));
}
tmp_2 = tmp_4;
} else if (t_3 <= 5e+256) {
tmp_2 = t_3;
} else if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (c / b) - (b / a);
}
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 t_0 = -b - b;
double t_1 = (2.0 * c) / t_0;
double t_2 = Math.sqrt(((b * b) - (c * (4.0 * a))));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_2);
} else {
tmp = (t_2 - b) / (2.0 * a);
}
double t_3 = tmp;
double tmp_2;
if (t_3 <= -Double.POSITIVE_INFINITY) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / (b + b));
} else {
tmp_3 = t_0 / (2.0 * a);
}
tmp_2 = tmp_3;
} else if (t_3 <= -2e-205) {
tmp_2 = t_3;
} else if (t_3 <= 0.0) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = t_1;
} else {
tmp_4 = ((b + Math.hypot(b, Math.sqrt((c * (a * -4.0))))) / Math.cbrt((a + a))) / Math.cbrt((4.0 * (a * a)));
}
tmp_2 = tmp_4;
} else if (t_3 <= 5e+256) {
tmp_2 = t_3;
} else if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (c / b) - (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 = Float64(Float64(-b) - b) t_1 = Float64(Float64(2.0 * c) / t_0) t_2 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_2)); else tmp = Float64(Float64(t_2 - b) / Float64(2.0 * a)); end t_3 = tmp tmp_2 = 0.0 if (t_3 <= Float64(-Inf)) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * Float64(Float64(-2.0) / Float64(b + b))); else tmp_3 = Float64(t_0 / Float64(2.0 * a)); end tmp_2 = tmp_3; elseif (t_3 <= -2e-205) tmp_2 = t_3; elseif (t_3 <= 0.0) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = t_1; else tmp_4 = Float64(Float64(Float64(b + hypot(b, sqrt(Float64(c * Float64(a * -4.0))))) / cbrt(Float64(a + a))) / cbrt(Float64(4.0 * Float64(a * a)))); end tmp_2 = tmp_4; elseif (t_3 <= 5e+256) tmp_2 = t_3; elseif (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(c / b) - 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[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$3, (-Infinity)], If[GreaterEqual[b, 0.0], N[(c * N[((-2.0) / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[t$95$3, -2e-205], t$95$3, If[LessEqual[t$95$3, 0.0], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(N[(b + N[Sqrt[b ^ 2 + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[Power[N[(a + a), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] / N[Power[N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], If[LessEqual[t$95$3, 5e+256], t$95$3, If[GreaterEqual[b, 0.0], t$95$1, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $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 := \left(-b\right) - b\\
t_1 := \frac{2 \cdot c}{t_0}\\
t_2 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_3 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_2 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;t_3 \leq -2 \cdot 10^{-205}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}{\sqrt[3]{a + a}}}{\sqrt[3]{4 \cdot \left(a \cdot a\right)}}\\
\end{array}\\
\mathbf{elif}\;t_3 \leq 5 \cdot 10^{+256}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\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.0Initial program 26.0%
Simplified26.0%
[Start]26.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}
\] |
|---|
Taylor expanded in b around inf 26.0%
Taylor expanded in b around -inf 78.1%
Simplified78.1%
[Start]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\frac{\left(-b\right) - b}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot b - b}{2 \cdot a}\\
\end{array}
\] |
|---|---|
mul-1-neg [=>]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\frac{\left(-b\right) - b}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
Applied egg-rr78.1%
[Start]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\frac{\left(-b\right) - b}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
|---|---|
frac-2neg [=>]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\color{blue}{\frac{-\left(\left(-b\right) - b\right)}{-c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
associate-/r/ [=>]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{2}{-\left(\left(-b\right) - b\right)} \cdot \left(-c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
neg-sub0 [=>]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\color{blue}{0 - \left(\left(-b\right) - b\right)}} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
add-sqr-sqrt [=>]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{0 - \left(\color{blue}{\sqrt{-b} \cdot \sqrt{-b}} - b\right)} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
sqrt-unprod [=>]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{0 - \left(\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}} - b\right)} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
sqr-neg [=>]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{0 - \left(\sqrt{\color{blue}{b \cdot b}} - b\right)} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
sqrt-unprod [<=]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{0 - \left(\color{blue}{\sqrt{b} \cdot \sqrt{b}} - b\right)} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
add-sqr-sqrt [<=]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{0 - \left(\color{blue}{b} - b\right)} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
associate-+l- [<=]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\color{blue}{\left(0 - b\right) + b}} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
neg-sub0 [<=]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\color{blue}{\left(-b\right)} + b} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
add-sqr-sqrt [=>]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\color{blue}{\sqrt{-b} \cdot \sqrt{-b}} + b} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
sqrt-unprod [=>]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}} + b} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
sqr-neg [=>]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\sqrt{\color{blue}{b \cdot b}} + b} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
sqrt-unprod [<=]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\color{blue}{\sqrt{b} \cdot \sqrt{b}} + b} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\] |
add-sqr-sqrt [<=]78.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\color{blue}{b} + b} \cdot \left(-c\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot 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))) < -2e-205 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.00000000000000015e256Initial program 99.1%
if -2e-205 < (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 50.4%
Taylor expanded in b around inf 81.7%
Applied egg-rr81.7%
[Start]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\end{array}
\] |
|---|---|
*-un-lft-identity [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}{2 \cdot a}\\
\end{array}
\] |
add-cube-cbrt [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\color{blue}{\frac{1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}{\left(\sqrt[3]{2 \cdot a} \cdot \sqrt[3]{2 \cdot a}\right) \cdot \sqrt[3]{2 \cdot a}}}\\
\end{array}
\] |
times-frac [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{2 \cdot a} \cdot \sqrt[3]{2 \cdot a}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\sqrt[3]{2 \cdot a}}\\
\end{array}
\] |
cbrt-unprod [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{\left(2 \cdot a\right) \cdot \left(2 \cdot a\right)}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\sqrt[3]{2 \cdot a}}\\
\end{array}
\] |
pow2 [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{{\left(2 \cdot a\right)}^{2}}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\sqrt[3]{2 \cdot a}}\\
\end{array}
\] |
add-log-exp [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{{\log \left(e^{2 \cdot a}\right)}^{2}}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\sqrt[3]{2 \cdot a}}\\
\end{array}
\] |
*-commutative [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{{\log \left(e^{a \cdot 2}\right)}^{2}}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\sqrt[3]{2 \cdot a}}\\
\end{array}
\] |
exp-lft-sqr [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{{\log \left(e^{a} \cdot e^{a}\right)}^{2}}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\sqrt[3]{2 \cdot a}}\\
\end{array}
\] |
log-prod [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{{\left(\log \left(e^{a}\right) + \log \left(e^{a}\right)\right)}^{2}}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\sqrt[3]{2 \cdot a}}\\
\end{array}
\] |
add-log-exp [<=]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{{\left(a + \log \left(e^{a}\right)\right)}^{2}}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\sqrt[3]{2 \cdot a}}\\
\end{array}
\] |
add-log-exp [<=]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{{\left(a + a\right)}^{2}}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\sqrt[3]{2 \cdot a}}\\
\end{array}
\] |
Simplified81.7%
[Start]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt[3]{{\left(a + a\right)}^{2}}} \cdot \frac{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}{\sqrt[3]{a + a}}\\
\end{array}
\] |
|---|---|
associate-*l/ [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot \frac{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}{\sqrt[3]{a + a}}}{\sqrt[3]{{\left(a + a\right)}^{2}}}\\
\end{array}
\] |
*-lft-identity [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}{\sqrt[3]{a + a}}}{\sqrt[3]{{\left(a + a\right)}^{2}}}\\
\end{array}
\] |
unpow2 [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\color{blue}{\frac{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}{\sqrt[3]{a + a}}}}{\sqrt[3]{\left(a + a\right) \cdot \left(a + a\right)}}\\
\end{array}
\] |
count-2 [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\color{blue}{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}}{\sqrt[3]{a + a}}}{\sqrt[3]{\left(2 \cdot a\right) \cdot \left(a + a\right)}}\\
\end{array}
\] |
count-2 [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}{\color{blue}{\sqrt[3]{a + a}}}}{\sqrt[3]{\left(2 \cdot a\right) \cdot \left(2 \cdot a\right)}}\\
\end{array}
\] |
swap-sqr [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\color{blue}{\frac{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}{\sqrt[3]{a + a}}}}{\sqrt[3]{\left(2 \cdot 2\right) \cdot \left(a \cdot a\right)}}\\
\end{array}
\] |
metadata-eval [=>]81.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\color{blue}{b + \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)}}{\sqrt[3]{a + a}}}{\sqrt[3]{4 \cdot \left(a \cdot a\right)}}\\
\end{array}
\] |
if 5.00000000000000015e256 < (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 34.3%
Taylor expanded in b around inf 40.0%
Taylor expanded in b around -inf 78.1%
Simplified78.1%
[Start]78.1 | \[ \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 [=>]78.1 | \[ \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 [=>]78.1 | \[ \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}
\] |
Final simplification90.9%
| Alternative 1 | |
|---|---|
| Accuracy | 90.6% |
| Cost | 38052 |
| Alternative 2 | |
|---|---|
| Accuracy | 85.8% |
| Cost | 7889 |
| Alternative 3 | |
|---|---|
| Accuracy | 81.5% |
| Cost | 7696 |
| Alternative 4 | |
|---|---|
| Accuracy | 75.5% |
| Cost | 7368 |
| Alternative 5 | |
|---|---|
| Accuracy | 68.4% |
| Cost | 644 |
| Alternative 6 | |
|---|---|
| Accuracy | 68.7% |
| Cost | 644 |
herbie shell --seed 2023159
(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))))