| Alternative 1 | |
|---|---|
| Error | 11.1 |
| Cost | 7756 |
(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) (* (* 4.0 a) c)))) (t_1 (- (- b) b)))
(if (<= b -1.3e+150)
(if (>= b 0.0) (/ (+ c c) t_1) (/ t_1 (+ a a)))
(if (<= b 2.9e+39)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))
(if (>= b 0.0) (- (/ c b)) (/ c b))))))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) - ((4.0 * a) * c)));
double t_1 = -b - b;
double tmp_1;
if (b <= -1.3e+150) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c + c) / t_1;
} else {
tmp_2 = t_1 / (a + a);
}
tmp_1 = tmp_2;
} else if (b <= 2.9e+39) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = (-b + t_0) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -(c / b);
} else {
tmp_1 = c / b;
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (-b - sqrt(((b * b) - ((4.0d0 * a) * c))))
else
tmp = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end if
code = tmp
end function
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
t_1 = -b - b
if (b <= (-1.3d+150)) then
if (b >= 0.0d0) then
tmp_2 = (c + c) / t_1
else
tmp_2 = t_1 / (a + a)
end if
tmp_1 = tmp_2
else if (b <= 2.9d+39) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * c) / (-b - t_0)
else
tmp_3 = (-b + t_0) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = -(c / b)
else
tmp_1 = c / b
end if
code = tmp_1
end function
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 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double t_1 = -b - b;
double tmp_1;
if (b <= -1.3e+150) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c + c) / t_1;
} else {
tmp_2 = t_1 / (a + a);
}
tmp_1 = tmp_2;
} else if (b <= 2.9e+39) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = (-b + t_0) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -(c / b);
} else {
tmp_1 = c / b;
}
return tmp_1;
}
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): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) t_1 = -b - b tmp_1 = 0 if b <= -1.3e+150: tmp_2 = 0 if b >= 0.0: tmp_2 = (c + c) / t_1 else: tmp_2 = t_1 / (a + a) tmp_1 = tmp_2 elif b <= 2.9e+39: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) / (-b - t_0) else: tmp_3 = (-b + t_0) / (2.0 * a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = -(c / b) else: tmp_1 = c / b return tmp_1
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(Float64(4.0 * a) * c))) t_1 = Float64(Float64(-b) - b) tmp_1 = 0.0 if (b <= -1.3e+150) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(c + c) / t_1); else tmp_2 = Float64(t_1 / Float64(a + a)); end tmp_1 = tmp_2; elseif (b <= 2.9e+39) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_3 = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(-Float64(c / b)); else tmp_1 = Float64(c / b); end return tmp_1 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) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); t_1 = -b - b; tmp_2 = 0.0; if (b <= -1.3e+150) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (c + c) / t_1; else tmp_3 = t_1 / (a + a); end tmp_2 = tmp_3; elseif (b <= 2.9e+39) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) / (-b - t_0); else tmp_4 = (-b + t_0) / (2.0 * a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = -(c / b); else tmp_2 = c / b; end tmp_5 = 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[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-b) - b), $MachinePrecision]}, If[LessEqual[b, -1.3e+150], If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / t$95$1), $MachinePrecision], N[(t$95$1 / N[(a + a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.9e+39], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], (-N[(c / b), $MachinePrecision]), N[(c / b), $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 - \left(4 \cdot a\right) \cdot c}\\
t_1 := \left(-b\right) - b\\
\mathbf{if}\;b \leq -1.3 \cdot 10^{+150}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{a + a}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{+39}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t_0}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
Results
if b < -1.30000000000000003e150Initial program 62.2
Simplified62.2
[Start]62.2 | \[ \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}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]62.2 | \[ \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}
\] |
metadata-eval [<=]62.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \color{blue}{\left(1 + 1\right)}}{\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}
\] |
metadata-eval [<=]62.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \left(\color{blue}{\frac{4}{4}} + 1\right)}{\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}
\] |
metadata-eval [<=]62.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \left(\frac{4}{4} + \color{blue}{\frac{4}{4}}\right)}{\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}
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [<=]62.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{\frac{4}{4} \cdot c + c \cdot \frac{4}{4}}}{\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}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]62.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{c \cdot \frac{4}{4}} + c \cdot \frac{4}{4}}{\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}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]62.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \frac{4}{4} + \color{blue}{\frac{4}{4} \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}
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [=>]62.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{\frac{4}{4} \cdot \left(c + c\right)}}{\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}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]62.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{\left(c + c\right) \cdot \frac{4}{4}}}{\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}
\] |
metadata-eval [=>]62.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(c + c\right) \cdot \color{blue}{1}}{\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}
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]62.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{c + 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}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]62.2 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{\left(-b\right) - \sqrt{b \cdot b - \color{blue}{c \cdot \left(4 \cdot 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 b around inf 62.2
Taylor expanded in b around -inf 2.3
Simplified2.3
[Start]2.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot b - b}{a + a}\\
\end{array}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]2.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -1 - b}{a + a}\\
\end{array}
\] |
rational_best_oopsla_all_46_json_45_simplify-94 [<=]2.3 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{a + a}\\
\end{array}
\] |
if -1.30000000000000003e150 < b < 2.90000000000000029e39Initial program 9.4
if 2.90000000000000029e39 < b Initial program 24.7
Simplified24.7
[Start]24.7 | \[ \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}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]24.7 | \[ \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}
\] |
metadata-eval [<=]24.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \color{blue}{\left(1 + 1\right)}}{\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}
\] |
metadata-eval [<=]24.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \left(\color{blue}{\frac{4}{4}} + 1\right)}{\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}
\] |
metadata-eval [<=]24.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \left(\frac{4}{4} + \color{blue}{\frac{4}{4}}\right)}{\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}
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [<=]24.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{\frac{4}{4} \cdot c + c \cdot \frac{4}{4}}}{\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}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]24.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{c \cdot \frac{4}{4}} + c \cdot \frac{4}{4}}{\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}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]24.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \frac{4}{4} + \color{blue}{\frac{4}{4} \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}
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [=>]24.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{\frac{4}{4} \cdot \left(c + c\right)}}{\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}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]24.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{\left(c + c\right) \cdot \frac{4}{4}}}{\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}
\] |
metadata-eval [=>]24.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(c + c\right) \cdot \color{blue}{1}}{\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}
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]24.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\color{blue}{c + 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}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]24.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{\left(-b\right) - \sqrt{b \cdot b - \color{blue}{c \cdot \left(4 \cdot 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 b around inf 8.1
Taylor expanded in b around -inf 8.1
Simplified8.1
[Start]8.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{\left(-b\right) - \left(b + -2 \cdot \frac{c \cdot a}{b}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(2 \cdot \frac{c \cdot a}{b} + -1 \cdot b\right) - b}{a + a}\\
\end{array}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]8.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{\left(-b\right) - \left(b + -2 \cdot \frac{c \cdot a}{b}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(2 \cdot \frac{c \cdot a}{b} + b \cdot -1\right) - b}{a + a}\\
\end{array}
\] |
rational_best_oopsla_all_46_json_45_simplify-94 [<=]8.1 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{\left(-b\right) - \left(b + -2 \cdot \frac{c \cdot a}{b}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(2 \cdot \frac{c \cdot a}{b} + \left(-b\right)\right) - b}{a + a}\\
\end{array}
\] |
Taylor expanded in c around inf 8.1
Taylor expanded in c around 0 4.7
Simplified4.7
[Start]4.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]4.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{\frac{c}{b} \cdot -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]4.7 | \[ \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\color{blue}{-\frac{c}{b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\] |
Final simplification7.2
| Alternative 1 | |
|---|---|
| Error | 11.1 |
| Cost | 7756 |
| Alternative 2 | |
|---|---|
| Error | 11.1 |
| Cost | 7756 |
| Alternative 3 | |
|---|---|
| Error | 14.8 |
| Cost | 7696 |
| Alternative 4 | |
|---|---|
| Error | 18.8 |
| Cost | 7368 |
| Alternative 5 | |
|---|---|
| Error | 22.9 |
| Cost | 644 |
| Alternative 6 | |
|---|---|
| Error | 40.3 |
| Cost | 388 |
| Alternative 7 | |
|---|---|
| Error | 61.7 |
| Cost | 324 |
herbie shell --seed 2023090
(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))))