
(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))))))
(if (<= b -3e+148)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (- (/ c b) (/ b a)))
(if (<= b 1e+149)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (- t_0 b) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (- (- (* -2.0 (* (/ c b) (- a))) b) b))
(fma -1.0 (/ b a) (/ c b)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -3e+148) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 1e+149) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (((-2.0 * ((c / b) * -a)) - b) - b);
} else {
tmp_1 = fma(-1.0, (b / a), (c / b));
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp_1 = 0.0 if (b <= -3e+148) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= 1e+149) 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(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(Float64(-2.0 * Float64(Float64(c / b) * Float64(-a))) - b) - b)); else tmp_1 = fma(-1.0, Float64(b / a), Float64(c / b)); 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]}, If[LessEqual[b, -3e+148], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1e+149], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $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[(N[(2.0 * c), $MachinePrecision] / N[(N[(N[(-2.0 * N[(N[(c / b), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -3 \cdot 10^{+148}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+149}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-2 \cdot \left(\frac{c}{b} \cdot \left(-a\right)\right) - b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\end{array}
\end{array}
if b < -3.00000000000000015e148Initial program 35.2%
Taylor expanded in b around inf 35.2%
*-commutative35.2%
Simplified35.2%
Taylor expanded in b around -inf 94.0%
+-commutative94.0%
mul-1-neg94.0%
unsub-neg94.0%
Simplified94.0%
if -3.00000000000000015e148 < b < 1.00000000000000005e149Initial program 87.5%
if 1.00000000000000005e149 < b Initial program 43.0%
Taylor expanded in b around -inf 43.0%
fma-def43.0%
Simplified43.0%
Taylor expanded in b around inf 93.9%
associate-*r/96.3%
Simplified96.3%
Final simplification90.2%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -5e+150)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (- (/ c b) (/ b a)))
(if (<= b -5e-311)
(if (>= b 0.0)
(/ 1.0 (/ (fma b -2.0 (/ 2.0 (/ (/ b a) c))) (* 2.0 c)))
(/ (- t_0 b) (* 2.0 a)))
(if (<= b 5e+141)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (- b) a))
(if (>= b 0.0)
(/ (* 2.0 c) (- (- (* -2.0 (* (/ c b) (- a))) b) b))
(fma -1.0 (/ b a) (/ c b))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -5e+150) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= -5e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 1.0 / (fma(b, -2.0, (2.0 / ((b / a) / c))) / (2.0 * c));
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 5e+141) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - t_0);
} else {
tmp_4 = -b / a;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (((-2.0 * ((c / b) * -a)) - b) - b);
} else {
tmp_1 = fma(-1.0, (b / a), (c / b));
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp_1 = 0.0 if (b <= -5e+150) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= -5e-311) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(1.0 / Float64(fma(b, -2.0, Float64(2.0 / Float64(Float64(b / a) / c))) / Float64(2.0 * c))); else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= 5e+141) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_4 = Float64(Float64(-b) / a); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(Float64(-2.0 * Float64(Float64(c / b) * Float64(-a))) - b) - b)); else tmp_1 = fma(-1.0, Float64(b / a), Float64(c / b)); 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]}, If[LessEqual[b, -5e+150], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -5e-311], If[GreaterEqual[b, 0.0], N[(1.0 / N[(N[(b * -2.0 + N[(2.0 / N[(N[(b / a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 5e+141], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(N[(N[(-2.0 * N[(N[(c / b), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -5 \cdot 10^{+150}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(b, -2, \frac{2}{\frac{\frac{b}{a}}{c}}\right)}{2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+141}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-2 \cdot \left(\frac{c}{b} \cdot \left(-a\right)\right) - b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\end{array}
\end{array}
if b < -5.00000000000000009e150Initial program 35.2%
Taylor expanded in b around inf 35.2%
*-commutative35.2%
Simplified35.2%
Taylor expanded in b around -inf 94.0%
+-commutative94.0%
mul-1-neg94.0%
unsub-neg94.0%
Simplified94.0%
if -5.00000000000000009e150 < b < -5.00000000000023e-311Initial program 95.2%
Taylor expanded in b around inf 95.2%
*-commutative95.2%
fma-def95.2%
*-commutative95.2%
associate-/l*95.2%
Simplified95.2%
clear-num95.2%
inv-pow95.2%
Applied egg-rr95.2%
clear-num95.2%
inv-pow95.2%
*-commutative95.2%
unpow-195.2%
associate-/l/95.2%
*-commutative95.2%
Applied egg-rr95.2%
unpow-195.2%
associate-*r/95.2%
metadata-eval95.2%
*-commutative95.2%
associate-/r*95.2%
*-commutative95.2%
Simplified95.2%
if -5.00000000000023e-311 < b < 5.00000000000000025e141Initial program 79.5%
Taylor expanded in b around -inf 79.5%
associate-*r/79.5%
mul-1-neg79.5%
Simplified79.5%
if 5.00000000000000025e141 < b Initial program 43.0%
Taylor expanded in b around -inf 43.0%
fma-def43.0%
Simplified43.0%
Taylor expanded in b around inf 93.9%
associate-*r/96.3%
Simplified96.3%
Final simplification90.2%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* 2.0 c) (* b -2.0))) (t_1 (sqrt (* a (* c -4.0)))))
(if (<= b -1.4e-69)
(if (>= b 0.0) t_0 (- (/ c b) (/ b a)))
(if (<= b -5e-311)
(if (>= b 0.0) t_0 (/ (- t_1 b) (* 2.0 a)))
(if (<= b 3.8e-75)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_1)) (+ (/ c b) (/ b a)))
(if (>= b 0.0)
(/ (* 2.0 c) (fma b -2.0 (* 2.0 (/ a (/ b c)))))
(fma -1.0 (/ b a) (/ c b))))))))
double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (b * -2.0);
double t_1 = sqrt((a * (c * -4.0)));
double tmp_1;
if (b <= -1.4e-69) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= -5e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = (t_1 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 3.8e-75) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - t_1);
} else {
tmp_4 = (c / b) + (b / a);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / fma(b, -2.0, (2.0 * (a / (b / c))));
} else {
tmp_1 = fma(-1.0, (b / a), (c / b));
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(2.0 * c) / Float64(b * -2.0)) t_1 = sqrt(Float64(a * Float64(c * -4.0))) tmp_1 = 0.0 if (b <= -1.4e-69) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= -5e-311) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_0; else tmp_3 = Float64(Float64(t_1 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= 3.8e-75) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_1)); else tmp_4 = Float64(Float64(c / b) + Float64(b / a)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / fma(b, -2.0, Float64(2.0 * Float64(a / Float64(b / c))))); else tmp_1 = fma(-1.0, Float64(b / a), Float64(c / b)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1.4e-69], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -5e-311], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(t$95$1 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 3.8e-75], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] + N[(b / a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0 + N[(2.0 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2 \cdot c}{b \cdot -2}\\
t_1 := \sqrt{a \cdot \left(c \cdot -4\right)}\\
\mathbf{if}\;b \leq -1.4 \cdot 10^{-69}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{-75}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} + \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(b, -2, 2 \cdot \frac{a}{\frac{b}{c}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\end{array}
\end{array}
if b < -1.3999999999999999e-69Initial program 66.1%
Taylor expanded in b around inf 66.1%
*-commutative66.1%
Simplified66.1%
Taylor expanded in b around -inf 88.0%
+-commutative88.0%
mul-1-neg88.0%
unsub-neg88.0%
Simplified88.0%
if -1.3999999999999999e-69 < b < -5.00000000000023e-311Initial program 97.1%
Taylor expanded in b around inf 97.1%
*-commutative97.1%
Simplified97.1%
Taylor expanded in b around 0 87.5%
*-commutative87.5%
Simplified87.5%
+-commutative87.5%
*-un-lft-identity87.5%
fma-def87.5%
associate-*l*87.5%
Applied egg-rr87.5%
fma-udef87.5%
*-lft-identity87.5%
unsub-neg87.5%
Simplified87.5%
if -5.00000000000023e-311 < b < 3.79999999999999994e-75Initial program 72.1%
Taylor expanded in b around -inf 72.1%
fma-def72.1%
Simplified72.1%
Taylor expanded in b around 0 67.2%
*-commutative67.2%
associate-*l*67.4%
Simplified67.4%
pow167.4%
fma-udef67.4%
+-commutative67.4%
associate-*r/67.4%
neg-mul-167.4%
add-sqr-sqrt67.4%
sqrt-unprod67.4%
sqr-neg67.4%
sqrt-unprod67.4%
add-sqr-sqrt67.4%
Applied egg-rr67.4%
if 3.79999999999999994e-75 < b Initial program 63.7%
Taylor expanded in b around inf 84.5%
*-commutative84.5%
fma-def84.5%
*-commutative84.5%
associate-/l*85.7%
Simplified85.7%
Taylor expanded in b around -inf 85.7%
fma-def63.7%
Simplified85.7%
Final simplification84.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.52e+148)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (- (/ c b) (/ b a)))
(if (<= b -5e-311)
(if (>= b 0.0)
(/ 1.0 (/ (fma b -2.0 (/ 2.0 (/ (/ b a) c))) (* 2.0 c)))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a)))
(if (<= b 3.35e-75)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (* a (* c -4.0)))))
(+ (/ c b) (/ b a)))
(if (>= b 0.0)
(/ (* 2.0 c) (fma b -2.0 (* 2.0 (/ a (/ b c)))))
(fma -1.0 (/ b a) (/ c b)))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -2.52e+148) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= -5e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 1.0 / (fma(b, -2.0, (2.0 / ((b / a) / c))) / (2.0 * c));
} else {
tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 3.35e-75) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - sqrt((a * (c * -4.0))));
} else {
tmp_4 = (c / b) + (b / a);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / fma(b, -2.0, (2.0 * (a / (b / c))));
} else {
tmp_1 = fma(-1.0, (b / a), (c / b));
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -2.52e+148) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= -5e-311) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(1.0 / Float64(fma(b, -2.0, Float64(2.0 / Float64(Float64(b / a) / c))) / Float64(2.0 * c))); 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 <= 3.35e-75) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(a * Float64(c * -4.0))))); else tmp_4 = Float64(Float64(c / b) + Float64(b / a)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / fma(b, -2.0, Float64(2.0 * Float64(a / Float64(b / c))))); else tmp_1 = fma(-1.0, Float64(b / a), Float64(c / b)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -2.52e+148], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -5e-311], If[GreaterEqual[b, 0.0], N[(1.0 / N[(N[(b * -2.0 + N[(2.0 / N[(N[(b / a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * c), $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, 3.35e-75], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] + N[(b / a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0 + N[(2.0 * N[(a / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.52 \cdot 10^{+148}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(b, -2, \frac{2}{\frac{\frac{b}{a}}{c}}\right)}{2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.35 \cdot 10^{-75}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{a \cdot \left(c \cdot -4\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} + \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(b, -2, 2 \cdot \frac{a}{\frac{b}{c}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\end{array}
\end{array}
if b < -2.51999999999999993e148Initial program 35.2%
Taylor expanded in b around inf 35.2%
*-commutative35.2%
Simplified35.2%
Taylor expanded in b around -inf 94.0%
+-commutative94.0%
mul-1-neg94.0%
unsub-neg94.0%
Simplified94.0%
if -2.51999999999999993e148 < b < -5.00000000000023e-311Initial program 95.2%
Taylor expanded in b around inf 95.2%
*-commutative95.2%
fma-def95.2%
*-commutative95.2%
associate-/l*95.2%
Simplified95.2%
clear-num95.2%
inv-pow95.2%
Applied egg-rr95.2%
clear-num95.2%
inv-pow95.2%
*-commutative95.2%
unpow-195.2%
associate-/l/95.2%
*-commutative95.2%
Applied egg-rr95.2%
unpow-195.2%
associate-*r/95.2%
metadata-eval95.2%
*-commutative95.2%
associate-/r*95.2%
*-commutative95.2%
Simplified95.2%
if -5.00000000000023e-311 < b < 3.3499999999999998e-75Initial program 72.1%
Taylor expanded in b around -inf 72.1%
fma-def72.1%
Simplified72.1%
Taylor expanded in b around 0 67.2%
*-commutative67.2%
associate-*l*67.4%
Simplified67.4%
pow167.4%
fma-udef67.4%
+-commutative67.4%
associate-*r/67.4%
neg-mul-167.4%
add-sqr-sqrt67.4%
sqrt-unprod67.4%
sqr-neg67.4%
sqrt-unprod67.4%
add-sqr-sqrt67.4%
Applied egg-rr67.4%
if 3.3499999999999998e-75 < b Initial program 63.7%
Taylor expanded in b around inf 84.5%
*-commutative84.5%
fma-def84.5%
*-commutative84.5%
associate-/l*85.7%
Simplified85.7%
Taylor expanded in b around -inf 85.7%
fma-def63.7%
Simplified85.7%
Final simplification87.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* 2.0 c) (* b -2.0))) (t_1 (sqrt (* a (* c -4.0)))))
(if (<= b -7.5e-70)
(if (>= b 0.0) t_0 (- (/ c b) (/ b a)))
(if (<= b -5e-311)
(if (>= b 0.0) t_0 (/ (- t_1 b) (* 2.0 a)))
(if (<= b 5.1e-76)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_1)) (+ (/ c b) (/ b a)))
(if (>= b 0.0)
(/ (* 2.0 c) (- (- (* -2.0 (* (/ c b) (- a))) b) b))
(fma -1.0 (/ b a) (/ c b))))))))
double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (b * -2.0);
double t_1 = sqrt((a * (c * -4.0)));
double tmp_1;
if (b <= -7.5e-70) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= -5e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = (t_1 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 5.1e-76) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - t_1);
} else {
tmp_4 = (c / b) + (b / a);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (((-2.0 * ((c / b) * -a)) - b) - b);
} else {
tmp_1 = fma(-1.0, (b / a), (c / b));
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(2.0 * c) / Float64(b * -2.0)) t_1 = sqrt(Float64(a * Float64(c * -4.0))) tmp_1 = 0.0 if (b <= -7.5e-70) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= -5e-311) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_0; else tmp_3 = Float64(Float64(t_1 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= 5.1e-76) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_1)); else tmp_4 = Float64(Float64(c / b) + Float64(b / a)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(Float64(-2.0 * Float64(Float64(c / b) * Float64(-a))) - b) - b)); else tmp_1 = fma(-1.0, Float64(b / a), Float64(c / b)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -7.5e-70], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -5e-311], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(t$95$1 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 5.1e-76], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] + N[(b / a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(N[(N[(-2.0 * N[(N[(c / b), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2 \cdot c}{b \cdot -2}\\
t_1 := \sqrt{a \cdot \left(c \cdot -4\right)}\\
\mathbf{if}\;b \leq -7.5 \cdot 10^{-70}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 5.1 \cdot 10^{-76}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} + \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-2 \cdot \left(\frac{c}{b} \cdot \left(-a\right)\right) - b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\end{array}
\end{array}
if b < -7.49999999999999973e-70Initial program 66.1%
Taylor expanded in b around inf 66.1%
*-commutative66.1%
Simplified66.1%
Taylor expanded in b around -inf 88.0%
+-commutative88.0%
mul-1-neg88.0%
unsub-neg88.0%
Simplified88.0%
if -7.49999999999999973e-70 < b < -5.00000000000023e-311Initial program 97.1%
Taylor expanded in b around inf 97.1%
*-commutative97.1%
Simplified97.1%
Taylor expanded in b around 0 87.5%
*-commutative87.5%
Simplified87.5%
+-commutative87.5%
*-un-lft-identity87.5%
fma-def87.5%
associate-*l*87.5%
Applied egg-rr87.5%
fma-udef87.5%
*-lft-identity87.5%
unsub-neg87.5%
Simplified87.5%
if -5.00000000000023e-311 < b < 5.09999999999999986e-76Initial program 72.1%
Taylor expanded in b around -inf 72.1%
fma-def72.1%
Simplified72.1%
Taylor expanded in b around 0 67.2%
*-commutative67.2%
associate-*l*67.4%
Simplified67.4%
pow167.4%
fma-udef67.4%
+-commutative67.4%
associate-*r/67.4%
neg-mul-167.4%
add-sqr-sqrt67.4%
sqrt-unprod67.4%
sqr-neg67.4%
sqrt-unprod67.4%
add-sqr-sqrt67.4%
Applied egg-rr67.4%
if 5.09999999999999986e-76 < b Initial program 63.7%
Taylor expanded in b around -inf 63.7%
fma-def63.7%
Simplified63.7%
Taylor expanded in b around inf 84.5%
associate-*r/85.7%
Simplified85.7%
Final simplification84.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma -1.0 (/ b a) (/ c b)))
(t_1 (/ (* 2.0 c) (* b -2.0)))
(t_2 (sqrt (* a (* c -4.0)))))
(if (<= b -4e-72)
(if (>= b 0.0) t_1 (- (/ c b) (/ b a)))
(if (<= b -5e-311)
(if (>= b 0.0) t_1 (/ (- t_2 b) (* 2.0 a)))
(if (<= b 6.8e-76)
(if (>= b 0.0) (/ (* c -2.0) (+ b t_2)) t_0)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- (* -2.0 (* (/ c b) (- a))) b) b))
t_0))))))
double code(double a, double b, double c) {
double t_0 = fma(-1.0, (b / a), (c / b));
double t_1 = (2.0 * c) / (b * -2.0);
double t_2 = sqrt((a * (c * -4.0)));
double tmp_1;
if (b <= -4e-72) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= -5e-311) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = (t_2 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 6.8e-76) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * -2.0) / (b + t_2);
} else {
tmp_4 = t_0;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (((-2.0 * ((c / b) * -a)) - b) - b);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
function code(a, b, c) t_0 = fma(-1.0, Float64(b / a), Float64(c / b)) t_1 = Float64(Float64(2.0 * c) / Float64(b * -2.0)) t_2 = sqrt(Float64(a * Float64(c * -4.0))) tmp_1 = 0.0 if (b <= -4e-72) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= -5e-311) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = Float64(Float64(t_2 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= 6.8e-76) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * -2.0) / Float64(b + t_2)); else tmp_4 = t_0; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(Float64(-2.0 * Float64(Float64(c / b) * Float64(-a))) - b) - b)); else tmp_1 = t_0; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -4e-72], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -5e-311], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(t$95$2 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 6.8e-76], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + t$95$2), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(N[(N[(-2.0 * N[(N[(c / b), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
t_1 := \frac{2 \cdot c}{b \cdot -2}\\
t_2 := \sqrt{a \cdot \left(c \cdot -4\right)}\\
\mathbf{if}\;b \leq -4 \cdot 10^{-72}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t_2 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 6.8 \cdot 10^{-76}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + t_2}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-2 \cdot \left(\frac{c}{b} \cdot \left(-a\right)\right) - b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < -3.9999999999999999e-72Initial program 66.1%
Taylor expanded in b around inf 66.1%
*-commutative66.1%
Simplified66.1%
Taylor expanded in b around -inf 88.0%
+-commutative88.0%
mul-1-neg88.0%
unsub-neg88.0%
Simplified88.0%
if -3.9999999999999999e-72 < b < -5.00000000000023e-311Initial program 97.1%
Taylor expanded in b around inf 97.1%
*-commutative97.1%
Simplified97.1%
Taylor expanded in b around 0 87.5%
*-commutative87.5%
Simplified87.5%
+-commutative87.5%
*-un-lft-identity87.5%
fma-def87.5%
associate-*l*87.5%
Applied egg-rr87.5%
fma-udef87.5%
*-lft-identity87.5%
unsub-neg87.5%
Simplified87.5%
if -5.00000000000023e-311 < b < 6.7999999999999998e-76Initial program 72.1%
Taylor expanded in b around -inf 72.1%
fma-def72.1%
Simplified72.1%
Taylor expanded in b around 0 67.2%
*-commutative67.2%
associate-*l*67.4%
Simplified67.4%
div-inv67.2%
associate-*l*67.2%
frac-2neg67.2%
metadata-eval67.2%
neg-sub067.2%
add-sqr-sqrt0.0%
sqrt-unprod65.6%
sqr-neg65.6%
sqrt-unprod65.4%
add-sqr-sqrt65.4%
associate-+l-65.4%
neg-sub065.4%
+-commutative65.4%
*-commutative65.4%
*-commutative65.4%
associate-*l*65.3%
add-sqr-sqrt0.0%
sqrt-unprod66.3%
sqr-neg66.3%
sqrt-unprod67.0%
add-sqr-sqrt67.0%
Applied egg-rr67.0%
associate-*r*67.0%
associate-*r/67.2%
*-commutative67.2%
associate-*l*67.2%
metadata-eval67.2%
+-commutative67.2%
*-commutative67.2%
*-commutative67.2%
associate-*r*67.4%
Simplified67.4%
if 6.7999999999999998e-76 < b Initial program 63.7%
Taylor expanded in b around -inf 63.7%
fma-def63.7%
Simplified63.7%
Taylor expanded in b around inf 84.5%
associate-*r/85.7%
Simplified85.7%
Final simplification84.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* 2.0 c) (* b -2.0))))
(if (<= b -2.5e-120)
(if (>= b 0.0) t_0 (- (/ c b) (/ b a)))
(if (>= b 0.0) t_0 (* (+ b (sqrt (* -4.0 (* c a)))) (/ 0.5 a))))))
double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (b * -2.0);
double tmp_1;
if (b <= -2.5e-120) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = (b + sqrt((-4.0 * (c * a)))) * (0.5 / 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) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
t_0 = (2.0d0 * c) / (b * (-2.0d0))
if (b <= (-2.5d-120)) then
if (b >= 0.0d0) then
tmp_2 = t_0
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = t_0
else
tmp_1 = (b + sqrt(((-4.0d0) * (c * a)))) * (0.5d0 / a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (b * -2.0);
double tmp_1;
if (b <= -2.5e-120) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = (b + Math.sqrt((-4.0 * (c * a)))) * (0.5 / a);
}
return tmp_1;
}
def code(a, b, c): t_0 = (2.0 * c) / (b * -2.0) tmp_1 = 0 if b <= -2.5e-120: tmp_2 = 0 if b >= 0.0: tmp_2 = t_0 else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = t_0 else: tmp_1 = (b + math.sqrt((-4.0 * (c * a)))) * (0.5 / a) return tmp_1
function code(a, b, c) t_0 = Float64(Float64(2.0 * c) / Float64(b * -2.0)) tmp_1 = 0.0 if (b <= -2.5e-120) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = t_0; else tmp_1 = Float64(Float64(b + sqrt(Float64(-4.0 * Float64(c * a)))) * Float64(0.5 / a)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = (2.0 * c) / (b * -2.0); tmp_2 = 0.0; if (b <= -2.5e-120) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_0; else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = t_0; else tmp_2 = (b + sqrt((-4.0 * (c * a)))) * (0.5 / a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.5e-120], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(b + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2 \cdot c}{b \cdot -2}\\
\mathbf{if}\;b \leq -2.5 \cdot 10^{-120}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(b + \sqrt{-4 \cdot \left(c \cdot a\right)}\right) \cdot \frac{0.5}{a}\\
\end{array}
\end{array}
if b < -2.50000000000000003e-120Initial program 68.8%
Taylor expanded in b around inf 68.8%
*-commutative68.8%
Simplified68.8%
Taylor expanded in b around -inf 85.3%
+-commutative85.3%
mul-1-neg85.3%
unsub-neg85.3%
Simplified85.3%
if -2.50000000000000003e-120 < b Initial program 71.0%
Taylor expanded in b around inf 70.6%
*-commutative70.6%
Simplified70.6%
Taylor expanded in b around 0 70.6%
*-commutative70.6%
Simplified70.6%
expm1-log1p-u64.3%
expm1-udef61.3%
neg-mul-161.3%
fma-def61.3%
associate-*l*61.3%
Applied egg-rr61.3%
expm1-def64.3%
expm1-log1p70.6%
*-rgt-identity70.6%
associate-*r/70.6%
associate-/r*70.6%
metadata-eval70.6%
Simplified70.6%
fma-udef70.6%
neg-mul-170.6%
+-commutative70.6%
*-commutative70.6%
*-commutative70.6%
associate-*l*70.6%
add-sqr-sqrt70.6%
sqrt-unprod70.6%
sqr-neg70.6%
sqrt-unprod54.5%
add-sqr-sqrt70.6%
Applied egg-rr70.6%
Final simplification76.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* 2.0 c) (* b -2.0))))
(if (<= b -1.65e-69)
(if (>= b 0.0) t_0 (- (/ c b) (/ b a)))
(if (>= b 0.0) t_0 (/ (- (sqrt (* a (* c -4.0))) b) (* 2.0 a))))))
double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (b * -2.0);
double tmp_1;
if (b <= -1.65e-69) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = (sqrt((a * (c * -4.0))) - 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) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
t_0 = (2.0d0 * c) / (b * (-2.0d0))
if (b <= (-1.65d-69)) then
if (b >= 0.0d0) then
tmp_2 = t_0
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = t_0
else
tmp_1 = (sqrt((a * (c * (-4.0d0)))) - b) / (2.0d0 * a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (b * -2.0);
double tmp_1;
if (b <= -1.65e-69) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = (Math.sqrt((a * (c * -4.0))) - b) / (2.0 * a);
}
return tmp_1;
}
def code(a, b, c): t_0 = (2.0 * c) / (b * -2.0) tmp_1 = 0 if b <= -1.65e-69: tmp_2 = 0 if b >= 0.0: tmp_2 = t_0 else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = t_0 else: tmp_1 = (math.sqrt((a * (c * -4.0))) - b) / (2.0 * a) return tmp_1
function code(a, b, c) t_0 = Float64(Float64(2.0 * c) / Float64(b * -2.0)) tmp_1 = 0.0 if (b <= -1.65e-69) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = t_0; else tmp_1 = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(2.0 * a)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = (2.0 * c) / (b * -2.0); tmp_2 = 0.0; if (b <= -1.65e-69) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_0; else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = t_0; else tmp_2 = (sqrt((a * (c * -4.0))) - b) / (2.0 * a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.65e-69], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2 \cdot c}{b \cdot -2}\\
\mathbf{if}\;b \leq -1.65 \cdot 10^{-69}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -1.65e-69Initial program 66.1%
Taylor expanded in b around inf 66.1%
*-commutative66.1%
Simplified66.1%
Taylor expanded in b around -inf 88.0%
+-commutative88.0%
mul-1-neg88.0%
unsub-neg88.0%
Simplified88.0%
if -1.65e-69 < b Initial program 72.4%
Taylor expanded in b around inf 72.1%
*-commutative72.1%
Simplified72.1%
Taylor expanded in b around 0 70.1%
*-commutative70.1%
Simplified70.1%
+-commutative70.1%
*-un-lft-identity70.1%
fma-def70.1%
associate-*l*70.1%
Applied egg-rr70.1%
fma-udef70.1%
*-lft-identity70.1%
unsub-neg70.1%
Simplified70.1%
Final simplification76.6%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (- (- (* -2.0 (* (/ c b) (- a))) b) b)) (fma -1.0 (/ b a) (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (((-2.0 * ((c / b) * -a)) - b) - b);
} else {
tmp = fma(-1.0, (b / a), (c / b));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(Float64(-2.0 * Float64(Float64(c / b) * Float64(-a))) - b) - b)); else tmp = fma(-1.0, Float64(b / a), Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(N[(N[(-2.0 * N[(N[(c / b), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-2 \cdot \left(\frac{c}{b} \cdot \left(-a\right)\right) - b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\end{array}
\end{array}
Initial program 70.2%
Taylor expanded in b around -inf 67.4%
fma-def67.4%
Simplified67.4%
Taylor expanded in b around inf 66.9%
associate-*r/67.3%
Simplified67.3%
Final simplification67.3%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = (c / b) - (b / 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 = (2.0d0 * c) / (b * (-2.0d0))
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (b * -2.0) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (b * -2.0); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
Initial program 70.2%
Taylor expanded in b around inf 69.9%
*-commutative69.9%
Simplified69.9%
Taylor expanded in b around -inf 67.1%
+-commutative67.1%
mul-1-neg67.1%
unsub-neg67.1%
Simplified67.1%
Final simplification67.1%
herbie shell --seed 2023333
(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))))