
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
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) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); end tmp_2 = tmp; end
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]}, 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]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\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}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
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) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); end tmp_2 = tmp; end
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]}, 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]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\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}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_1 (/ (* b -2.0) (* 2.0 a)))
(t_2 (/ (- t_0 b) (* 2.0 a))))
(if (<= b -3.4e+161)
(if (>= b 0.0) (/ -1.0 (/ b c)) t_1)
(if (<= b -1.25e-174)
(if (>= b 0.0) (/ (* c 2.0) (* 2.0 (fma a (/ c b) (- b)))) t_2)
(if (<= b -5.6e-207)
(if (>= b 0.0)
(/ (* c 2.0) (- (* 2.0 (/ (* c a) b)) (* b 2.0)))
(* (/ 0.5 a) (- (hypot b (sqrt (* (* c a) -4.0))) b)))
(if (<= b 8.2e+130)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) t_2)
(if (>= b 0.0) (/ c (- b)) t_1)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = (b * -2.0) / (2.0 * a);
double t_2 = (t_0 - b) / (2.0 * a);
double tmp_1;
if (b <= -3.4e+161) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 / (b / c);
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= -1.25e-174) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_3 = t_2;
}
tmp_1 = tmp_3;
} else if (b <= -5.6e-207) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * 2.0) / ((2.0 * ((c * a) / b)) - (b * 2.0));
} else {
tmp_4 = (0.5 / a) * (hypot(b, sqrt(((c * a) * -4.0))) - b);
}
tmp_1 = tmp_4;
} else if (b <= 8.2e+130) {
double tmp_5;
if (b >= 0.0) {
tmp_5 = (c * 2.0) / (-b - t_0);
} else {
tmp_5 = t_2;
}
tmp_1 = tmp_5;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_1 = Float64(Float64(b * -2.0) / Float64(2.0 * a)) t_2 = Float64(Float64(t_0 - b) / Float64(2.0 * a)) tmp_1 = 0.0 if (b <= -3.4e+161) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 / Float64(b / c)); else tmp_2 = t_1; end tmp_1 = tmp_2; elseif (b <= -1.25e-174) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_3 = t_2; end tmp_1 = tmp_3; elseif (b <= -5.6e-207) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * 2.0) / Float64(Float64(2.0 * Float64(Float64(c * a) / b)) - Float64(b * 2.0))); else tmp_4 = Float64(Float64(0.5 / a) * Float64(hypot(b, sqrt(Float64(Float64(c * a) * -4.0))) - b)); end tmp_1 = tmp_4; elseif (b <= 8.2e+130) tmp_5 = 0.0 if (b >= 0.0) tmp_5 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_0)); else tmp_5 = t_2; end tmp_1 = tmp_5; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = t_1; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.4e+161], If[GreaterEqual[b, 0.0], N[(-1.0 / N[(b / c), $MachinePrecision]), $MachinePrecision], t$95$1], If[LessEqual[b, -1.25e-174], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2], If[LessEqual[b, -5.6e-207], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[b ^ 2 + N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 8.2e+130], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], t$95$2], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \frac{b \cdot -2}{2 \cdot a}\\
t_2 := \frac{t\_0 - b}{2 \cdot a}\\
\mathbf{if}\;b \leq -3.4 \cdot 10^{+161}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-1}{\frac{b}{c}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \leq -1.25 \cdot 10^{-174}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}\\
\mathbf{elif}\;b \leq -5.6 \cdot 10^{-207}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \frac{c \cdot a}{b} - b \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{\left(c \cdot a\right) \cdot -4}\right) - b\right)\\
\end{array}\\
\mathbf{elif}\;b \leq 8.2 \cdot 10^{+130}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -3.39999999999999993e161Initial program 35.6%
Taylor expanded in b around -inf 97.6%
*-commutative97.6%
Simplified97.6%
Applied egg-rr97.6%
clear-num97.6%
inv-pow97.6%
Applied egg-rr97.6%
unpow-197.6%
*-commutative97.6%
Simplified97.6%
Taylor expanded in b around inf 97.6%
associate-*r/97.6%
mul-1-neg97.6%
Simplified97.6%
if -3.39999999999999993e161 < b < -1.2500000000000001e-174Initial program 94.2%
Taylor expanded in a around 0 94.2%
distribute-lft-out--94.2%
associate-/l*94.2%
fma-neg94.2%
Simplified94.2%
if -1.2500000000000001e-174 < b < -5.59999999999999986e-207Initial program 74.3%
Taylor expanded in a around 0 74.3%
Applied egg-rr71.8%
associate-/r*71.8%
metadata-eval71.8%
metadata-eval71.8%
associate-*r/71.8%
*-commutative71.8%
associate-*r/71.8%
metadata-eval71.8%
Simplified71.8%
add-sqr-sqrt0.0%
sqrt-prod72.0%
sqr-neg72.0%
sqrt-unprod74.3%
add-sqr-sqrt74.3%
add-sqr-sqrt0.0%
sqrt-prod72.0%
sqr-neg72.0%
sqrt-unprod71.8%
add-sqr-sqrt71.8%
pow1/271.8%
metadata-eval71.8%
pow-div71.2%
pow171.2%
pow1/271.2%
frac-2neg71.2%
distribute-frac-neg71.2%
distribute-neg-frac271.2%
Applied egg-rr85.9%
neg-sub085.9%
sub-neg85.9%
+-commutative85.9%
distribute-neg-in85.9%
remove-double-neg85.9%
sub-neg85.9%
*-commutative85.9%
Simplified85.9%
if -5.59999999999999986e-207 < b < 8.19999999999999955e130Initial program 84.0%
if 8.19999999999999955e130 < b Initial program 52.2%
Taylor expanded in b around -inf 52.2%
*-commutative52.2%
Simplified52.2%
Taylor expanded in c around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
Simplified100.0%
Final simplification91.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* b -2.0) (* 2.0 a))) (t_1 (sqrt (fma c (* a -4.0) (* b b)))))
(if (<= b -3.4e+161)
(if (>= b 0.0) (/ -1.0 (/ b c)) t_0)
(if (<= b -1.25e-174)
(if (>= b 0.0)
(/ (* c 2.0) (* 2.0 (fma a (/ c b) (- b))))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a)))
(if (<= b -2.2e-206)
(if (>= b 0.0)
(/ (* c 2.0) (- (* 2.0 (/ (* c a) b)) (* b 2.0)))
(* (/ 0.5 a) (- (hypot b (sqrt (* (* c a) -4.0))) b)))
(if (<= b 7.8e-116)
(if (>= b 0.0) (* c (/ -2.0 (+ b t_1))) (/ (- b t_1) (* -2.0 a)))
(if (>= b 0.0)
(/
(* c 2.0)
(- (- b) (* b (sqrt (fma -4.0 (* (/ c b) (/ a b)) 1.0)))))
t_0)))))))
double code(double a, double b, double c) {
double t_0 = (b * -2.0) / (2.0 * a);
double t_1 = sqrt(fma(c, (a * -4.0), (b * b)));
double tmp_1;
if (b <= -3.4e+161) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 / (b / c);
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= -1.25e-174) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= -2.2e-206) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * 2.0) / ((2.0 * ((c * a) / b)) - (b * 2.0));
} else {
tmp_4 = (0.5 / a) * (hypot(b, sqrt(((c * a) * -4.0))) - b);
}
tmp_1 = tmp_4;
} else if (b <= 7.8e-116) {
double tmp_5;
if (b >= 0.0) {
tmp_5 = c * (-2.0 / (b + t_1));
} else {
tmp_5 = (b - t_1) / (-2.0 * a);
}
tmp_1 = tmp_5;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / (-b - (b * sqrt(fma(-4.0, ((c / b) * (a / b)), 1.0))));
} else {
tmp_1 = t_0;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(b * -2.0) / Float64(2.0 * a)) t_1 = sqrt(fma(c, Float64(a * -4.0), Float64(b * b))) tmp_1 = 0.0 if (b <= -3.4e+161) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 / Float64(b / c)); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b <= -1.25e-174) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= -2.2e-206) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * 2.0) / Float64(Float64(2.0 * Float64(Float64(c * a) / b)) - Float64(b * 2.0))); else tmp_4 = Float64(Float64(0.5 / a) * Float64(hypot(b, sqrt(Float64(Float64(c * a) * -4.0))) - b)); end tmp_1 = tmp_4; elseif (b <= 7.8e-116) tmp_5 = 0.0 if (b >= 0.0) tmp_5 = Float64(c * Float64(-2.0 / Float64(b + t_1))); else tmp_5 = Float64(Float64(b - t_1) / Float64(-2.0 * a)); end tmp_1 = tmp_5; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - Float64(b * sqrt(fma(-4.0, Float64(Float64(c / b) * Float64(a / b)), 1.0))))); else tmp_1 = t_0; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -3.4e+161], If[GreaterEqual[b, 0.0], N[(-1.0 / N[(b / c), $MachinePrecision]), $MachinePrecision], t$95$0], If[LessEqual[b, -1.25e-174], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -2.2e-206], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[b ^ 2 + N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 7.8e-116], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - t$95$1), $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - N[(b * N[Sqrt[N[(-4.0 * N[(N[(c / b), $MachinePrecision] * N[(a / b), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot -2}{2 \cdot a}\\
t_1 := \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\\
\mathbf{if}\;b \leq -3.4 \cdot 10^{+161}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-1}{\frac{b}{c}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{elif}\;b \leq -1.25 \cdot 10^{-174}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq -2.2 \cdot 10^{-206}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \frac{c \cdot a}{b} - b \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{\left(c \cdot a\right) \cdot -4}\right) - b\right)\\
\end{array}\\
\mathbf{elif}\;b \leq 7.8 \cdot 10^{-116}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - t\_1}{-2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - b \cdot \sqrt{\mathsf{fma}\left(-4, \frac{c}{b} \cdot \frac{a}{b}, 1\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -3.39999999999999993e161Initial program 35.6%
Taylor expanded in b around -inf 97.6%
*-commutative97.6%
Simplified97.6%
Applied egg-rr97.6%
clear-num97.6%
inv-pow97.6%
Applied egg-rr97.6%
unpow-197.6%
*-commutative97.6%
Simplified97.6%
Taylor expanded in b around inf 97.6%
associate-*r/97.6%
mul-1-neg97.6%
Simplified97.6%
if -3.39999999999999993e161 < b < -1.2500000000000001e-174Initial program 94.2%
Taylor expanded in a around 0 94.2%
distribute-lft-out--94.2%
associate-/l*94.2%
fma-neg94.2%
Simplified94.2%
if -1.2500000000000001e-174 < b < -2.1999999999999999e-206Initial program 74.3%
Taylor expanded in a around 0 74.3%
Applied egg-rr71.8%
associate-/r*71.8%
metadata-eval71.8%
metadata-eval71.8%
associate-*r/71.8%
*-commutative71.8%
associate-*r/71.8%
metadata-eval71.8%
Simplified71.8%
add-sqr-sqrt0.0%
sqrt-prod72.0%
sqr-neg72.0%
sqrt-unprod74.3%
add-sqr-sqrt74.3%
add-sqr-sqrt0.0%
sqrt-prod72.0%
sqr-neg72.0%
sqrt-unprod71.8%
add-sqr-sqrt71.8%
pow1/271.8%
metadata-eval71.8%
pow-div71.2%
pow171.2%
pow1/271.2%
frac-2neg71.2%
distribute-frac-neg71.2%
distribute-neg-frac271.2%
Applied egg-rr85.9%
neg-sub085.9%
sub-neg85.9%
+-commutative85.9%
distribute-neg-in85.9%
remove-double-neg85.9%
sub-neg85.9%
*-commutative85.9%
Simplified85.9%
if -2.1999999999999999e-206 < b < 7.8000000000000001e-116Initial program 76.0%
Simplified76.0%
if 7.8000000000000001e-116 < b Initial program 75.5%
Taylor expanded in b around -inf 75.5%
*-commutative75.5%
Simplified75.5%
Taylor expanded in b around inf 74.5%
associate-/l*72.6%
Simplified72.6%
*-commutative72.6%
sqrt-prod74.5%
+-commutative74.5%
fma-define74.5%
div-inv74.5%
pow-flip74.5%
metadata-eval74.5%
sqrt-pow193.0%
metadata-eval93.0%
pow193.0%
Applied egg-rr93.0%
add-sqr-sqrt62.3%
pow262.3%
sqrt-prod39.9%
sqrt-pow139.9%
metadata-eval39.9%
unpow-139.9%
Applied egg-rr39.9%
unpow239.9%
associate-*r/39.9%
*-rgt-identity39.9%
associate-*r/39.9%
associate-*r/39.9%
*-rgt-identity39.9%
associate-*l/39.9%
rem-square-sqrt93.0%
Simplified93.0%
associate-*r/93.0%
clear-num93.0%
un-div-inv93.5%
Applied egg-rr93.5%
*-un-lft-identity93.5%
associate-/r/94.0%
Applied egg-rr94.0%
*-lft-identity94.0%
associate-/l*94.0%
Simplified94.0%
Final simplification91.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* b -2.0) (* 2.0 a))) (t_1 (sqrt (fma c (* a -4.0) (* b b)))))
(if (<= b -3.4e+161)
(if (>= b 0.0) (/ -1.0 (/ b c)) t_0)
(if (<= b -1.25e-174)
(if (>= b 0.0)
(/ (* c 2.0) (* 2.0 (fma a (/ c b) (- b))))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a)))
(if (<= b -2.55e-207)
(if (>= b 0.0)
(/ (* c 2.0) (- (* 2.0 (/ (* c a) b)) (* b 2.0)))
(* (/ 0.5 a) (- (hypot b (sqrt (* (* c a) -4.0))) b)))
(if (<= b 8.2e-105)
(if (>= b 0.0) (* c (/ -2.0 (+ b t_1))) (/ (- b t_1) (* -2.0 a)))
(if (>= b 0.0)
(/
(* c (- 2.0))
(+ b (* b (sqrt (fma -4.0 (* a (/ (/ c b) b)) 1.0)))))
t_0)))))))
double code(double a, double b, double c) {
double t_0 = (b * -2.0) / (2.0 * a);
double t_1 = sqrt(fma(c, (a * -4.0), (b * b)));
double tmp_1;
if (b <= -3.4e+161) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 / (b / c);
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= -1.25e-174) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= -2.55e-207) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * 2.0) / ((2.0 * ((c * a) / b)) - (b * 2.0));
} else {
tmp_4 = (0.5 / a) * (hypot(b, sqrt(((c * a) * -4.0))) - b);
}
tmp_1 = tmp_4;
} else if (b <= 8.2e-105) {
double tmp_5;
if (b >= 0.0) {
tmp_5 = c * (-2.0 / (b + t_1));
} else {
tmp_5 = (b - t_1) / (-2.0 * a);
}
tmp_1 = tmp_5;
} else if (b >= 0.0) {
tmp_1 = (c * -2.0) / (b + (b * sqrt(fma(-4.0, (a * ((c / b) / b)), 1.0))));
} else {
tmp_1 = t_0;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(b * -2.0) / Float64(2.0 * a)) t_1 = sqrt(fma(c, Float64(a * -4.0), Float64(b * b))) tmp_1 = 0.0 if (b <= -3.4e+161) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 / Float64(b / c)); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b <= -1.25e-174) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= -2.55e-207) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * 2.0) / Float64(Float64(2.0 * Float64(Float64(c * a) / b)) - Float64(b * 2.0))); else tmp_4 = Float64(Float64(0.5 / a) * Float64(hypot(b, sqrt(Float64(Float64(c * a) * -4.0))) - b)); end tmp_1 = tmp_4; elseif (b <= 8.2e-105) tmp_5 = 0.0 if (b >= 0.0) tmp_5 = Float64(c * Float64(-2.0 / Float64(b + t_1))); else tmp_5 = Float64(Float64(b - t_1) / Float64(-2.0 * a)); end tmp_1 = tmp_5; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * Float64(-2.0)) / Float64(b + Float64(b * sqrt(fma(-4.0, Float64(a * Float64(Float64(c / b) / b)), 1.0))))); else tmp_1 = t_0; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -3.4e+161], If[GreaterEqual[b, 0.0], N[(-1.0 / N[(b / c), $MachinePrecision]), $MachinePrecision], t$95$0], If[LessEqual[b, -1.25e-174], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -2.55e-207], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[b ^ 2 + N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 8.2e-105], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - t$95$1), $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * (-2.0)), $MachinePrecision] / N[(b + N[(b * N[Sqrt[N[(-4.0 * N[(a * N[(N[(c / b), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot -2}{2 \cdot a}\\
t_1 := \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\\
\mathbf{if}\;b \leq -3.4 \cdot 10^{+161}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-1}{\frac{b}{c}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{elif}\;b \leq -1.25 \cdot 10^{-174}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq -2.55 \cdot 10^{-207}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \frac{c \cdot a}{b} - b \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\mathsf{hypot}\left(b, \sqrt{\left(c \cdot a\right) \cdot -4}\right) - b\right)\\
\end{array}\\
\mathbf{elif}\;b \leq 8.2 \cdot 10^{-105}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - t\_1}{-2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \left(-2\right)}{b + b \cdot \sqrt{\mathsf{fma}\left(-4, a \cdot \frac{\frac{c}{b}}{b}, 1\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -3.39999999999999993e161Initial program 35.6%
Taylor expanded in b around -inf 97.6%
*-commutative97.6%
Simplified97.6%
Applied egg-rr97.6%
clear-num97.6%
inv-pow97.6%
Applied egg-rr97.6%
unpow-197.6%
*-commutative97.6%
Simplified97.6%
Taylor expanded in b around inf 97.6%
associate-*r/97.6%
mul-1-neg97.6%
Simplified97.6%
if -3.39999999999999993e161 < b < -1.2500000000000001e-174Initial program 94.2%
Taylor expanded in a around 0 94.2%
distribute-lft-out--94.2%
associate-/l*94.2%
fma-neg94.2%
Simplified94.2%
if -1.2500000000000001e-174 < b < -2.5500000000000002e-207Initial program 74.3%
Taylor expanded in a around 0 74.3%
Applied egg-rr71.8%
associate-/r*71.8%
metadata-eval71.8%
metadata-eval71.8%
associate-*r/71.8%
*-commutative71.8%
associate-*r/71.8%
metadata-eval71.8%
Simplified71.8%
add-sqr-sqrt0.0%
sqrt-prod72.0%
sqr-neg72.0%
sqrt-unprod74.3%
add-sqr-sqrt74.3%
add-sqr-sqrt0.0%
sqrt-prod72.0%
sqr-neg72.0%
sqrt-unprod71.8%
add-sqr-sqrt71.8%
pow1/271.8%
metadata-eval71.8%
pow-div71.2%
pow171.2%
pow1/271.2%
frac-2neg71.2%
distribute-frac-neg71.2%
distribute-neg-frac271.2%
Applied egg-rr85.9%
neg-sub085.9%
sub-neg85.9%
+-commutative85.9%
distribute-neg-in85.9%
remove-double-neg85.9%
sub-neg85.9%
*-commutative85.9%
Simplified85.9%
if -2.5500000000000002e-207 < b < 8.20000000000000061e-105Initial program 76.4%
Simplified76.5%
if 8.20000000000000061e-105 < b Initial program 75.2%
Taylor expanded in b around -inf 75.2%
*-commutative75.2%
Simplified75.2%
Taylor expanded in b around inf 75.2%
associate-/l*73.3%
Simplified73.3%
*-commutative73.3%
sqrt-prod75.2%
+-commutative75.2%
fma-define75.2%
div-inv75.2%
pow-flip75.2%
metadata-eval75.2%
sqrt-pow193.9%
metadata-eval93.9%
pow193.9%
Applied egg-rr93.9%
add-sqr-sqrt62.9%
pow262.9%
sqrt-prod40.2%
sqrt-pow140.2%
metadata-eval40.2%
unpow-140.2%
Applied egg-rr40.2%
unpow240.2%
associate-*r/40.2%
*-rgt-identity40.2%
associate-*r/40.2%
associate-*r/40.2%
*-rgt-identity40.2%
associate-*l/40.2%
rem-square-sqrt93.9%
Simplified93.9%
Final simplification91.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* c 2.0) (* 2.0 (fma a (/ c b) (- b)))))
(t_1 (/ (* b -2.0) (* 2.0 a)))
(t_2
(if (>= b 0.0) (/ (* c 2.0) (- (- b) (sqrt (* (* c a) -4.0)))) t_1)))
(if (<= b -4.8e+178)
(if (>= b 0.0) (/ -1.0 (/ b c)) t_1)
(if (<= b -7.5e-240)
(if (>= b 0.0)
t_0
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a)))
(if (<= b 1.28e-107)
t_2
(if (<= b 4.9e-86)
(if (>= b 0.0) (/ c (- (* c (/ a b)) b)) (/ (- (- b) b) (* 2.0 a)))
(if (<= b 8.6e-48)
t_2
(if (>= b 0.0) t_0 (/ (/ (* a (* c -2.0)) b) (* 2.0 a))))))))))
double code(double a, double b, double c) {
double t_0 = (c * 2.0) / (2.0 * fma(a, (c / b), -b));
double t_1 = (b * -2.0) / (2.0 * a);
double tmp;
if (b >= 0.0) {
tmp = (c * 2.0) / (-b - sqrt(((c * a) * -4.0)));
} else {
tmp = t_1;
}
double t_2 = tmp;
double tmp_2;
if (b <= -4.8e+178) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -1.0 / (b / c);
} else {
tmp_3 = t_1;
}
tmp_2 = tmp_3;
} else if (b <= -7.5e-240) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = t_0;
} else {
tmp_4 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
}
tmp_2 = tmp_4;
} else if (b <= 1.28e-107) {
tmp_2 = t_2;
} else if (b <= 4.9e-86) {
double tmp_5;
if (b >= 0.0) {
tmp_5 = c / ((c * (a / b)) - b);
} else {
tmp_5 = (-b - b) / (2.0 * a);
}
tmp_2 = tmp_5;
} else if (b <= 8.6e-48) {
tmp_2 = t_2;
} else if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = ((a * (c * -2.0)) / b) / (2.0 * a);
}
return tmp_2;
}
function code(a, b, c) t_0 = Float64(Float64(c * 2.0) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))) t_1 = Float64(Float64(b * -2.0) / Float64(2.0 * a)) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(c * 2.0) / Float64(Float64(-b) - sqrt(Float64(Float64(c * a) * -4.0)))); else tmp = t_1; end t_2 = tmp tmp_2 = 0.0 if (b <= -4.8e+178) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-1.0 / Float64(b / c)); else tmp_3 = t_1; end tmp_2 = tmp_3; elseif (b <= -7.5e-240) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = t_0; else tmp_4 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a)); end tmp_2 = tmp_4; elseif (b <= 1.28e-107) tmp_2 = t_2; elseif (b <= 4.9e-86) tmp_5 = 0.0 if (b >= 0.0) tmp_5 = Float64(c / Float64(Float64(c * Float64(a / b)) - b)); else tmp_5 = Float64(Float64(Float64(-b) - b) / Float64(2.0 * a)); end tmp_2 = tmp_5; elseif (b <= 8.6e-48) tmp_2 = t_2; elseif (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(Float64(Float64(a * Float64(c * -2.0)) / b) / Float64(2.0 * a)); end return tmp_2 end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]}, If[LessEqual[b, -4.8e+178], If[GreaterEqual[b, 0.0], N[(-1.0 / N[(b / c), $MachinePrecision]), $MachinePrecision], t$95$1], If[LessEqual[b, -7.5e-240], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.28e-107], t$95$2, If[LessEqual[b, 4.9e-86], If[GreaterEqual[b, 0.0], N[(c / N[(N[(c * N[(a / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 8.6e-48], t$95$2, If[GreaterEqual[b, 0.0], t$95$0, N[(N[(N[(a * N[(c * -2.0), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
t_1 := \frac{b \cdot -2}{2 \cdot a}\\
t_2 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{\left(c \cdot a\right) \cdot -4}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{if}\;b \leq -4.8 \cdot 10^{+178}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-1}{\frac{b}{c}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \leq -7.5 \cdot 10^{-240}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.28 \cdot 10^{-107}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \leq 4.9 \cdot 10^{-86}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{c \cdot \frac{a}{b} - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{-48}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a \cdot \left(c \cdot -2\right)}{b}}{2 \cdot a}\\
\end{array}
\end{array}
if b < -4.8e178Initial program 37.5%
Taylor expanded in b around -inf 97.2%
*-commutative97.2%
Simplified97.2%
Applied egg-rr97.2%
clear-num97.2%
inv-pow97.2%
Applied egg-rr97.2%
unpow-197.2%
*-commutative97.2%
Simplified97.2%
Taylor expanded in b around inf 97.2%
associate-*r/97.2%
mul-1-neg97.2%
Simplified97.2%
if -4.8e178 < b < -7.4999999999999995e-240Initial program 86.1%
Taylor expanded in a around 0 86.1%
distribute-lft-out--86.1%
associate-/l*86.1%
fma-neg86.1%
Simplified86.1%
if -7.4999999999999995e-240 < b < 1.28e-107 or 4.89999999999999972e-86 < b < 8.6e-48Initial program 77.7%
Taylor expanded in b around -inf 68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in b around 0 66.8%
if 1.28e-107 < b < 4.89999999999999972e-86Initial program 84.0%
Taylor expanded in a around 0 84.0%
Taylor expanded in b around -inf 84.0%
div-inv84.0%
*-commutative84.0%
Applied egg-rr84.0%
div-inv83.7%
*-commutative83.7%
associate-*l*83.7%
distribute-lft-out--83.7%
*-commutative83.7%
associate-*r*83.7%
div-inv83.7%
clear-num83.7%
un-div-inv83.7%
Applied egg-rr83.7%
associate-*r*83.7%
associate-*r/84.0%
*-rgt-identity84.0%
*-commutative84.0%
times-frac84.0%
metadata-eval84.0%
*-lft-identity84.0%
Simplified84.0%
associate-/r/84.0%
Applied egg-rr84.0%
if 8.6e-48 < b Initial program 74.9%
Taylor expanded in a around 0 85.3%
distribute-lft-out--85.3%
associate-/l*86.4%
fma-neg86.4%
Simplified86.4%
Taylor expanded in b around inf 86.4%
associate-*r/86.4%
*-commutative86.4%
associate-*r*86.4%
Simplified86.4%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_1 (/ (* b -2.0) (* 2.0 a))))
(if (<= b -4.8e+178)
(if (>= b 0.0) (/ -1.0 (/ b c)) t_1)
(if (<= b -7.5e-240)
(if (>= b 0.0)
(/ (* c 2.0) (* 2.0 (fma a (/ c b) (- b))))
(/ (- t_0 b) (* 2.0 a)))
(if (<= b 1.5e+131)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) t_1)
(if (>= b 0.0) (/ c (- b)) t_1))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = (b * -2.0) / (2.0 * a);
double tmp_1;
if (b <= -4.8e+178) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 / (b / c);
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= -7.5e-240) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 1.5e+131) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * 2.0) / (-b - t_0);
} else {
tmp_4 = t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_1 = Float64(Float64(b * -2.0) / Float64(2.0 * a)) tmp_1 = 0.0 if (b <= -4.8e+178) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 / Float64(b / c)); else tmp_2 = t_1; end tmp_1 = tmp_2; elseif (b <= -7.5e-240) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= 1.5e+131) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_0)); else tmp_4 = t_1; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = t_1; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4.8e+178], If[GreaterEqual[b, 0.0], N[(-1.0 / N[(b / c), $MachinePrecision]), $MachinePrecision], t$95$1], If[LessEqual[b, -7.5e-240], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.5e+131], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \frac{b \cdot -2}{2 \cdot a}\\
\mathbf{if}\;b \leq -4.8 \cdot 10^{+178}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-1}{\frac{b}{c}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \leq -7.5 \cdot 10^{-240}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{+131}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -4.8e178Initial program 37.5%
Taylor expanded in b around -inf 97.2%
*-commutative97.2%
Simplified97.2%
Applied egg-rr97.2%
clear-num97.2%
inv-pow97.2%
Applied egg-rr97.2%
unpow-197.2%
*-commutative97.2%
Simplified97.2%
Taylor expanded in b around inf 97.2%
associate-*r/97.2%
mul-1-neg97.2%
Simplified97.2%
if -4.8e178 < b < -7.4999999999999995e-240Initial program 86.1%
Taylor expanded in a around 0 86.1%
distribute-lft-out--86.1%
associate-/l*86.1%
fma-neg86.1%
Simplified86.1%
if -7.4999999999999995e-240 < b < 1.5000000000000001e131Initial program 85.5%
Taylor expanded in b around -inf 81.6%
*-commutative81.6%
Simplified81.6%
if 1.5000000000000001e131 < b Initial program 52.2%
Taylor expanded in b around -inf 52.2%
*-commutative52.2%
Simplified52.2%
Taylor expanded in c around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
Simplified100.0%
Final simplification87.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_1 (/ (* b -2.0) (* 2.0 a))))
(if (<= b -4.8e+178)
(if (>= b 0.0) (/ -1.0 (/ b c)) t_1)
(if (<= b 1e+131)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) (/ (- t_0 b) (* 2.0 a)))
(if (>= b 0.0) (/ c (- b)) t_1)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = (b * -2.0) / (2.0 * a);
double tmp_1;
if (b <= -4.8e+178) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 / (b / c);
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 1e+131) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = t_1;
}
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) :: 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) - (c * (a * 4.0d0))))
t_1 = (b * (-2.0d0)) / (2.0d0 * a)
if (b <= (-4.8d+178)) then
if (b >= 0.0d0) then
tmp_2 = (-1.0d0) / (b / c)
else
tmp_2 = t_1
end if
tmp_1 = tmp_2
else if (b <= 1d+131) then
if (b >= 0.0d0) then
tmp_3 = (c * 2.0d0) / (-b - t_0)
else
tmp_3 = (t_0 - b) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = c / -b
else
tmp_1 = t_1
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = (b * -2.0) / (2.0 * a);
double tmp_1;
if (b <= -4.8e+178) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 / (b / c);
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 1e+131) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_1 = (b * -2.0) / (2.0 * a) tmp_1 = 0 if b <= -4.8e+178: tmp_2 = 0 if b >= 0.0: tmp_2 = -1.0 / (b / c) else: tmp_2 = t_1 tmp_1 = tmp_2 elif b <= 1e+131: tmp_3 = 0 if b >= 0.0: tmp_3 = (c * 2.0) / (-b - t_0) else: tmp_3 = (t_0 - b) / (2.0 * a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = c / -b else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_1 = Float64(Float64(b * -2.0) / Float64(2.0 * a)) tmp_1 = 0.0 if (b <= -4.8e+178) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 / Float64(b / c)); else tmp_2 = t_1; end tmp_1 = tmp_2; elseif (b <= 1e+131) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = t_1; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); t_1 = (b * -2.0) / (2.0 * a); tmp_2 = 0.0; if (b <= -4.8e+178) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -1.0 / (b / c); else tmp_3 = t_1; end tmp_2 = tmp_3; elseif (b <= 1e+131) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (c * 2.0) / (-b - t_0); else tmp_4 = (t_0 - b) / (2.0 * a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = c / -b; else tmp_2 = t_1; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4.8e+178], If[GreaterEqual[b, 0.0], N[(-1.0 / N[(b / c), $MachinePrecision]), $MachinePrecision], t$95$1], If[LessEqual[b, 1e+131], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \frac{b \cdot -2}{2 \cdot a}\\
\mathbf{if}\;b \leq -4.8 \cdot 10^{+178}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-1}{\frac{b}{c}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+131}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -4.8e178Initial program 37.5%
Taylor expanded in b around -inf 97.2%
*-commutative97.2%
Simplified97.2%
Applied egg-rr97.2%
clear-num97.2%
inv-pow97.2%
Applied egg-rr97.2%
unpow-197.2%
*-commutative97.2%
Simplified97.2%
Taylor expanded in b around inf 97.2%
associate-*r/97.2%
mul-1-neg97.2%
Simplified97.2%
if -4.8e178 < b < 9.9999999999999991e130Initial program 85.8%
if 9.9999999999999991e130 < b Initial program 52.2%
Taylor expanded in b around -inf 52.2%
*-commutative52.2%
Simplified52.2%
Taylor expanded in c around 0 100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
Simplified100.0%
Final simplification89.3%
(FPCore (a b c)
:precision binary64
(if (<= b 1.15e-142)
(if (>= b 0.0)
(/ (* c 2.0) (- (- b) (sqrt (* (* c a) -4.0))))
(/ (* b -2.0) (* 2.0 a)))
(if (>= b 0.0) (/ c (- (/ a (/ b c)) b)) (/ (- (- b) b) (* 2.0 a)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= 1.15e-142) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c * 2.0) / (-b - sqrt(((c * a) * -4.0)));
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = c / ((a / (b / c)) - b);
} else {
tmp_1 = (-b - b) / (2.0 * a);
}
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
real(8) :: tmp_1
real(8) :: tmp_2
if (b <= 1.15d-142) then
if (b >= 0.0d0) then
tmp_2 = (c * 2.0d0) / (-b - sqrt(((c * a) * (-4.0d0))))
else
tmp_2 = (b * (-2.0d0)) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = c / ((a / (b / c)) - b)
else
tmp_1 = (-b - b) / (2.0d0 * a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= 1.15e-142) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c * 2.0) / (-b - Math.sqrt(((c * a) * -4.0)));
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = c / ((a / (b / c)) - b);
} else {
tmp_1 = (-b - b) / (2.0 * a);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= 1.15e-142: tmp_2 = 0 if b >= 0.0: tmp_2 = (c * 2.0) / (-b - math.sqrt(((c * a) * -4.0))) else: tmp_2 = (b * -2.0) / (2.0 * a) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = c / ((a / (b / c)) - b) else: tmp_1 = (-b - b) / (2.0 * a) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= 1.15e-142) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - sqrt(Float64(Float64(c * a) * -4.0)))); else tmp_2 = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(Float64(a / Float64(b / c)) - b)); else tmp_1 = Float64(Float64(Float64(-b) - b) / Float64(2.0 * a)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= 1.15e-142) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (c * 2.0) / (-b - sqrt(((c * a) * -4.0))); else tmp_3 = (b * -2.0) / (2.0 * a); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = c / ((a / (b / c)) - b); else tmp_2 = (-b - b) / (2.0 * a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, 1.15e-142], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / N[(N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.15 \cdot 10^{-142}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{\left(c \cdot a\right) \cdot -4}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{\frac{a}{\frac{b}{c}} - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < 1.15000000000000001e-142Initial program 73.8%
Taylor expanded in b around -inf 69.1%
*-commutative69.1%
Simplified69.1%
Taylor expanded in b around 0 69.1%
if 1.15000000000000001e-142 < b Initial program 76.2%
Taylor expanded in a around 0 80.6%
Taylor expanded in b around -inf 80.6%
div-inv80.6%
*-commutative80.6%
Applied egg-rr80.6%
div-inv80.3%
*-commutative80.3%
associate-*l*80.3%
distribute-lft-out--80.3%
*-commutative80.3%
associate-*r*81.3%
div-inv81.3%
clear-num81.3%
un-div-inv81.3%
Applied egg-rr81.3%
associate-*r*81.3%
associate-*r/81.6%
*-rgt-identity81.6%
*-commutative81.6%
times-frac81.6%
metadata-eval81.6%
*-lft-identity81.6%
Simplified81.6%
Final simplification74.0%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ c (- b)) (/ (* b -2.0) (* 2.0 a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / -b;
} else {
tmp = (b * -2.0) / (2.0 * a);
}
return tmp;
}
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 = c / -b
else
tmp = (b * (-2.0d0)) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / -b;
} else {
tmp = (b * -2.0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c / -b else: tmp = (b * -2.0) / (2.0 * a) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c / Float64(-b)); else tmp = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c / -b; else tmp = (b * -2.0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}
\end{array}
Initial program 74.8%
Taylor expanded in b around -inf 71.9%
*-commutative71.9%
Simplified71.9%
Taylor expanded in c around 0 66.4%
mul-1-neg66.4%
distribute-neg-frac266.4%
Simplified66.4%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ -1.0 (/ b c)) (/ (* b -2.0) (* 2.0 a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -1.0 / (b / c);
} else {
tmp = (b * -2.0) / (2.0 * a);
}
return tmp;
}
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 = (-1.0d0) / (b / c)
else
tmp = (b * (-2.0d0)) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -1.0 / (b / c);
} else {
tmp = (b * -2.0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -1.0 / (b / c) else: tmp = (b * -2.0) / (2.0 * a) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-1.0 / Float64(b / c)); else tmp = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -1.0 / (b / c); else tmp = (b * -2.0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-1.0 / N[(b / c), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-1}{\frac{b}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}
\end{array}
Initial program 74.8%
Taylor expanded in b around -inf 71.9%
*-commutative71.9%
Simplified71.9%
Applied egg-rr66.1%
clear-num66.1%
inv-pow66.1%
Applied egg-rr66.9%
unpow-166.9%
*-commutative66.9%
Simplified66.9%
Taylor expanded in b around inf 66.2%
associate-*r/66.2%
mul-1-neg66.2%
Simplified66.2%
Final simplification66.2%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ b a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = b / a;
} else {
tmp = c / b;
}
return tmp;
}
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 = b / a
else
tmp = c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(b / a); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
Initial program 74.8%
Taylor expanded in a around 0 68.9%
Taylor expanded in b around -inf 65.0%
mul-1-neg65.0%
distribute-rgt-neg-in65.0%
+-commutative65.0%
mul-1-neg65.0%
unsub-neg65.0%
Simplified65.0%
Taylor expanded in b around 0 34.7%
Taylor expanded in c around inf 3.6%
herbie shell --seed 2024107
(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))))