
(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 (* c (* a -4.0)))
(t_1 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_2 (* c (/ -2.0 (+ b b))))
(t_3 (* (/ (+ b b) a) -0.5)))
(if (<= b -4.4e+151)
(if (>= b 0.0) t_2 t_3)
(if (<= b -2e-154)
(if (>= b 0.0)
(expm1 (/ (- c) b))
(* -0.5 (/ (- b (sqrt (+ (* b b) t_0))) a)))
(if (<= b -5e-256)
(if (>= b 0.0) t_2 (* -0.5 (/ 1.0 (/ a (- b (hypot b (sqrt t_0)))))))
(if (<= b 2.4e+90)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_1)) (/ (- t_1 b) (* a 2.0)))
(if (>= b 0.0) (/ (* c -2.0) (+ b b)) t_3)))))))
double code(double a, double b, double c) {
double t_0 = c * (a * -4.0);
double t_1 = sqrt(((b * b) - (c * (a * 4.0))));
double t_2 = c * (-2.0 / (b + b));
double t_3 = ((b + b) / a) * -0.5;
double tmp_1;
if (b <= -4.4e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_2;
} else {
tmp_2 = t_3;
}
tmp_1 = tmp_2;
} else if (b <= -2e-154) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = expm1((-c / b));
} else {
tmp_3 = -0.5 * ((b - sqrt(((b * b) + t_0))) / a);
}
tmp_1 = tmp_3;
} else if (b <= -5e-256) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = t_2;
} else {
tmp_4 = -0.5 * (1.0 / (a / (b - hypot(b, sqrt(t_0)))));
}
tmp_1 = tmp_4;
} else if (b <= 2.4e+90) {
double tmp_5;
if (b >= 0.0) {
tmp_5 = (c * 2.0) / (-b - t_1);
} else {
tmp_5 = (t_1 - b) / (a * 2.0);
}
tmp_1 = tmp_5;
} else if (b >= 0.0) {
tmp_1 = (c * -2.0) / (b + b);
} else {
tmp_1 = t_3;
}
return tmp_1;
}
public static double code(double a, double b, double c) {
double t_0 = c * (a * -4.0);
double t_1 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double t_2 = c * (-2.0 / (b + b));
double t_3 = ((b + b) / a) * -0.5;
double tmp_1;
if (b <= -4.4e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_2;
} else {
tmp_2 = t_3;
}
tmp_1 = tmp_2;
} else if (b <= -2e-154) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = Math.expm1((-c / b));
} else {
tmp_3 = -0.5 * ((b - Math.sqrt(((b * b) + t_0))) / a);
}
tmp_1 = tmp_3;
} else if (b <= -5e-256) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = t_2;
} else {
tmp_4 = -0.5 * (1.0 / (a / (b - Math.hypot(b, Math.sqrt(t_0)))));
}
tmp_1 = tmp_4;
} else if (b <= 2.4e+90) {
double tmp_5;
if (b >= 0.0) {
tmp_5 = (c * 2.0) / (-b - t_1);
} else {
tmp_5 = (t_1 - b) / (a * 2.0);
}
tmp_1 = tmp_5;
} else if (b >= 0.0) {
tmp_1 = (c * -2.0) / (b + b);
} else {
tmp_1 = t_3;
}
return tmp_1;
}
def code(a, b, c): t_0 = c * (a * -4.0) t_1 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_2 = c * (-2.0 / (b + b)) t_3 = ((b + b) / a) * -0.5 tmp_1 = 0 if b <= -4.4e+151: tmp_2 = 0 if b >= 0.0: tmp_2 = t_2 else: tmp_2 = t_3 tmp_1 = tmp_2 elif b <= -2e-154: tmp_3 = 0 if b >= 0.0: tmp_3 = math.expm1((-c / b)) else: tmp_3 = -0.5 * ((b - math.sqrt(((b * b) + t_0))) / a) tmp_1 = tmp_3 elif b <= -5e-256: tmp_4 = 0 if b >= 0.0: tmp_4 = t_2 else: tmp_4 = -0.5 * (1.0 / (a / (b - math.hypot(b, math.sqrt(t_0))))) tmp_1 = tmp_4 elif b <= 2.4e+90: tmp_5 = 0 if b >= 0.0: tmp_5 = (c * 2.0) / (-b - t_1) else: tmp_5 = (t_1 - b) / (a * 2.0) tmp_1 = tmp_5 elif b >= 0.0: tmp_1 = (c * -2.0) / (b + b) else: tmp_1 = t_3 return tmp_1
function code(a, b, c) t_0 = Float64(c * Float64(a * -4.0)) t_1 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_2 = Float64(c * Float64(-2.0 / Float64(b + b))) t_3 = Float64(Float64(Float64(b + b) / a) * -0.5) tmp_1 = 0.0 if (b <= -4.4e+151) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_2; else tmp_2 = t_3; end tmp_1 = tmp_2; elseif (b <= -2e-154) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = expm1(Float64(Float64(-c) / b)); else tmp_3 = Float64(-0.5 * Float64(Float64(b - sqrt(Float64(Float64(b * b) + t_0))) / a)); end tmp_1 = tmp_3; elseif (b <= -5e-256) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = t_2; else tmp_4 = Float64(-0.5 * Float64(1.0 / Float64(a / Float64(b - hypot(b, sqrt(t_0)))))); end tmp_1 = tmp_4; elseif (b <= 2.4e+90) tmp_5 = 0.0 if (b >= 0.0) tmp_5 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_1)); else tmp_5 = Float64(Float64(t_1 - b) / Float64(a * 2.0)); end tmp_1 = tmp_5; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * -2.0) / Float64(b + b)); else tmp_1 = t_3; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[b, -4.4e+151], If[GreaterEqual[b, 0.0], t$95$2, t$95$3], If[LessEqual[b, -2e-154], If[GreaterEqual[b, 0.0], N[(Exp[N[((-c) / b), $MachinePrecision]] - 1), $MachinePrecision], N[(-0.5 * N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -5e-256], If[GreaterEqual[b, 0.0], t$95$2, N[(-0.5 * N[(1.0 / N[(a / N[(b - N[Sqrt[b ^ 2 + N[Sqrt[t$95$0], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.4e+90], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + b), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(a \cdot -4\right)\\
t_1 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_2 := c \cdot \frac{-2}{b + b}\\
t_3 := \frac{b + b}{a} \cdot -0.5\\
\mathbf{if}\;b \leq -4.4 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-154}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\mathsf{expm1}\left(\frac{-c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{b - \sqrt{b \cdot b + t_0}}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-256}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{1}{\frac{a}{b - \mathsf{hypot}\left(b, \sqrt{t_0}\right)}}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{+90}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
\end{array}
if b < -4.40000000000000013e151Initial program 38.2%
Simplified38.2%
Taylor expanded in b around inf 38.2%
Taylor expanded in b around -inf 100.0%
count-2100.0%
Simplified100.0%
if -4.40000000000000013e151 < b < -1.9999999999999999e-154Initial program 91.8%
Simplified91.8%
Taylor expanded in b around inf 91.8%
fma-udef91.8%
Applied egg-rr91.8%
expm1-log1p-u91.8%
Applied egg-rr91.8%
Taylor expanded in c around 0 91.8%
associate-*r/91.8%
neg-mul-191.8%
Simplified91.8%
if -1.9999999999999999e-154 < b < -5e-256Initial program 51.7%
Simplified51.7%
Taylor expanded in b around inf 51.7%
fma-udef51.7%
Applied egg-rr51.7%
clear-num51.7%
inv-pow51.7%
add-sqr-sqrt51.7%
hypot-def86.3%
Applied egg-rr86.3%
unpow-186.3%
Simplified86.3%
if -5e-256 < b < 2.4000000000000001e90Initial program 83.5%
if 2.4000000000000001e90 < b Initial program 45.2%
Simplified45.2%
Taylor expanded in b around inf 96.9%
Taylor expanded in b around -inf 96.9%
count-296.9%
Simplified96.9%
associate-*r/97.2%
Applied egg-rr97.2%
Final simplification91.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* c (* a -4.0))) (t_1 (* (/ (+ b b) a) -0.5)))
(if (<= b -2.5e+151)
(if (>= b 0.0) (* c (/ -2.0 (+ b b))) t_1)
(if (<= b -1.4e-155)
(if (>= b 0.0)
(expm1 (/ (- c) b))
(* -0.5 (/ (- b (sqrt (+ (* b b) t_0))) a)))
(if (<= b 6e+89)
(if (>= b 0.0)
(* c (/ -2.0 (+ b (sqrt (fma b b t_0)))))
(* -0.5 (pow (cbrt (/ (- b (hypot b (sqrt t_0))) a)) 3.0)))
(if (>= b 0.0) (/ (* c -2.0) (+ b b)) t_1))))))
double code(double a, double b, double c) {
double t_0 = c * (a * -4.0);
double t_1 = ((b + b) / a) * -0.5;
double tmp_1;
if (b <= -2.5e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (b + b));
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= -1.4e-155) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = expm1((-c / b));
} else {
tmp_3 = -0.5 * ((b - sqrt(((b * b) + t_0))) / a);
}
tmp_1 = tmp_3;
} else if (b <= 6e+89) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = c * (-2.0 / (b + sqrt(fma(b, b, t_0))));
} else {
tmp_4 = -0.5 * pow(cbrt(((b - hypot(b, sqrt(t_0))) / a)), 3.0);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c * -2.0) / (b + b);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(c * Float64(a * -4.0)) t_1 = Float64(Float64(Float64(b + b) / a) * -0.5) tmp_1 = 0.0 if (b <= -2.5e+151) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(b + b))); else tmp_2 = t_1; end tmp_1 = tmp_2; elseif (b <= -1.4e-155) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = expm1(Float64(Float64(-c) / b)); else tmp_3 = Float64(-0.5 * Float64(Float64(b - sqrt(Float64(Float64(b * b) + t_0))) / a)); end tmp_1 = tmp_3; elseif (b <= 6e+89) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(c * Float64(-2.0 / Float64(b + sqrt(fma(b, b, t_0))))); else tmp_4 = Float64(-0.5 * (cbrt(Float64(Float64(b - hypot(b, sqrt(t_0))) / a)) ^ 3.0)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * -2.0) / Float64(b + b)); else tmp_1 = t_1; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[b, -2.5e+151], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1], If[LessEqual[b, -1.4e-155], If[GreaterEqual[b, 0.0], N[(Exp[N[((-c) / b), $MachinePrecision]] - 1), $MachinePrecision], N[(-0.5 * N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 6e+89], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + N[Sqrt[N[(b * b + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[Power[N[Power[N[(N[(b - N[Sqrt[b ^ 2 + N[Sqrt[t$95$0], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + b), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(a \cdot -4\right)\\
t_1 := \frac{b + b}{a} \cdot -0.5\\
\mathbf{if}\;b \leq -2.5 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \leq -1.4 \cdot 10^{-155}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\mathsf{expm1}\left(\frac{-c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{b - \sqrt{b \cdot b + t_0}}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{+89}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \sqrt{\mathsf{fma}\left(b, b, t_0\right)}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot {\left(\sqrt[3]{\frac{b - \mathsf{hypot}\left(b, \sqrt{t_0}\right)}{a}}\right)}^{3}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if b < -2.5000000000000001e151Initial program 38.2%
Simplified38.2%
Taylor expanded in b around inf 38.2%
Taylor expanded in b around -inf 100.0%
count-2100.0%
Simplified100.0%
if -2.5000000000000001e151 < b < -1.4e-155Initial program 91.8%
Simplified91.8%
Taylor expanded in b around inf 91.8%
fma-udef91.8%
Applied egg-rr91.8%
expm1-log1p-u91.8%
Applied egg-rr91.8%
Taylor expanded in c around 0 91.8%
associate-*r/91.8%
neg-mul-191.8%
Simplified91.8%
if -1.4e-155 < b < 6.00000000000000025e89Initial program 79.3%
Simplified79.2%
add-cube-cbrt79.1%
pow379.1%
fma-udef79.1%
add-sqr-sqrt79.1%
hypot-def83.5%
Applied egg-rr83.5%
if 6.00000000000000025e89 < b Initial program 45.2%
Simplified45.2%
Taylor expanded in b around inf 96.9%
Taylor expanded in b around -inf 96.9%
count-296.9%
Simplified96.9%
associate-*r/97.2%
Applied egg-rr97.2%
Final simplification91.2%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (+ (* b b) (* c (* a -4.0))))) (t_1 (* (/ (+ b b) a) -0.5)))
(if (<= b -2.6e+151)
(if (>= b 0.0) (* c (/ -2.0 (+ b b))) t_1)
(if (<= b 6.8e-304)
(if (>= b 0.0) (expm1 (/ (- c) b)) (* -0.5 (/ (- b t_0) a)))
(if (<= b 7.6e+89)
(if (>= b 0.0)
(* c (/ -2.0 (+ b t_0)))
(* -0.5 (fma 2.0 (/ b a) (* -2.0 (/ c b)))))
(if (>= b 0.0) (/ (* c -2.0) (+ b b)) t_1))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) + (c * (a * -4.0))));
double t_1 = ((b + b) / a) * -0.5;
double tmp_1;
if (b <= -2.6e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (b + b));
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 6.8e-304) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = expm1((-c / b));
} else {
tmp_3 = -0.5 * ((b - t_0) / a);
}
tmp_1 = tmp_3;
} else if (b <= 7.6e+89) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = c * (-2.0 / (b + t_0));
} else {
tmp_4 = -0.5 * fma(2.0, (b / a), (-2.0 * (c / b)));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c * -2.0) / (b + b);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) + Float64(c * Float64(a * -4.0)))) t_1 = Float64(Float64(Float64(b + b) / a) * -0.5) tmp_1 = 0.0 if (b <= -2.6e+151) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(b + b))); else tmp_2 = t_1; end tmp_1 = tmp_2; elseif (b <= 6.8e-304) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = expm1(Float64(Float64(-c) / b)); else tmp_3 = Float64(-0.5 * Float64(Float64(b - t_0) / a)); end tmp_1 = tmp_3; elseif (b <= 7.6e+89) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(c * Float64(-2.0 / Float64(b + t_0))); else tmp_4 = Float64(-0.5 * fma(2.0, Float64(b / a), Float64(-2.0 * Float64(c / b)))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * -2.0) / Float64(b + b)); else tmp_1 = t_1; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[b, -2.6e+151], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1], If[LessEqual[b, 6.8e-304], If[GreaterEqual[b, 0.0], N[(Exp[N[((-c) / b), $MachinePrecision]] - 1), $MachinePrecision], N[(-0.5 * N[(N[(b - t$95$0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 7.6e+89], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(2.0 * N[(b / a), $MachinePrecision] + N[(-2.0 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + b), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}\\
t_1 := \frac{b + b}{a} \cdot -0.5\\
\mathbf{if}\;b \leq -2.6 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \leq 6.8 \cdot 10^{-304}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\mathsf{expm1}\left(\frac{-c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{b - t_0}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{+89}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + t_0}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \mathsf{fma}\left(2, \frac{b}{a}, -2 \cdot \frac{c}{b}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if b < -2.60000000000000013e151Initial program 38.2%
Simplified38.2%
Taylor expanded in b around inf 38.2%
Taylor expanded in b around -inf 100.0%
count-2100.0%
Simplified100.0%
if -2.60000000000000013e151 < b < 6.7999999999999997e-304Initial program 78.3%
Simplified78.3%
Taylor expanded in b around inf 78.3%
fma-udef78.3%
Applied egg-rr78.3%
expm1-log1p-u78.2%
Applied egg-rr78.2%
Taylor expanded in c around 0 78.3%
associate-*r/78.3%
neg-mul-178.3%
Simplified78.3%
if 6.7999999999999997e-304 < b < 7.60000000000000047e89Initial program 85.4%
Simplified85.2%
Taylor expanded in b around -inf 85.2%
+-commutative85.2%
fma-def85.2%
Simplified85.2%
fma-udef37.3%
Applied egg-rr85.2%
if 7.60000000000000047e89 < b Initial program 45.2%
Simplified45.2%
Taylor expanded in b around inf 96.9%
Taylor expanded in b around -inf 96.9%
count-296.9%
Simplified96.9%
associate-*r/97.2%
Applied egg-rr97.2%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))) (t_1 (* (/ (+ b b) a) -0.5)))
(if (<= b -4.9e+151)
(if (>= b 0.0) (* c (/ -2.0 (+ b b))) t_1)
(if (<= b 2.65e+88)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) (/ (- t_0 b) (* a 2.0)))
(if (>= b 0.0) (/ (* c -2.0) (+ b b)) t_1)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = ((b + b) / a) * -0.5;
double tmp_1;
if (b <= -4.9e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (b + b));
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 2.65e+88) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c * -2.0) / (b + b);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
t_1 = ((b + b) / a) * (-0.5d0)
if (b <= (-4.9d+151)) then
if (b >= 0.0d0) then
tmp_2 = c * ((-2.0d0) / (b + b))
else
tmp_2 = t_1
end if
tmp_1 = tmp_2
else if (b <= 2.65d+88) then
if (b >= 0.0d0) then
tmp_3 = (c * 2.0d0) / (-b - t_0)
else
tmp_3 = (t_0 - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c * (-2.0d0)) / (b + b)
else
tmp_1 = t_1
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = ((b + b) / a) * -0.5;
double tmp_1;
if (b <= -4.9e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (b + b));
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 2.65e+88) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c * -2.0) / (b + b);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_1 = ((b + b) / a) * -0.5 tmp_1 = 0 if b <= -4.9e+151: tmp_2 = 0 if b >= 0.0: tmp_2 = c * (-2.0 / (b + b)) else: tmp_2 = t_1 tmp_1 = tmp_2 elif b <= 2.65e+88: tmp_3 = 0 if b >= 0.0: tmp_3 = (c * 2.0) / (-b - t_0) else: tmp_3 = (t_0 - b) / (a * 2.0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c * -2.0) / (b + b) else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_1 = Float64(Float64(Float64(b + b) / a) * -0.5) tmp_1 = 0.0 if (b <= -4.9e+151) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(b + b))); else tmp_2 = t_1; end tmp_1 = tmp_2; elseif (b <= 2.65e+88) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * -2.0) / Float64(b + b)); else tmp_1 = t_1; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); t_1 = ((b + b) / a) * -0.5; tmp_2 = 0.0; if (b <= -4.9e+151) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * (-2.0 / (b + b)); else tmp_3 = t_1; end tmp_2 = tmp_3; elseif (b <= 2.65e+88) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (c * 2.0) / (-b - t_0); else tmp_4 = (t_0 - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c * -2.0) / (b + b); else tmp_2 = t_1; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[b, -4.9e+151], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1], If[LessEqual[b, 2.65e+88], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + b), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \frac{b + b}{a} \cdot -0.5\\
\mathbf{if}\;b \leq -4.9 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \leq 2.65 \cdot 10^{+88}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if b < -4.8999999999999999e151Initial program 38.2%
Simplified38.2%
Taylor expanded in b around inf 38.2%
Taylor expanded in b around -inf 100.0%
count-2100.0%
Simplified100.0%
if -4.8999999999999999e151 < b < 2.64999999999999994e88Initial program 82.5%
if 2.64999999999999994e88 < b Initial program 45.2%
Simplified45.2%
Taylor expanded in b around inf 96.9%
Taylor expanded in b around -inf 96.9%
count-296.9%
Simplified96.9%
associate-*r/97.2%
Applied egg-rr97.2%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* c (* a -4.0))) (t_1 (* (/ (+ b b) a) -0.5)))
(if (<= b -5.2e+153)
(if (>= b 0.0) (* c (/ -2.0 (+ b b))) t_1)
(if (<= b 6.8e-304)
(if (>= b 0.0)
(expm1 (/ (- c) b))
(* -0.5 (/ (- b (sqrt (+ (* b b) t_0))) a)))
(if (<= b 1.25e-94)
(if (>= b 0.0)
(/ (* c -2.0) (+ b (sqrt t_0)))
(* -0.5 (fma 2.0 (/ b a) (* -2.0 (/ c b)))))
(if (>= b 0.0) (/ (* c -2.0) (+ b b)) t_1))))))
double code(double a, double b, double c) {
double t_0 = c * (a * -4.0);
double t_1 = ((b + b) / a) * -0.5;
double tmp_1;
if (b <= -5.2e+153) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (b + b));
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 6.8e-304) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = expm1((-c / b));
} else {
tmp_3 = -0.5 * ((b - sqrt(((b * b) + t_0))) / a);
}
tmp_1 = tmp_3;
} else if (b <= 1.25e-94) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * -2.0) / (b + sqrt(t_0));
} else {
tmp_4 = -0.5 * fma(2.0, (b / a), (-2.0 * (c / b)));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c * -2.0) / (b + b);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(c * Float64(a * -4.0)) t_1 = Float64(Float64(Float64(b + b) / a) * -0.5) tmp_1 = 0.0 if (b <= -5.2e+153) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(b + b))); else tmp_2 = t_1; end tmp_1 = tmp_2; elseif (b <= 6.8e-304) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = expm1(Float64(Float64(-c) / b)); else tmp_3 = Float64(-0.5 * Float64(Float64(b - sqrt(Float64(Float64(b * b) + t_0))) / a)); end tmp_1 = tmp_3; elseif (b <= 1.25e-94) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * -2.0) / Float64(b + sqrt(t_0))); else tmp_4 = Float64(-0.5 * fma(2.0, Float64(b / a), Float64(-2.0 * Float64(c / b)))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * -2.0) / Float64(b + b)); else tmp_1 = t_1; end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[b, -5.2e+153], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1], If[LessEqual[b, 6.8e-304], If[GreaterEqual[b, 0.0], N[(Exp[N[((-c) / b), $MachinePrecision]] - 1), $MachinePrecision], N[(-0.5 * N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.25e-94], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(2.0 * N[(b / a), $MachinePrecision] + N[(-2.0 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + b), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(a \cdot -4\right)\\
t_1 := \frac{b + b}{a} \cdot -0.5\\
\mathbf{if}\;b \leq -5.2 \cdot 10^{+153}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{elif}\;b \leq 6.8 \cdot 10^{-304}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\mathsf{expm1}\left(\frac{-c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{b - \sqrt{b \cdot b + t_0}}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{-94}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + \sqrt{t_0}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \mathsf{fma}\left(2, \frac{b}{a}, -2 \cdot \frac{c}{b}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if b < -5.1999999999999998e153Initial program 38.2%
Simplified38.2%
Taylor expanded in b around inf 38.2%
Taylor expanded in b around -inf 100.0%
count-2100.0%
Simplified100.0%
if -5.1999999999999998e153 < b < 6.7999999999999997e-304Initial program 78.3%
Simplified78.3%
Taylor expanded in b around inf 78.3%
fma-udef78.3%
Applied egg-rr78.3%
expm1-log1p-u78.2%
Applied egg-rr78.2%
Taylor expanded in c around 0 78.3%
associate-*r/78.3%
neg-mul-178.3%
Simplified78.3%
if 6.7999999999999997e-304 < b < 1.2499999999999999e-94Initial program 77.2%
Simplified77.0%
Taylor expanded in b around -inf 77.0%
+-commutative77.0%
fma-def77.0%
Simplified77.0%
Taylor expanded in b around 0 73.1%
associate-*r*12.6%
*-commutative12.6%
*-commutative12.6%
Simplified73.1%
associate-*r/73.2%
Applied egg-rr73.2%
if 1.2499999999999999e-94 < b Initial program 63.9%
Simplified63.8%
Taylor expanded in b around inf 85.5%
Taylor expanded in b around -inf 85.5%
count-285.5%
Simplified85.5%
associate-*r/85.8%
Applied egg-rr85.8%
Final simplification84.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* -2.0 (/ c b)))
(t_1 (* c (/ -2.0 (+ b b))))
(t_2 (sqrt (* c (* a -4.0)))))
(if (<= b -6.5e-48)
(if (>= b 0.0) t_1 (* -0.5 (+ t_0 (* 2.0 (/ b a)))))
(if (<= b -2e-310)
(if (>= b 0.0) t_1 (* -0.5 (/ (- b t_2) a)))
(if (<= b 1.25e-94)
(if (>= b 0.0)
(* c (/ -2.0 (+ b t_2)))
(* -0.5 (fma 2.0 (/ b a) t_0)))
(if (>= b 0.0) (/ (* c -2.0) (+ b b)) (* (/ (+ b b) a) -0.5)))))))
double code(double a, double b, double c) {
double t_0 = -2.0 * (c / b);
double t_1 = c * (-2.0 / (b + b));
double t_2 = sqrt((c * (a * -4.0)));
double tmp_1;
if (b <= -6.5e-48) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = -0.5 * (t_0 + (2.0 * (b / a)));
}
tmp_1 = tmp_2;
} else if (b <= -2e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = -0.5 * ((b - t_2) / a);
}
tmp_1 = tmp_3;
} else if (b <= 1.25e-94) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = c * (-2.0 / (b + t_2));
} else {
tmp_4 = -0.5 * fma(2.0, (b / a), t_0);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c * -2.0) / (b + b);
} else {
tmp_1 = ((b + b) / a) * -0.5;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(-2.0 * Float64(c / b)) t_1 = Float64(c * Float64(-2.0 / Float64(b + b))) t_2 = sqrt(Float64(c * Float64(a * -4.0))) tmp_1 = 0.0 if (b <= -6.5e-48) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(-0.5 * Float64(t_0 + Float64(2.0 * Float64(b / a)))); end tmp_1 = tmp_2; elseif (b <= -2e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = Float64(-0.5 * Float64(Float64(b - t_2) / a)); end tmp_1 = tmp_3; elseif (b <= 1.25e-94) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(c * Float64(-2.0 / Float64(b + t_2))); else tmp_4 = Float64(-0.5 * fma(2.0, Float64(b / a), t_0)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * -2.0) / Float64(b + b)); else tmp_1 = Float64(Float64(Float64(b + b) / a) * -0.5); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(-2.0 * N[(c / b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -6.5e-48], If[GreaterEqual[b, 0.0], t$95$1, N[(-0.5 * N[(t$95$0 + N[(2.0 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -2e-310], If[GreaterEqual[b, 0.0], t$95$1, N[(-0.5 * N[(N[(b - t$95$2), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.25e-94], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(2.0 * N[(b / a), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -2 \cdot \frac{c}{b}\\
t_1 := c \cdot \frac{-2}{b + b}\\
t_2 := \sqrt{c \cdot \left(a \cdot -4\right)}\\
\mathbf{if}\;b \leq -6.5 \cdot 10^{-48}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(t_0 + 2 \cdot \frac{b}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{b - t_2}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{-94}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + t_2}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \mathsf{fma}\left(2, \frac{b}{a}, t_0\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + b}{a} \cdot -0.5\\
\end{array}
\end{array}
if b < -6.5e-48Initial program 57.9%
Simplified57.9%
Taylor expanded in b around inf 57.9%
Taylor expanded in b around -inf 92.9%
if -6.5e-48 < b < -1.999999999999994e-310Initial program 67.7%
Simplified67.7%
Taylor expanded in b around inf 67.7%
Taylor expanded in b around 0 58.3%
associate-*r*58.3%
*-commutative58.3%
*-commutative58.3%
Simplified58.3%
if -1.999999999999994e-310 < b < 1.2499999999999999e-94Initial program 75.6%
Simplified75.4%
Taylor expanded in b around -inf 75.4%
+-commutative75.4%
fma-def75.4%
Simplified75.4%
Taylor expanded in b around 0 71.6%
associate-*r*12.4%
*-commutative12.4%
*-commutative12.4%
Simplified71.6%
if 1.2499999999999999e-94 < b Initial program 63.9%
Simplified63.8%
Taylor expanded in b around inf 85.5%
Taylor expanded in b around -inf 85.5%
count-285.5%
Simplified85.5%
associate-*r/85.8%
Applied egg-rr85.8%
Final simplification82.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* -2.0 (/ c b)))
(t_1 (* c (/ -2.0 (+ b b))))
(t_2 (sqrt (* c (* a -4.0)))))
(if (<= b -4.4e-48)
(if (>= b 0.0) t_1 (* -0.5 (+ t_0 (* 2.0 (/ b a)))))
(if (<= b -2e-310)
(if (>= b 0.0) t_1 (* -0.5 (/ (- b t_2) a)))
(if (<= b 1.16e-94)
(if (>= b 0.0)
(/ (* c -2.0) (+ b t_2))
(* -0.5 (fma 2.0 (/ b a) t_0)))
(if (>= b 0.0) (/ (* c -2.0) (+ b b)) (* (/ (+ b b) a) -0.5)))))))
double code(double a, double b, double c) {
double t_0 = -2.0 * (c / b);
double t_1 = c * (-2.0 / (b + b));
double t_2 = sqrt((c * (a * -4.0)));
double tmp_1;
if (b <= -4.4e-48) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = -0.5 * (t_0 + (2.0 * (b / a)));
}
tmp_1 = tmp_2;
} else if (b <= -2e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = -0.5 * ((b - t_2) / a);
}
tmp_1 = tmp_3;
} else if (b <= 1.16e-94) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * -2.0) / (b + t_2);
} else {
tmp_4 = -0.5 * fma(2.0, (b / a), t_0);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c * -2.0) / (b + b);
} else {
tmp_1 = ((b + b) / a) * -0.5;
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(-2.0 * Float64(c / b)) t_1 = Float64(c * Float64(-2.0 / Float64(b + b))) t_2 = sqrt(Float64(c * Float64(a * -4.0))) tmp_1 = 0.0 if (b <= -4.4e-48) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(-0.5 * Float64(t_0 + Float64(2.0 * Float64(b / a)))); end tmp_1 = tmp_2; elseif (b <= -2e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = Float64(-0.5 * Float64(Float64(b - t_2) / a)); end tmp_1 = tmp_3; elseif (b <= 1.16e-94) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * -2.0) / Float64(b + t_2)); else tmp_4 = Float64(-0.5 * fma(2.0, Float64(b / a), t_0)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * -2.0) / Float64(b + b)); else tmp_1 = Float64(Float64(Float64(b + b) / a) * -0.5); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(-2.0 * N[(c / b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -4.4e-48], If[GreaterEqual[b, 0.0], t$95$1, N[(-0.5 * N[(t$95$0 + N[(2.0 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -2e-310], If[GreaterEqual[b, 0.0], t$95$1, N[(-0.5 * N[(N[(b - t$95$2), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.16e-94], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + t$95$2), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(2.0 * N[(b / a), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -2 \cdot \frac{c}{b}\\
t_1 := c \cdot \frac{-2}{b + b}\\
t_2 := \sqrt{c \cdot \left(a \cdot -4\right)}\\
\mathbf{if}\;b \leq -4.4 \cdot 10^{-48}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(t_0 + 2 \cdot \frac{b}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{b - t_2}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.16 \cdot 10^{-94}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + t_2}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \mathsf{fma}\left(2, \frac{b}{a}, t_0\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + b}{a} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.40000000000000025e-48Initial program 57.9%
Simplified57.9%
Taylor expanded in b around inf 57.9%
Taylor expanded in b around -inf 92.9%
if -4.40000000000000025e-48 < b < -1.999999999999994e-310Initial program 67.7%
Simplified67.7%
Taylor expanded in b around inf 67.7%
Taylor expanded in b around 0 58.3%
associate-*r*58.3%
*-commutative58.3%
*-commutative58.3%
Simplified58.3%
if -1.999999999999994e-310 < b < 1.16000000000000001e-94Initial program 75.6%
Simplified75.4%
Taylor expanded in b around -inf 75.4%
+-commutative75.4%
fma-def75.4%
Simplified75.4%
Taylor expanded in b around 0 71.6%
associate-*r*12.4%
*-commutative12.4%
*-commutative12.4%
Simplified71.6%
associate-*r/71.8%
Applied egg-rr71.8%
if 1.16000000000000001e-94 < b Initial program 63.9%
Simplified63.8%
Taylor expanded in b around inf 85.5%
Taylor expanded in b around -inf 85.5%
count-285.5%
Simplified85.5%
associate-*r/85.8%
Applied egg-rr85.8%
Final simplification82.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* c (/ -2.0 (+ b b)))))
(if (<= b -4.8e-48)
(if (>= b 0.0) t_0 (* -0.5 (+ (* -2.0 (/ c b)) (* 2.0 (/ b a)))))
(if (>= b 0.0) t_0 (* -0.5 (/ (- b (sqrt (* c (* a -4.0)))) a))))))
double code(double a, double b, double c) {
double t_0 = c * (-2.0 / (b + b));
double tmp_1;
if (b <= -4.8e-48) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = -0.5 * ((-2.0 * (c / b)) + (2.0 * (b / a)));
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = -0.5 * ((b - sqrt((c * (a * -4.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 = c * ((-2.0d0) / (b + b))
if (b <= (-4.8d-48)) then
if (b >= 0.0d0) then
tmp_2 = t_0
else
tmp_2 = (-0.5d0) * (((-2.0d0) * (c / b)) + (2.0d0 * (b / a)))
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = t_0
else
tmp_1 = (-0.5d0) * ((b - sqrt((c * (a * (-4.0d0))))) / a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = c * (-2.0 / (b + b));
double tmp_1;
if (b <= -4.8e-48) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = -0.5 * ((-2.0 * (c / b)) + (2.0 * (b / a)));
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = -0.5 * ((b - Math.sqrt((c * (a * -4.0)))) / a);
}
return tmp_1;
}
def code(a, b, c): t_0 = c * (-2.0 / (b + b)) tmp_1 = 0 if b <= -4.8e-48: tmp_2 = 0 if b >= 0.0: tmp_2 = t_0 else: tmp_2 = -0.5 * ((-2.0 * (c / b)) + (2.0 * (b / a))) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = t_0 else: tmp_1 = -0.5 * ((b - math.sqrt((c * (a * -4.0)))) / a) return tmp_1
function code(a, b, c) t_0 = Float64(c * Float64(-2.0 / Float64(b + b))) tmp_1 = 0.0 if (b <= -4.8e-48) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(-0.5 * Float64(Float64(-2.0 * Float64(c / b)) + Float64(2.0 * Float64(b / a)))); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = t_0; else tmp_1 = Float64(-0.5 * Float64(Float64(b - sqrt(Float64(c * Float64(a * -4.0)))) / a)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = c * (-2.0 / (b + b)); tmp_2 = 0.0; if (b <= -4.8e-48) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_0; else tmp_3 = -0.5 * ((-2.0 * (c / b)) + (2.0 * (b / a))); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = t_0; else tmp_2 = -0.5 * ((b - sqrt((c * (a * -4.0)))) / a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4.8e-48], If[GreaterEqual[b, 0.0], t$95$0, N[(-0.5 * N[(N[(-2.0 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$0, N[(-0.5 * N[(N[(b - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \frac{-2}{b + b}\\
\mathbf{if}\;b \leq -4.8 \cdot 10^{-48}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(-2 \cdot \frac{c}{b} + 2 \cdot \frac{b}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{b - \sqrt{c \cdot \left(a \cdot -4\right)}}{a}\\
\end{array}
\end{array}
if b < -4.8e-48Initial program 57.9%
Simplified57.9%
Taylor expanded in b around inf 57.9%
Taylor expanded in b around -inf 92.9%
if -4.8e-48 < b Initial program 67.6%
Simplified67.5%
Taylor expanded in b around inf 63.6%
Taylor expanded in b around 0 62.0%
associate-*r*62.0%
*-commutative62.0%
*-commutative62.0%
Simplified62.0%
Final simplification71.1%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* c (/ -2.0 (+ b b))) (* -0.5 (/ (* c -2.0) b))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c * (-2.0 / (b + b));
} else {
tmp = -0.5 * ((c * -2.0) / 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 = c * ((-2.0d0) / (b + b))
else
tmp = (-0.5d0) * ((c * (-2.0d0)) / b)
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));
} else {
tmp = -0.5 * ((c * -2.0) / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c * (-2.0 / (b + b)) else: tmp = -0.5 * ((c * -2.0) / b) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c * Float64(-2.0 / Float64(b + b))); else tmp = Float64(-0.5 * Float64(Float64(c * -2.0) / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c * (-2.0 / (b + b)); else tmp = -0.5 * ((c * -2.0) / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(c * -2.0), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c \cdot -2}{b}\\
\end{array}
\end{array}
Initial program 64.7%
Simplified64.7%
Taylor expanded in b around inf 61.9%
Taylor expanded in b around -inf 68.2%
Taylor expanded in c around inf 38.4%
associate-*r/38.4%
Simplified38.4%
Final simplification38.4%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* c (/ -2.0 (+ b b))) (* (/ (+ b b) a) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c * (-2.0 / (b + b));
} else {
tmp = ((b + b) / a) * -0.5;
}
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))
else
tmp = ((b + b) / a) * (-0.5d0)
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));
} else {
tmp = ((b + b) / a) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c * (-2.0 / (b + b)) else: tmp = ((b + b) / a) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c * Float64(-2.0 / Float64(b + b))); else tmp = Float64(Float64(Float64(b + b) / a) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c * (-2.0 / (b + b)); else tmp = ((b + b) / a) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + b}{a} \cdot -0.5\\
\end{array}
\end{array}
Initial program 64.7%
Simplified64.7%
Taylor expanded in b around inf 61.9%
Taylor expanded in b around -inf 68.1%
count-268.1%
Simplified68.1%
Final simplification68.1%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* c -2.0) (+ b b)) (* (/ (+ b b) a) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c * -2.0) / (b + b);
} else {
tmp = ((b + b) / a) * -0.5;
}
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)
else
tmp = ((b + b) / a) * (-0.5d0)
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);
} else {
tmp = ((b + b) / a) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (c * -2.0) / (b + b) else: tmp = ((b + b) / a) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(c * -2.0) / Float64(b + b)); else tmp = Float64(Float64(Float64(b + b) / a) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (c * -2.0) / (b + b); else tmp = ((b + b) / a) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] / N[(b + b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot -2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + b}{a} \cdot -0.5\\
\end{array}
\end{array}
Initial program 64.7%
Simplified64.7%
Taylor expanded in b around inf 61.9%
Taylor expanded in b around -inf 68.1%
count-268.1%
Simplified68.1%
associate-*r/68.2%
Applied egg-rr68.2%
Final simplification68.2%
herbie shell --seed 2023285
(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))))