
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) 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(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); 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 = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); 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[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $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{\left(-b\right) - t_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t_0}\\
\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) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) 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(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); 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 = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); 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[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $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{\left(-b\right) - t_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t_0}\\
\end{array}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (- b) b)) (t_1 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -5e+107)
(if (>= b 0.0)
(/ t_0 (* a 2.0))
(/ (* 2.0 c) (fma b -2.0 (* c (* a (/ 2.0 b))))))
(if (<= b 4.4e+38)
(if (>= b 0.0) (/ (- (- b) t_1) (* a 2.0)) (/ (* 2.0 c) (- t_1 b)))
(if (>= b 0.0) (- (/ c b) (/ b a)) (/ 2.0 (/ t_0 c)))))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double t_1 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -5e+107) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0 / (a * 2.0);
} else {
tmp_2 = (2.0 * c) / fma(b, -2.0, (c * (a * (2.0 / b))));
}
tmp_1 = tmp_2;
} else if (b <= 4.4e+38) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_1) / (a * 2.0);
} else {
tmp_3 = (2.0 * c) / (t_1 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = 2.0 / (t_0 / c);
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(-b) - b) t_1 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp_1 = 0.0 if (b <= -5e+107) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(t_0 / Float64(a * 2.0)); else tmp_2 = Float64(Float64(2.0 * c) / fma(b, -2.0, Float64(c * Float64(a * Float64(2.0 / b))))); end tmp_1 = tmp_2; elseif (b <= 4.4e+38) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(-b) - t_1) / Float64(a * 2.0)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(t_1 - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = Float64(2.0 / Float64(t_0 / c)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -5e+107], If[GreaterEqual[b, 0.0], N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0 + N[(c * N[(a * N[(2.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 4.4e+38], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$1), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$1 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
t_1 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -5 \cdot 10^{+107}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(b, -2, c \cdot \left(a \cdot \frac{2}{b}\right)\right)}\\
\end{array}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{+38}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t_1 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_0}{c}}\\
\end{array}
\end{array}
if b < -5.0000000000000002e107Initial program 52.8%
sqr-neg52.8%
sqr-neg52.8%
associate-*l*52.8%
*-commutative52.8%
associate-/l*52.8%
Simplified52.8%
Taylor expanded in b around inf 52.8%
Taylor expanded in b around -inf 87.6%
expm1-log1p-u78.3%
expm1-udef42.2%
Applied egg-rr43.8%
Simplified94.9%
if -5.0000000000000002e107 < b < 4.40000000000000013e38Initial program 87.4%
if 4.40000000000000013e38 < b Initial program 61.2%
sqr-neg61.2%
sqr-neg61.2%
associate-*l*61.2%
*-commutative61.2%
associate-/l*61.2%
Simplified61.2%
Taylor expanded in b around -inf 61.2%
Taylor expanded in b around inf 91.6%
+-commutative91.6%
mul-1-neg91.6%
unsub-neg91.6%
Simplified91.6%
Final simplification90.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (- b) b))
(t_1 (/ 2.0 (/ t_0 c)))
(t_2 (sqrt (* a (* c -4.0)))))
(if (<= b -4e-89)
(if (>= b 0.0) (/ t_0 (* a 2.0)) (/ (- c) b))
(if (<= b -1e-310)
(if (>= b 0.0) (fma -1.0 (/ b a) (/ c b)) (/ 2.0 (/ (- t_2 b) c)))
(if (<= b 2.65e-42)
(if (>= b 0.0) (/ (- (- b) t_2) (* a 2.0)) t_1)
(if (>= b 0.0) (- (/ c b) (/ b a)) t_1))))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double t_1 = 2.0 / (t_0 / c);
double t_2 = sqrt((a * (c * -4.0)));
double tmp_1;
if (b <= -4e-89) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0 / (a * 2.0);
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = fma(-1.0, (b / a), (c / b));
} else {
tmp_3 = 2.0 / ((t_2 - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 2.65e-42) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - t_2) / (a * 2.0);
} else {
tmp_4 = t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(-b) - b) t_1 = Float64(2.0 / Float64(t_0 / c)) t_2 = sqrt(Float64(a * Float64(c * -4.0))) tmp_1 = 0.0 if (b <= -4e-89) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(t_0 / Float64(a * 2.0)); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= -1e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = fma(-1.0, Float64(b / a), Float64(c / b)); else tmp_3 = Float64(2.0 / Float64(Float64(t_2 - b) / c)); end tmp_1 = tmp_3; elseif (b <= 2.65e-42) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - t_2) / Float64(a * 2.0)); else tmp_4 = t_1; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = t_1; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -4e-89], If[GreaterEqual[b, 0.0], N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]], If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(t$95$2 - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.65e-42], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$2), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$1], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
t_1 := \frac{2}{\frac{t_0}{c}}\\
t_2 := \sqrt{a \cdot \left(c \cdot -4\right)}\\
\mathbf{if}\;b \leq -4 \cdot 10^{-89}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_2 - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.65 \cdot 10^{-42}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_2}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if b < -4.00000000000000015e-89Initial program 69.1%
sqr-neg69.1%
sqr-neg69.1%
associate-*l*69.1%
*-commutative69.1%
associate-/l*68.9%
Simplified68.9%
Taylor expanded in b around inf 68.9%
Taylor expanded in b around -inf 84.1%
*-commutative84.1%
Simplified84.1%
Taylor expanded in b around 0 85.2%
associate-*r/85.2%
neg-mul-185.2%
Simplified85.2%
if -4.00000000000000015e-89 < b < -9.999999999999969e-311Initial program 88.5%
sqr-neg88.5%
sqr-neg88.5%
associate-*l*88.5%
*-commutative88.5%
associate-/l*88.4%
Simplified88.4%
Taylor expanded in b around inf 88.4%
fma-def88.4%
Simplified88.4%
Taylor expanded in b around 0 76.9%
*-commutative19.6%
associate-*l*19.6%
Simplified76.9%
if -9.999999999999969e-311 < b < 2.65e-42Initial program 84.0%
sqr-neg84.0%
sqr-neg84.0%
associate-*l*84.0%
*-commutative84.0%
associate-/l*84.0%
Simplified84.0%
Taylor expanded in b around -inf 84.0%
Taylor expanded in b around 0 73.6%
*-commutative73.6%
associate-*l*73.6%
Simplified73.6%
if 2.65e-42 < b Initial program 65.2%
sqr-neg65.2%
sqr-neg65.2%
associate-*l*65.2%
*-commutative65.2%
associate-/l*65.2%
Simplified65.2%
Taylor expanded in b around -inf 65.2%
Taylor expanded in b around inf 86.4%
+-commutative86.4%
mul-1-neg86.4%
unsub-neg86.4%
Simplified86.4%
Final simplification82.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* a (* c -4.0))))
(t_1 (- (- b) b))
(t_2 (/ 2.0 (/ t_1 c))))
(if (<= b -2.8e-81)
(if (>= b 0.0)
(/ t_1 (* a 2.0))
(/ (* 2.0 c) (fma b -2.0 (* c (* a (/ 2.0 b))))))
(if (<= b -1e-310)
(if (>= b 0.0) (fma -1.0 (/ b a) (/ c b)) (/ 2.0 (/ (- t_0 b) c)))
(if (<= b 1.5e-42)
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) t_2)
(if (>= b 0.0) (- (/ c b) (/ b a)) t_2))))))
double code(double a, double b, double c) {
double t_0 = sqrt((a * (c * -4.0)));
double t_1 = -b - b;
double t_2 = 2.0 / (t_1 / c);
double tmp_1;
if (b <= -2.8e-81) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1 / (a * 2.0);
} else {
tmp_2 = (2.0 * c) / fma(b, -2.0, (c * (a * (2.0 / b))));
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = fma(-1.0, (b / a), (c / b));
} else {
tmp_3 = 2.0 / ((t_0 - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 1.5e-42) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - t_0) / (a * 2.0);
} else {
tmp_4 = t_2;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_2;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(a * Float64(c * -4.0))) t_1 = Float64(Float64(-b) - b) t_2 = Float64(2.0 / Float64(t_1 / c)) tmp_1 = 0.0 if (b <= -2.8e-81) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(t_1 / Float64(a * 2.0)); else tmp_2 = Float64(Float64(2.0 * c) / fma(b, -2.0, Float64(c * Float64(a * Float64(2.0 / b))))); end tmp_1 = tmp_2; elseif (b <= -1e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = fma(-1.0, Float64(b / a), Float64(c / b)); else tmp_3 = Float64(2.0 / Float64(Float64(t_0 - b) / c)); end tmp_1 = tmp_3; elseif (b <= 1.5e-42) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)); else tmp_4 = t_2; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = t_2; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 / N[(t$95$1 / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.8e-81], If[GreaterEqual[b, 0.0], N[(t$95$1 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0 + N[(c * N[(a * N[(2.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(t$95$0 - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.5e-42], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$2], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{a \cdot \left(c \cdot -4\right)}\\
t_1 := \left(-b\right) - b\\
t_2 := \frac{2}{\frac{t_1}{c}}\\
\mathbf{if}\;b \leq -2.8 \cdot 10^{-81}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(b, -2, c \cdot \left(a \cdot \frac{2}{b}\right)\right)}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_0 - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{-42}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if b < -2.7999999999999999e-81Initial program 69.8%
sqr-neg69.8%
sqr-neg69.8%
associate-*l*69.8%
*-commutative69.8%
associate-/l*69.7%
Simplified69.7%
Taylor expanded in b around inf 69.7%
Taylor expanded in b around -inf 82.3%
expm1-log1p-u72.1%
expm1-udef33.9%
Applied egg-rr34.8%
Simplified86.7%
if -2.7999999999999999e-81 < b < -9.999999999999969e-311Initial program 86.4%
sqr-neg86.4%
sqr-neg86.4%
associate-*l*86.4%
*-commutative86.4%
associate-/l*86.3%
Simplified86.3%
Taylor expanded in b around inf 86.3%
fma-def86.3%
Simplified86.3%
Taylor expanded in b around 0 75.1%
*-commutative19.2%
associate-*l*19.2%
Simplified75.1%
if -9.999999999999969e-311 < b < 1.50000000000000014e-42Initial program 84.0%
sqr-neg84.0%
sqr-neg84.0%
associate-*l*84.0%
*-commutative84.0%
associate-/l*84.0%
Simplified84.0%
Taylor expanded in b around -inf 84.0%
Taylor expanded in b around 0 73.6%
*-commutative73.6%
associate-*l*73.6%
Simplified73.6%
if 1.50000000000000014e-42 < b Initial program 65.2%
sqr-neg65.2%
sqr-neg65.2%
associate-*l*65.2%
*-commutative65.2%
associate-/l*65.2%
Simplified65.2%
Taylor expanded in b around -inf 65.2%
Taylor expanded in b around inf 86.4%
+-commutative86.4%
mul-1-neg86.4%
unsub-neg86.4%
Simplified86.4%
Final simplification82.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (- b) b)) (t_1 (/ 2.0 (/ t_0 c))))
(if (<= b -1.15e+107)
(if (>= b 0.0)
(/ t_0 (* a 2.0))
(/ (* 2.0 c) (fma b -2.0 (* c (* a (/ 2.0 b))))))
(if (<= b -1e-310)
(if (>= b 0.0)
(/ c b)
(/ 2.0 (/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) c)))
(if (<= b 2.7e-42)
(if (>= b 0.0) (/ (- (- b) (sqrt (* a (* c -4.0)))) (* a 2.0)) t_1)
(if (>= b 0.0) (- (/ c b) (/ b a)) t_1))))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double t_1 = 2.0 / (t_0 / c);
double tmp_1;
if (b <= -1.15e+107) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0 / (a * 2.0);
} else {
tmp_2 = (2.0 * c) / fma(b, -2.0, (c * (a * (2.0 / b))));
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c / b;
} else {
tmp_3 = 2.0 / ((sqrt(((b * b) - (4.0 * (a * c)))) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 2.7e-42) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - sqrt((a * (c * -4.0)))) / (a * 2.0);
} else {
tmp_4 = t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(-b) - b) t_1 = Float64(2.0 / Float64(t_0 / c)) tmp_1 = 0.0 if (b <= -1.15e+107) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(t_0 / Float64(a * 2.0)); else tmp_2 = Float64(Float64(2.0 * c) / fma(b, -2.0, Float64(c * Float64(a * Float64(2.0 / b))))); end tmp_1 = tmp_2; elseif (b <= -1e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c / b); else tmp_3 = Float64(2.0 / Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) - b) / c)); end tmp_1 = tmp_3; elseif (b <= 2.7e-42) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - sqrt(Float64(a * Float64(c * -4.0)))) / Float64(a * 2.0)); else tmp_4 = t_1; end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = t_1; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.15e+107], If[GreaterEqual[b, 0.0], N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0 + N[(c * N[(a * N[(2.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], N[(2.0 / N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.7e-42], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$1], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
t_1 := \frac{2}{\frac{t_0}{c}}\\
\mathbf{if}\;b \leq -1.15 \cdot 10^{+107}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(b, -2, c \cdot \left(a \cdot \frac{2}{b}\right)\right)}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.7 \cdot 10^{-42}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if b < -1.15e107Initial program 52.8%
sqr-neg52.8%
sqr-neg52.8%
associate-*l*52.8%
*-commutative52.8%
associate-/l*52.8%
Simplified52.8%
Taylor expanded in b around inf 52.8%
Taylor expanded in b around -inf 87.6%
expm1-log1p-u78.3%
expm1-udef42.2%
Applied egg-rr43.8%
Simplified94.9%
if -1.15e107 < b < -9.999999999999969e-311Initial program 90.3%
sqr-neg90.3%
sqr-neg90.3%
associate-*l*90.3%
*-commutative90.3%
associate-/l*90.1%
Simplified90.1%
Taylor expanded in b around inf 90.1%
*-commutative90.1%
fma-def90.1%
associate-/l*90.1%
associate-*r/90.1%
*-commutative90.1%
Simplified90.1%
Taylor expanded in b around 0 90.1%
if -9.999999999999969e-311 < b < 2.69999999999999999e-42Initial program 84.0%
sqr-neg84.0%
sqr-neg84.0%
associate-*l*84.0%
*-commutative84.0%
associate-/l*84.0%
Simplified84.0%
Taylor expanded in b around -inf 84.0%
Taylor expanded in b around 0 73.6%
*-commutative73.6%
associate-*l*73.6%
Simplified73.6%
if 2.69999999999999999e-42 < b Initial program 65.2%
sqr-neg65.2%
sqr-neg65.2%
associate-*l*65.2%
*-commutative65.2%
associate-/l*65.2%
Simplified65.2%
Taylor expanded in b around -inf 65.2%
Taylor expanded in b around inf 86.4%
+-commutative86.4%
mul-1-neg86.4%
unsub-neg86.4%
Simplified86.4%
Final simplification87.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (- b) b)) (t_1 (sqrt (- (* b b) (* 4.0 (* a c))))))
(if (<= b -2.15e+105)
(if (>= b 0.0)
(/ t_0 (* a 2.0))
(/ (* 2.0 c) (fma b -2.0 (* c (* a (/ 2.0 b))))))
(if (<= b 4.4e+38)
(if (>= b 0.0) (- (/ (+ b t_1) (* a 2.0))) (/ 2.0 (/ (- t_1 b) c)))
(if (>= b 0.0) (- (/ c b) (/ b a)) (/ 2.0 (/ t_0 c)))))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double t_1 = sqrt(((b * b) - (4.0 * (a * c))));
double tmp_1;
if (b <= -2.15e+105) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0 / (a * 2.0);
} else {
tmp_2 = (2.0 * c) / fma(b, -2.0, (c * (a * (2.0 / b))));
}
tmp_1 = tmp_2;
} else if (b <= 4.4e+38) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -((b + t_1) / (a * 2.0));
} else {
tmp_3 = 2.0 / ((t_1 - b) / c);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = 2.0 / (t_0 / c);
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(-b) - b) t_1 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) tmp_1 = 0.0 if (b <= -2.15e+105) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(t_0 / Float64(a * 2.0)); else tmp_2 = Float64(Float64(2.0 * c) / fma(b, -2.0, Float64(c * Float64(a * Float64(2.0 / b))))); end tmp_1 = tmp_2; elseif (b <= 4.4e+38) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-Float64(Float64(b + t_1) / Float64(a * 2.0))); else tmp_3 = Float64(2.0 / Float64(Float64(t_1 - b) / c)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = Float64(2.0 / Float64(t_0 / c)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2.15e+105], If[GreaterEqual[b, 0.0], N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0 + N[(c * N[(a * N[(2.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 4.4e+38], If[GreaterEqual[b, 0.0], (-N[(N[(b + t$95$1), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), N[(2.0 / N[(N[(t$95$1 - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
t_1 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
\mathbf{if}\;b \leq -2.15 \cdot 10^{+105}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(b, -2, c \cdot \left(a \cdot \frac{2}{b}\right)\right)}\\
\end{array}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{+38}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\frac{b + t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_1 - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_0}{c}}\\
\end{array}
\end{array}
if b < -2.1500000000000001e105Initial program 52.8%
sqr-neg52.8%
sqr-neg52.8%
associate-*l*52.8%
*-commutative52.8%
associate-/l*52.8%
Simplified52.8%
Taylor expanded in b around inf 52.8%
Taylor expanded in b around -inf 87.6%
expm1-log1p-u78.3%
expm1-udef42.2%
Applied egg-rr43.8%
Simplified94.9%
if -2.1500000000000001e105 < b < 4.40000000000000013e38Initial program 87.4%
sqr-neg87.4%
sqr-neg87.4%
associate-*l*87.4%
*-commutative87.4%
associate-/l*87.3%
Simplified87.3%
if 4.40000000000000013e38 < b Initial program 61.2%
sqr-neg61.2%
sqr-neg61.2%
associate-*l*61.2%
*-commutative61.2%
associate-/l*61.2%
Simplified61.2%
Taylor expanded in b around -inf 61.2%
Taylor expanded in b around inf 91.6%
+-commutative91.6%
mul-1-neg91.6%
unsub-neg91.6%
Simplified91.6%
Final simplification90.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ 2.0 (/ (- (- b) b) c))))
(if (<= b 8.8e-42)
(if (>= b 0.0) (/ (- (- b) (sqrt (* a (* c -4.0)))) (* a 2.0)) t_0)
(if (>= b 0.0) (- (/ c b) (/ b a)) t_0))))
double code(double a, double b, double c) {
double t_0 = 2.0 / ((-b - b) / c);
double tmp_1;
if (b <= 8.8e-42) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - sqrt((a * (c * -4.0)))) / (a * 2.0);
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_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) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
t_0 = 2.0d0 / ((-b - b) / c)
if (b <= 8.8d-42) then
if (b >= 0.0d0) then
tmp_2 = (-b - sqrt((a * (c * (-4.0d0))))) / (a * 2.0d0)
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (c / b) - (b / a)
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = 2.0 / ((-b - b) / c);
double tmp_1;
if (b <= 8.8e-42) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - Math.sqrt((a * (c * -4.0)))) / (a * 2.0);
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = 2.0 / ((-b - b) / c) tmp_1 = 0 if b <= 8.8e-42: tmp_2 = 0 if b >= 0.0: tmp_2 = (-b - math.sqrt((a * (c * -4.0)))) / (a * 2.0) else: tmp_2 = t_0 tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (c / b) - (b / a) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(2.0 / Float64(Float64(Float64(-b) - b) / c)) tmp_1 = 0.0 if (b <= 8.8e-42) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(Float64(-b) - sqrt(Float64(a * Float64(c * -4.0)))) / Float64(a * 2.0)); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = 2.0 / ((-b - b) / c); tmp_2 = 0.0; if (b <= 8.8e-42) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (-b - sqrt((a * (c * -4.0)))) / (a * 2.0); else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (c / b) - (b / a); else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(2.0 / N[(N[((-b) - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 8.8e-42], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{\frac{\left(-b\right) - b}{c}}\\
\mathbf{if}\;b \leq 8.8 \cdot 10^{-42}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < 8.8000000000000002e-42Initial program 77.1%
sqr-neg77.1%
sqr-neg77.1%
associate-*l*77.1%
*-commutative77.1%
associate-/l*77.0%
Simplified77.0%
Taylor expanded in b around -inf 69.2%
Taylor expanded in b around 0 66.7%
*-commutative66.7%
associate-*l*66.7%
Simplified66.7%
if 8.8000000000000002e-42 < b Initial program 65.2%
sqr-neg65.2%
sqr-neg65.2%
associate-*l*65.2%
*-commutative65.2%
associate-/l*65.2%
Simplified65.2%
Taylor expanded in b around -inf 65.2%
Taylor expanded in b around inf 86.4%
+-commutative86.4%
mul-1-neg86.4%
unsub-neg86.4%
Simplified86.4%
Final simplification73.1%
(FPCore (a b c) :precision binary64 (if (<= b -1.5e-238) (if (>= b 0.0) (/ c b) (/ 2.0 (* -2.0 (/ b c)))) (if (>= b 0.0) (/ (- (- b) b) (* a 2.0)) (/ 2.0 (* 2.0 (/ a b))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1.5e-238) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = 2.0 / (-2.0 * (b / c));
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-b - b) / (a * 2.0);
} else {
tmp_1 = 2.0 / (2.0 * (a / b));
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b <= (-1.5d-238)) then
if (b >= 0.0d0) then
tmp_2 = c / b
else
tmp_2 = 2.0d0 / ((-2.0d0) * (b / c))
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (-b - b) / (a * 2.0d0)
else
tmp_1 = 2.0d0 / (2.0d0 * (a / b))
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -1.5e-238) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = 2.0 / (-2.0 * (b / c));
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-b - b) / (a * 2.0);
} else {
tmp_1 = 2.0 / (2.0 * (a / b));
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -1.5e-238: tmp_2 = 0 if b >= 0.0: tmp_2 = c / b else: tmp_2 = 2.0 / (-2.0 * (b / c)) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (-b - b) / (a * 2.0) else: tmp_1 = 2.0 / (2.0 * (a / b)) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -1.5e-238) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / b); else tmp_2 = Float64(2.0 / Float64(-2.0 * Float64(b / c))); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - b) / Float64(a * 2.0)); else tmp_1 = Float64(2.0 / Float64(2.0 * Float64(a / b))); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= -1.5e-238) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / b; else tmp_3 = 2.0 / (-2.0 * (b / c)); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (-b - b) / (a * 2.0); else tmp_2 = 2.0 / (2.0 * (a / b)); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -1.5e-238], If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], N[(2.0 / N[(-2.0 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[((-b) - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(2.0 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{-238}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{-2 \cdot \frac{b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{2 \cdot \frac{a}{b}}\\
\end{array}
\end{array}
if b < -1.5e-238Initial program 73.5%
sqr-neg73.5%
sqr-neg73.5%
associate-*l*73.5%
*-commutative73.5%
associate-/l*73.4%
Simplified73.4%
Taylor expanded in b around inf 73.4%
*-commutative73.4%
fma-def73.4%
associate-/l*73.4%
associate-*r/73.4%
*-commutative73.4%
Simplified73.4%
Taylor expanded in b around 0 73.4%
Taylor expanded in b around -inf 67.9%
*-commutative67.9%
Simplified67.9%
if -1.5e-238 < b Initial program 72.9%
sqr-neg72.9%
sqr-neg72.9%
associate-*l*72.9%
*-commutative72.9%
associate-/l*72.9%
Simplified72.9%
Taylor expanded in b around inf 66.1%
Taylor expanded in b around -inf 61.0%
Taylor expanded in b around 0 61.0%
Final simplification64.4%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (- (- b) b) (* a 2.0)) (/ 2.0 (* -2.0 (/ b c)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - b) / (a * 2.0);
} else {
tmp = 2.0 / (-2.0 * (b / c));
}
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 - b) / (a * 2.0d0)
else
tmp = 2.0d0 / ((-2.0d0) * (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - b) / (a * 2.0);
} else {
tmp = 2.0 / (-2.0 * (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (-b - b) / (a * 2.0) else: tmp = 2.0 / (-2.0 * (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - b) / Float64(a * 2.0)); else tmp = Float64(2.0 / Float64(-2.0 * Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (-b - b) / (a * 2.0); else tmp = 2.0 / (-2.0 * (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[((-b) - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(-2.0 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{-2 \cdot \frac{b}{c}}\\
\end{array}
\end{array}
Initial program 73.2%
sqr-neg73.2%
sqr-neg73.2%
associate-*l*73.2%
*-commutative73.2%
associate-/l*73.2%
Simplified73.2%
Taylor expanded in b around inf 69.7%
Taylor expanded in b around -inf 64.4%
*-commutative35.1%
Simplified64.4%
Final simplification64.4%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (- (- b) b) (* a 2.0)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (-b - b) / (a * 2.0);
} 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 - b) / (a * 2.0d0)
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 - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (-b - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (-b - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[((-b) - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
Initial program 73.2%
sqr-neg73.2%
sqr-neg73.2%
associate-*l*73.2%
*-commutative73.2%
associate-/l*73.2%
Simplified73.2%
Taylor expanded in b around inf 69.7%
Taylor expanded in b around -inf 64.4%
*-commutative35.1%
Simplified64.4%
Taylor expanded in b around 0 64.8%
associate-*r/64.8%
neg-mul-164.8%
Simplified64.8%
Final simplification64.8%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ c b) (/ 2.0 (* -2.0 (/ b c)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / b;
} else {
tmp = 2.0 / (-2.0 * (b / c));
}
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 = 2.0d0 / ((-2.0d0) * (b / c))
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 = 2.0 / (-2.0 * (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c / b else: tmp = 2.0 / (-2.0 * (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c / b); else tmp = Float64(2.0 / Float64(-2.0 * Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c / b; else tmp = 2.0 / (-2.0 * (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], N[(2.0 / N[(-2.0 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{-2 \cdot \frac{b}{c}}\\
\end{array}
\end{array}
Initial program 73.2%
sqr-neg73.2%
sqr-neg73.2%
associate-*l*73.2%
*-commutative73.2%
associate-/l*73.2%
Simplified73.2%
Taylor expanded in b around inf 69.2%
*-commutative69.2%
fma-def69.2%
associate-/l*69.6%
associate-*r/69.6%
*-commutative69.6%
Simplified69.6%
Taylor expanded in b around 0 40.4%
Taylor expanded in b around -inf 35.1%
*-commutative35.1%
Simplified35.1%
Final simplification35.1%
herbie shell --seed 2024018
(FPCore (a b c)
:name "jeff quadratic root 1"
:precision binary64
(if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))