
(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 11 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 (* 4.0 a)))))
(t_1 (fma a (/ c b) (- b)))
(t_2 (/ (* 2.0 c) (- (- b) t_0)))
(t_3 (/ (- t_0 b) (* 2.0 a))))
(if (<= b -1e+133)
(if (>= b 0.0) t_2 (/ t_1 a))
(if (<= b 4e+105)
(if (>= b 0.0) t_2 t_3)
(if (>= b 0.0) (/ (* 2.0 c) (* 2.0 t_1)) t_3)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = fma(a, (c / b), -b);
double t_2 = (2.0 * c) / (-b - t_0);
double t_3 = (t_0 - b) / (2.0 * a);
double tmp_1;
if (b <= -1e+133) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_2;
} else {
tmp_2 = t_1 / a;
}
tmp_1 = tmp_2;
} else if (b <= 4e+105) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_2;
} else {
tmp_3 = t_3;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * t_1);
} else {
tmp_1 = t_3;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = fma(a, Float64(c / b), Float64(-b)) t_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)) t_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)) tmp_1 = 0.0 if (b <= -1e+133) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_2; else tmp_2 = Float64(t_1 / a); end tmp_1 = tmp_2; elseif (b <= 4e+105) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_2; else tmp_3 = t_3; end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * t_1)); else tmp_1 = t_3; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]}, Block[{t$95$2 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1e+133], If[GreaterEqual[b, 0.0], t$95$2, N[(t$95$1 / a), $MachinePrecision]], If[LessEqual[b, 4e+105], If[GreaterEqual[b, 0.0], t$95$2, t$95$3], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \mathsf{fma}\left(a, \frac{c}{b}, -b\right)\\
t_2 := \frac{2 \cdot c}{\left(-b\right) - t\_0}\\
t_3 := \frac{t\_0 - b}{2 \cdot a}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+133}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{+105}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if b < -1e133Initial program 45.3%
add-sqr-sqrt45.3%
pow245.3%
pow1/245.3%
sqrt-pow145.3%
fma-neg45.4%
*-commutative45.4%
distribute-rgt-neg-in45.4%
distribute-lft-neg-in45.4%
metadata-eval45.4%
*-commutative45.4%
metadata-eval45.4%
Applied egg-rr45.4%
Taylor expanded in b around -inf 91.1%
Taylor expanded in a around 0 81.5%
neg-mul-181.5%
+-commutative81.5%
associate-/l*91.4%
fma-undefine91.4%
Simplified91.4%
if -1e133 < b < 3.9999999999999998e105Initial program 91.8%
if 3.9999999999999998e105 < b Initial program 43.9%
Taylor expanded in a around 0 86.8%
distribute-lft-out--86.8%
associate-/l*91.7%
fma-neg91.7%
Simplified91.7%
Final simplification91.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (/ (* 2.0 c) (- (- b) t_0)))
(t_2 (/ (- t_0 b) (* 2.0 a))))
(if (<= b -8.5e+139)
(if (>= b 0.0) t_1 (* b (/ -1.0 a)))
(if (<= b -2e-310)
(if (>= b 0.0) (/ b a) t_2)
(if (<= b 1.55e+106)
(if (>= b 0.0) t_1 (* c (- (/ 1.0 b) (/ b (* c a)))))
(if (>= b 0.0) (/ (* 2.0 c) (* 2.0 (fma a (/ c b) (- b)))) t_2))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double t_2 = (t_0 - b) / (2.0 * a);
double tmp_1;
if (b <= -8.5e+139) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = b * (-1.0 / a);
}
tmp_1 = tmp_2;
} else if (b <= -2e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = b / a;
} else {
tmp_3 = t_2;
}
tmp_1 = tmp_3;
} else if (b <= 1.55e+106) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = t_1;
} else {
tmp_4 = c * ((1.0 / b) - (b / (c * a)));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_1 = t_2;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)) t_2 = Float64(Float64(t_0 - b) / Float64(2.0 * a)) tmp_1 = 0.0 if (b <= -8.5e+139) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(b * Float64(-1.0 / a)); end tmp_1 = tmp_2; elseif (b <= -2e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(b / a); else tmp_3 = t_2; end tmp_1 = tmp_3; elseif (b <= 1.55e+106) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = t_1; else tmp_4 = Float64(c * Float64(Float64(1.0 / b) - Float64(b / Float64(c * a)))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_1 = t_2; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -8.5e+139], If[GreaterEqual[b, 0.0], t$95$1, N[(b * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -2e-310], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], t$95$2], If[LessEqual[b, 1.55e+106], If[GreaterEqual[b, 0.0], t$95$1, N[(c * N[(N[(1.0 / b), $MachinePrecision] - N[(b / N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - t\_0}\\
t_2 := \frac{t\_0 - b}{2 \cdot a}\\
\mathbf{if}\;b \leq -8.5 \cdot 10^{+139}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{-1}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{+106}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;c \cdot \left(\frac{1}{b} - \frac{b}{c \cdot a}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if b < -8.5e139Initial program 45.3%
add-sqr-sqrt45.3%
pow245.3%
pow1/245.3%
sqrt-pow145.3%
fma-neg45.4%
*-commutative45.4%
distribute-rgt-neg-in45.4%
distribute-lft-neg-in45.4%
metadata-eval45.4%
*-commutative45.4%
metadata-eval45.4%
Applied egg-rr45.4%
Taylor expanded in b around -inf 91.1%
Taylor expanded in c around 0 91.1%
if -8.5e139 < b < -1.999999999999994e-310Initial program 93.7%
Taylor expanded in a around 0 93.7%
distribute-lft-out--93.7%
associate-/l*93.7%
fma-neg93.7%
Simplified93.7%
Taylor expanded in c around inf 93.7%
if -1.999999999999994e-310 < b < 1.55e106Initial program 89.7%
add-sqr-sqrt89.7%
pow289.7%
pow1/289.7%
sqrt-pow189.7%
fma-neg89.7%
*-commutative89.7%
distribute-rgt-neg-in89.7%
distribute-lft-neg-in89.7%
metadata-eval89.7%
*-commutative89.7%
metadata-eval89.7%
Applied egg-rr89.7%
Taylor expanded in b around -inf 89.7%
Taylor expanded in c around -inf 89.7%
associate-*r*89.7%
neg-mul-189.7%
*-commutative89.7%
Simplified89.7%
if 1.55e106 < b Initial program 43.9%
Taylor expanded in a around 0 86.8%
distribute-lft-out--86.8%
associate-/l*91.7%
fma-neg91.7%
Simplified91.7%
Final simplification91.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (/ (* 2.0 c) (- (- b) t_0)))
(t_2 (/ (- t_0 b) (* 2.0 a))))
(if (<= b -4.6e+136)
(if (>= b 0.0) t_1 (* b (/ -1.0 a)))
(if (<= b -2e-310)
(if (>= b 0.0) (/ b a) t_2)
(if (<= b 7.8e+105)
(if (>= b 0.0) t_1 (* b (+ (/ c (pow b 2.0)) (/ -1.0 a))))
(if (>= b 0.0) (/ (* 2.0 c) (* 2.0 (fma a (/ c b) (- b)))) t_2))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double t_2 = (t_0 - b) / (2.0 * a);
double tmp_1;
if (b <= -4.6e+136) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = b * (-1.0 / a);
}
tmp_1 = tmp_2;
} else if (b <= -2e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = b / a;
} else {
tmp_3 = t_2;
}
tmp_1 = tmp_3;
} else if (b <= 7.8e+105) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = t_1;
} else {
tmp_4 = b * ((c / pow(b, 2.0)) + (-1.0 / a));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_1 = t_2;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)) t_2 = Float64(Float64(t_0 - b) / Float64(2.0 * a)) tmp_1 = 0.0 if (b <= -4.6e+136) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(b * Float64(-1.0 / a)); end tmp_1 = tmp_2; elseif (b <= -2e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(b / a); else tmp_3 = t_2; end tmp_1 = tmp_3; elseif (b <= 7.8e+105) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = t_1; else tmp_4 = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_1 = t_2; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4.6e+136], If[GreaterEqual[b, 0.0], t$95$1, N[(b * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -2e-310], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], t$95$2], If[LessEqual[b, 7.8e+105], If[GreaterEqual[b, 0.0], t$95$1, N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - t\_0}\\
t_2 := \frac{t\_0 - b}{2 \cdot a}\\
\mathbf{if}\;b \leq -4.6 \cdot 10^{+136}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{-1}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}\\
\mathbf{elif}\;b \leq 7.8 \cdot 10^{+105}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if b < -4.6e136Initial program 45.3%
add-sqr-sqrt45.3%
pow245.3%
pow1/245.3%
sqrt-pow145.3%
fma-neg45.4%
*-commutative45.4%
distribute-rgt-neg-in45.4%
distribute-lft-neg-in45.4%
metadata-eval45.4%
*-commutative45.4%
metadata-eval45.4%
Applied egg-rr45.4%
Taylor expanded in b around -inf 91.1%
Taylor expanded in c around 0 91.1%
if -4.6e136 < b < -1.999999999999994e-310Initial program 93.7%
Taylor expanded in a around 0 93.7%
distribute-lft-out--93.7%
associate-/l*93.7%
fma-neg93.7%
Simplified93.7%
Taylor expanded in c around inf 93.7%
if -1.999999999999994e-310 < b < 7.79999999999999957e105Initial program 89.7%
add-sqr-sqrt89.7%
pow289.7%
pow1/289.7%
sqrt-pow189.7%
fma-neg89.7%
*-commutative89.7%
distribute-rgt-neg-in89.7%
distribute-lft-neg-in89.7%
metadata-eval89.7%
*-commutative89.7%
metadata-eval89.7%
Applied egg-rr89.7%
Taylor expanded in b around -inf 89.7%
if 7.79999999999999957e105 < b Initial program 43.9%
Taylor expanded in a around 0 86.8%
distribute-lft-out--86.8%
associate-/l*91.7%
fma-neg91.7%
Simplified91.7%
Final simplification91.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (* b (+ (/ c (pow b 2.0)) (/ -1.0 a))))
(t_2 (/ (- t_0 b) (* 2.0 a))))
(if (<= b -5.8e+128)
(if (>= b 0.0) (/ (* 2.0 c) (- (* 2.0 (/ (* c a) b)) (* b 2.0))) t_1)
(if (<= b -2e-310)
(if (>= b 0.0) (/ b a) t_2)
(if (<= b 1.8e+106)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) t_1)
(if (>= b 0.0) (/ (* 2.0 c) (* 2.0 (fma a (/ c b) (- b)))) t_2))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = b * ((c / pow(b, 2.0)) + (-1.0 / a));
double t_2 = (t_0 - b) / (2.0 * a);
double tmp_1;
if (b <= -5.8e+128) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / ((2.0 * ((c * a) / b)) - (b * 2.0));
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= -2e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = b / a;
} else {
tmp_3 = t_2;
}
tmp_1 = tmp_3;
} else if (b <= 1.8e+106) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - t_0);
} else {
tmp_4 = t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_1 = t_2;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))) t_2 = Float64(Float64(t_0 - b) / Float64(2.0 * a)) tmp_1 = 0.0 if (b <= -5.8e+128) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(2.0 * Float64(Float64(c * a) / b)) - Float64(b * 2.0))); else tmp_2 = t_1; end tmp_1 = tmp_2; elseif (b <= -2e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(b / a); else tmp_3 = t_2; end tmp_1 = tmp_3; elseif (b <= 1.8e+106) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_4 = t_1; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_1 = t_2; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -5.8e+128], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1], If[LessEqual[b, -2e-310], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], t$95$2], If[LessEqual[b, 1.8e+106], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
t_2 := \frac{t\_0 - b}{2 \cdot a}\\
\mathbf{if}\;b \leq -5.8 \cdot 10^{+128}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{c \cdot a}{b} - b \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{+106}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if b < -5.8000000000000001e128Initial program 45.3%
add-sqr-sqrt45.3%
pow245.3%
pow1/245.3%
sqrt-pow145.3%
fma-neg45.4%
*-commutative45.4%
distribute-rgt-neg-in45.4%
distribute-lft-neg-in45.4%
metadata-eval45.4%
*-commutative45.4%
metadata-eval45.4%
Applied egg-rr45.4%
Taylor expanded in b around -inf 91.1%
Taylor expanded in a around 0 91.1%
if -5.8000000000000001e128 < b < -1.999999999999994e-310Initial program 93.7%
Taylor expanded in a around 0 93.7%
distribute-lft-out--93.7%
associate-/l*93.7%
fma-neg93.7%
Simplified93.7%
Taylor expanded in c around inf 93.7%
if -1.999999999999994e-310 < b < 1.8e106Initial program 89.7%
add-sqr-sqrt89.7%
pow289.7%
pow1/289.7%
sqrt-pow189.7%
fma-neg89.7%
*-commutative89.7%
distribute-rgt-neg-in89.7%
distribute-lft-neg-in89.7%
metadata-eval89.7%
*-commutative89.7%
metadata-eval89.7%
Applied egg-rr89.7%
Taylor expanded in b around -inf 89.7%
if 1.8e106 < b Initial program 43.9%
Taylor expanded in a around 0 86.8%
distribute-lft-out--86.8%
associate-/l*91.7%
fma-neg91.7%
Simplified91.7%
Final simplification91.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (/ (* 2.0 c) (- (- b) t_0)))
(t_2 (/ (- t_0 b) (* 2.0 a))))
(if (<= b -1e+140)
(if (>= b 0.0) t_1 (/ (- (- b) b) (* 2.0 a)))
(if (<= b 4e+105)
(if (>= b 0.0) t_1 t_2)
(if (>= b 0.0) (/ (* 2.0 c) (* 2.0 (fma a (/ c b) (- b)))) t_2)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double t_2 = (t_0 - b) / (2.0 * a);
double tmp_1;
if (b <= -1e+140) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (-b - b) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 4e+105) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = t_2;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_1 = t_2;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)) t_2 = Float64(Float64(t_0 - b) / Float64(2.0 * a)) tmp_1 = 0.0 if (b <= -1e+140) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(Float64(-b) - b) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 4e+105) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = t_2; end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_1 = t_2; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1e+140], If[GreaterEqual[b, 0.0], t$95$1, N[(N[((-b) - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 4e+105], If[GreaterEqual[b, 0.0], t$95$1, t$95$2], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - t\_0}\\
t_2 := \frac{t\_0 - b}{2 \cdot a}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+140}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{+105}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if b < -1.00000000000000006e140Initial program 45.3%
add-sqr-sqrt45.3%
pow245.3%
pow1/245.3%
sqrt-pow145.3%
fma-neg45.4%
*-commutative45.4%
distribute-rgt-neg-in45.4%
distribute-lft-neg-in45.4%
metadata-eval45.4%
*-commutative45.4%
metadata-eval45.4%
Applied egg-rr45.4%
Taylor expanded in b around -inf 91.3%
if -1.00000000000000006e140 < b < 3.9999999999999998e105Initial program 91.8%
if 3.9999999999999998e105 < b Initial program 43.9%
Taylor expanded in a around 0 86.8%
distribute-lft-out--86.8%
associate-/l*91.7%
fma-neg91.7%
Simplified91.7%
Final simplification91.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (/ (* 2.0 c) (- (- b) t_0)))
(t_2 (/ (- t_0 b) (* 2.0 a))))
(if (<= b -3.4e+132)
(if (>= b 0.0) t_1 (* b (/ -1.0 a)))
(if (<= b 1e+106)
(if (>= b 0.0) t_1 t_2)
(if (>= b 0.0) (/ (* 2.0 c) (* 2.0 (fma a (/ c b) (- b)))) t_2)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double t_2 = (t_0 - b) / (2.0 * a);
double tmp_1;
if (b <= -3.4e+132) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = b * (-1.0 / a);
}
tmp_1 = tmp_2;
} else if (b <= 1e+106) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = t_2;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_1 = t_2;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)) t_2 = Float64(Float64(t_0 - b) / Float64(2.0 * a)) tmp_1 = 0.0 if (b <= -3.4e+132) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(b * Float64(-1.0 / a)); end tmp_1 = tmp_2; elseif (b <= 1e+106) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = t_2; end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_1 = t_2; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.4e+132], If[GreaterEqual[b, 0.0], t$95$1, N[(b * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1e+106], If[GreaterEqual[b, 0.0], t$95$1, t$95$2], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - t\_0}\\
t_2 := \frac{t\_0 - b}{2 \cdot a}\\
\mathbf{if}\;b \leq -3.4 \cdot 10^{+132}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{-1}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+106}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if b < -3.40000000000000025e132Initial program 45.3%
add-sqr-sqrt45.3%
pow245.3%
pow1/245.3%
sqrt-pow145.3%
fma-neg45.4%
*-commutative45.4%
distribute-rgt-neg-in45.4%
distribute-lft-neg-in45.4%
metadata-eval45.4%
*-commutative45.4%
metadata-eval45.4%
Applied egg-rr45.4%
Taylor expanded in b around -inf 91.1%
Taylor expanded in c around 0 91.1%
if -3.40000000000000025e132 < b < 1.00000000000000009e106Initial program 91.8%
if 1.00000000000000009e106 < b Initial program 43.9%
Taylor expanded in a around 0 86.8%
distribute-lft-out--86.8%
associate-/l*91.7%
fma-neg91.7%
Simplified91.7%
Final simplification91.6%
(FPCore (a b c)
:precision binary64
(if (<= b -2e+138)
(if (>= b 0.0)
(/ (* 2.0 c) (- (* 2.0 (/ (* c a) b)) (* b 2.0)))
(* b (+ (/ c (pow b 2.0)) (/ -1.0 a))))
(if (<= b 8.4e-210)
(if (>= b 0.0)
(/ b a)
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))
(if (>= b 0.0)
(* c (/ -2.0 (+ b (+ b (* -2.0 (* a (/ c b)))))))
(/ (- b b) (* a -2.0))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -2e+138) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / ((2.0 * ((c * a) / b)) - (b * 2.0));
} else {
tmp_2 = b * ((c / pow(b, 2.0)) + (-1.0 / a));
}
tmp_1 = tmp_2;
} else if (b <= 8.4e-210) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = b / a;
} else {
tmp_3 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c * (-2.0 / (b + (b + (-2.0 * (a * (c / b))))));
} else {
tmp_1 = (b - b) / (a * -2.0);
}
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
real(8) :: tmp_3
if (b <= (-2d+138)) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / ((2.0d0 * ((c * a) / b)) - (b * 2.0d0))
else
tmp_2 = b * ((c / (b ** 2.0d0)) + ((-1.0d0) / a))
end if
tmp_1 = tmp_2
else if (b <= 8.4d-210) then
if (b >= 0.0d0) then
tmp_3 = b / a
else
tmp_3 = (sqrt(((b * b) - (c * (4.0d0 * a)))) - b) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = c * ((-2.0d0) / (b + (b + ((-2.0d0) * (a * (c / b))))))
else
tmp_1 = (b - b) / (a * (-2.0d0))
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -2e+138) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / ((2.0 * ((c * a) / b)) - (b * 2.0));
} else {
tmp_2 = b * ((c / Math.pow(b, 2.0)) + (-1.0 / a));
}
tmp_1 = tmp_2;
} else if (b <= 8.4e-210) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = b / a;
} else {
tmp_3 = (Math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c * (-2.0 / (b + (b + (-2.0 * (a * (c / b))))));
} else {
tmp_1 = (b - b) / (a * -2.0);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -2e+138: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / ((2.0 * ((c * a) / b)) - (b * 2.0)) else: tmp_2 = b * ((c / math.pow(b, 2.0)) + (-1.0 / a)) tmp_1 = tmp_2 elif b <= 8.4e-210: tmp_3 = 0 if b >= 0.0: tmp_3 = b / a else: tmp_3 = (math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = c * (-2.0 / (b + (b + (-2.0 * (a * (c / b)))))) else: tmp_1 = (b - b) / (a * -2.0) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -2e+138) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(2.0 * Float64(Float64(c * a) / b)) - Float64(b * 2.0))); else tmp_2 = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); end tmp_1 = tmp_2; elseif (b <= 8.4e-210) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(b / a); else tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(c * Float64(-2.0 / Float64(b + Float64(b + Float64(-2.0 * Float64(a * Float64(c / b))))))); else tmp_1 = Float64(Float64(b - b) / Float64(a * -2.0)); end return tmp_1 end
function tmp_5 = code(a, b, c) tmp_2 = 0.0; if (b <= -2e+138) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / ((2.0 * ((c * a) / b)) - (b * 2.0)); else tmp_3 = b * ((c / (b ^ 2.0)) + (-1.0 / a)); end tmp_2 = tmp_3; elseif (b <= 8.4e-210) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = b / a; else tmp_4 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = c * (-2.0 / (b + (b + (-2.0 * (a * (c / b)))))); else tmp_2 = (b - b) / (a * -2.0); end tmp_5 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -2e+138], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 8.4e-210], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - b), $MachinePrecision] / N[(a * -2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+138}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{c \cdot a}{b} - b \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \leq 8.4 \cdot 10^{-210}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - b}{a \cdot -2}\\
\end{array}
\end{array}
if b < -2.0000000000000001e138Initial program 45.3%
add-sqr-sqrt45.3%
pow245.3%
pow1/245.3%
sqrt-pow145.3%
fma-neg45.4%
*-commutative45.4%
distribute-rgt-neg-in45.4%
distribute-lft-neg-in45.4%
metadata-eval45.4%
*-commutative45.4%
metadata-eval45.4%
Applied egg-rr45.4%
Taylor expanded in b around -inf 91.1%
Taylor expanded in a around 0 91.1%
if -2.0000000000000001e138 < b < 8.40000000000000064e-210Initial program 92.6%
Taylor expanded in a around 0 82.1%
distribute-lft-out--82.1%
associate-/l*82.1%
fma-neg82.1%
Simplified82.1%
Taylor expanded in c around inf 82.2%
if 8.40000000000000064e-210 < b Initial program 72.4%
Simplified72.2%
Taylor expanded in c around 0 72.2%
Taylor expanded in c around 0 72.8%
associate-/l*74.7%
Simplified74.7%
Final simplification80.3%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e+139)
(if (>= b 0.0)
(/ (* 2.0 c) (- (* 2.0 (/ (* c a) b)) (* b 2.0)))
(* b (+ (/ c (pow b 2.0)) (/ -1.0 a))))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (fma a (/ c b) (- b))))
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -4.8e+139) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / ((2.0 * ((c * a) / b)) - (b * 2.0));
} else {
tmp_2 = b * ((c / pow(b, 2.0)) + (-1.0 / a));
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_1 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -4.8e+139) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(2.0 * Float64(Float64(c * a) / b)) - Float64(b * 2.0))); else tmp_2 = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) - b) / Float64(2.0 * a)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -4.8e+139], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $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[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{+139}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{c \cdot a}{b} - b \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -4.80000000000000016e139Initial program 45.3%
add-sqr-sqrt45.3%
pow245.3%
pow1/245.3%
sqrt-pow145.3%
fma-neg45.4%
*-commutative45.4%
distribute-rgt-neg-in45.4%
distribute-lft-neg-in45.4%
metadata-eval45.4%
*-commutative45.4%
metadata-eval45.4%
Applied egg-rr45.4%
Taylor expanded in b around -inf 91.1%
Taylor expanded in a around 0 91.1%
if -4.80000000000000016e139 < b Initial program 81.9%
Taylor expanded in a around 0 77.4%
distribute-lft-out--77.4%
associate-/l*78.3%
fma-neg78.3%
Simplified78.3%
Final simplification80.4%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (- (* 2.0 (/ (* c a) b)) (* b 2.0))) (* b (+ (/ c (pow b 2.0)) (/ -1.0 a)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / ((2.0 * ((c * a) / b)) - (b * 2.0));
} else {
tmp = b * ((c / pow(b, 2.0)) + (-1.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 = (2.0d0 * c) / ((2.0d0 * ((c * a) / b)) - (b * 2.0d0))
else
tmp = b * ((c / (b ** 2.0d0)) + ((-1.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 = (2.0 * c) / ((2.0 * ((c * a) / b)) - (b * 2.0));
} else {
tmp = b * ((c / Math.pow(b, 2.0)) + (-1.0 / a));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / ((2.0 * ((c * a) / b)) - (b * 2.0)) else: tmp = b * ((c / math.pow(b, 2.0)) + (-1.0 / a)) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(2.0 * Float64(Float64(c * a) / b)) - Float64(b * 2.0))); else tmp = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / ((2.0 * ((c * a) / b)) - (b * 2.0)); else tmp = b * ((c / (b ^ 2.0)) + (-1.0 / a)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{c \cdot a}{b} - b \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\end{array}
\end{array}
Initial program 75.9%
add-sqr-sqrt75.8%
pow275.8%
pow1/275.8%
sqrt-pow175.8%
fma-neg75.8%
*-commutative75.8%
distribute-rgt-neg-in75.8%
distribute-lft-neg-in75.8%
metadata-eval75.8%
*-commutative75.8%
metadata-eval75.8%
Applied egg-rr75.8%
Taylor expanded in b around -inf 68.6%
Taylor expanded in a around 0 64.8%
Final simplification64.8%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* c (/ -2.0 (+ b (+ b (* -2.0 (* a (/ c b))))))) (/ (- b b) (* a -2.0))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c * (-2.0 / (b + (b + (-2.0 * (a * (c / b))))));
} else {
tmp = (b - b) / (a * -2.0);
}
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 * ((-2.0d0) / (b + (b + ((-2.0d0) * (a * (c / b))))))
else
tmp = (b - b) / (a * (-2.0d0))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c * (-2.0 / (b + (b + (-2.0 * (a * (c / b))))));
} else {
tmp = (b - b) / (a * -2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c * (-2.0 / (b + (b + (-2.0 * (a * (c / b)))))) else: tmp = (b - b) / (a * -2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c * Float64(-2.0 / Float64(b + Float64(b + Float64(-2.0 * Float64(a * Float64(c / b))))))); else tmp = Float64(Float64(b - b) / Float64(a * -2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c * (-2.0 / (b + (b + (-2.0 * (a * (c / b)))))); else tmp = (b - b) / (a * -2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - b), $MachinePrecision] / N[(a * -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - b}{a \cdot -2}\\
\end{array}
\end{array}
Initial program 75.9%
Simplified75.8%
Taylor expanded in c around 0 37.6%
Taylor expanded in c around 0 33.8%
associate-/l*34.6%
Simplified34.6%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ c (- b)) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / -b;
} else {
tmp = 0.0;
}
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 = 0.0d0
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 = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c / -b else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c / Float64(-b)); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c / -b; else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
Initial program 75.9%
Simplified75.8%
Taylor expanded in c around 0 37.6%
Taylor expanded in b around inf 34.4%
Taylor expanded in b around 0 34.5%
associate-*r/34.5%
neg-mul-134.5%
Simplified34.5%
Final simplification34.5%
herbie shell --seed 2024139
(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))))