
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (fma (/ c (hypot c d)) (/ b (hypot c d)) (* a (* (expm1 (log1p (/ d (hypot d c)))) (/ -1.0 (hypot d c))))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), (a * (expm1(log1p((d / hypot(d, c)))) * (-1.0 / hypot(d, c)))));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a * Float64(expm1(log1p(Float64(d / hypot(d, c)))) * Float64(-1.0 / hypot(d, c))))) end
code[a_, b_, c_, d_] := N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(Exp[N[Log[1 + N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision] * N[(-1.0 / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\mathsf{hypot}\left(d, c\right)}\right)\right) \cdot \frac{-1}{\mathsf{hypot}\left(d, c\right)}\right)\right)
\end{array}
Initial program 63.0%
div-sub61.0%
*-commutative61.0%
add-sqr-sqrt61.0%
times-frac62.1%
fma-neg62.1%
hypot-define62.1%
hypot-define76.4%
associate-/l*79.7%
add-sqr-sqrt79.7%
pow279.7%
hypot-define79.7%
Applied egg-rr79.7%
*-un-lft-identity79.7%
unpow279.7%
times-frac97.6%
add-sqr-sqrt47.5%
sqrt-prod59.3%
sqr-neg59.3%
sqrt-unprod31.1%
add-sqr-sqrt58.5%
hypot-undefine56.4%
+-commutative56.4%
hypot-define58.5%
add-sqr-sqrt31.1%
sqrt-unprod59.3%
sqr-neg59.3%
sqrt-prod47.5%
add-sqr-sqrt97.6%
hypot-undefine79.7%
+-commutative79.7%
hypot-define97.6%
Applied egg-rr97.6%
expm1-log1p-u97.6%
expm1-undefine92.0%
Applied egg-rr92.0%
expm1-define97.6%
Simplified97.6%
Final simplification97.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ c (hypot c d))) (t_1 (/ b (hypot c d))))
(if (<= d -1.02e+188)
(fma t_0 t_1 (/ a (- d)))
(if (<= d 5.3e+125)
(fma t_0 t_1 (/ (/ (* d a) (hypot d c)) (- (hypot d c))))
(* (/ 1.0 (hypot c d)) (- (* b (/ c d)) a))))))
double code(double a, double b, double c, double d) {
double t_0 = c / hypot(c, d);
double t_1 = b / hypot(c, d);
double tmp;
if (d <= -1.02e+188) {
tmp = fma(t_0, t_1, (a / -d));
} else if (d <= 5.3e+125) {
tmp = fma(t_0, t_1, (((d * a) / hypot(d, c)) / -hypot(d, c)));
} else {
tmp = (1.0 / hypot(c, d)) * ((b * (c / d)) - a);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(c / hypot(c, d)) t_1 = Float64(b / hypot(c, d)) tmp = 0.0 if (d <= -1.02e+188) tmp = fma(t_0, t_1, Float64(a / Float64(-d))); elseif (d <= 5.3e+125) tmp = fma(t_0, t_1, Float64(Float64(Float64(d * a) / hypot(d, c)) / Float64(-hypot(d, c)))); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(b * Float64(c / d)) - a)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.02e+188], N[(t$95$0 * t$95$1 + N[(a / (-d)), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.3e+125], N[(t$95$0 * t$95$1 + N[(N[(N[(d * a), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -1.02 \cdot 10^{+188}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_1, \frac{a}{-d}\right)\\
\mathbf{elif}\;d \leq 5.3 \cdot 10^{+125}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_1, \frac{\frac{d \cdot a}{\mathsf{hypot}\left(d, c\right)}}{-\mathsf{hypot}\left(d, c\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b \cdot \frac{c}{d} - a\right)\\
\end{array}
\end{array}
if d < -1.02e188Initial program 31.3%
div-sub31.3%
*-commutative31.3%
add-sqr-sqrt31.3%
times-frac31.7%
fma-neg31.7%
hypot-define31.7%
hypot-define41.0%
associate-/l*49.1%
add-sqr-sqrt49.1%
pow249.1%
hypot-define49.1%
Applied egg-rr49.1%
Taylor expanded in d around inf 96.8%
if -1.02e188 < d < 5.3000000000000003e125Initial program 73.3%
div-sub70.5%
*-commutative70.5%
add-sqr-sqrt70.5%
times-frac71.9%
fma-neg71.9%
hypot-define71.9%
hypot-define86.9%
associate-/l*89.3%
add-sqr-sqrt89.3%
pow289.3%
hypot-define89.3%
Applied egg-rr89.3%
unpow289.3%
hypot-undefine89.3%
hypot-undefine89.3%
add-sqr-sqrt89.3%
associate-*r/86.9%
add-sqr-sqrt86.9%
hypot-undefine86.9%
hypot-undefine86.9%
associate-/r*96.6%
*-commutative96.6%
hypot-undefine87.0%
+-commutative87.0%
hypot-define96.6%
hypot-undefine87.0%
+-commutative87.0%
hypot-define96.6%
Applied egg-rr96.6%
if 5.3000000000000003e125 < d Initial program 34.3%
*-un-lft-identity34.3%
add-sqr-sqrt34.3%
times-frac34.3%
hypot-define34.3%
fma-neg34.3%
distribute-rgt-neg-in34.3%
hypot-define59.7%
Applied egg-rr59.7%
Taylor expanded in c around 0 78.2%
neg-mul-178.2%
+-commutative78.2%
unsub-neg78.2%
associate-/l*89.8%
Simplified89.8%
Final simplification95.7%
(FPCore (a b c d) :precision binary64 (fma (/ c (hypot c d)) (/ b (hypot c d)) (* a (* (/ d (hypot d c)) (/ -1.0 (hypot d c))))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), (a * ((d / hypot(d, c)) * (-1.0 / hypot(d, c)))));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a * Float64(Float64(d / hypot(d, c)) * Float64(-1.0 / hypot(d, c))))) end
code[a_, b_, c_, d_] := N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \left(\frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{-1}{\mathsf{hypot}\left(d, c\right)}\right)\right)
\end{array}
Initial program 63.0%
div-sub61.0%
*-commutative61.0%
add-sqr-sqrt61.0%
times-frac62.1%
fma-neg62.1%
hypot-define62.1%
hypot-define76.4%
associate-/l*79.7%
add-sqr-sqrt79.7%
pow279.7%
hypot-define79.7%
Applied egg-rr79.7%
*-un-lft-identity79.7%
unpow279.7%
times-frac97.6%
add-sqr-sqrt47.5%
sqrt-prod59.3%
sqr-neg59.3%
sqrt-unprod31.1%
add-sqr-sqrt58.5%
hypot-undefine56.4%
+-commutative56.4%
hypot-define58.5%
add-sqr-sqrt31.1%
sqrt-unprod59.3%
sqr-neg59.3%
sqrt-prod47.5%
add-sqr-sqrt97.6%
hypot-undefine79.7%
+-commutative79.7%
hypot-define97.6%
Applied egg-rr97.6%
Final simplification97.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ a (- d))))
(t_1 (/ 1.0 (hypot c d)))
(t_2 (+ (* c c) (* d d)))
(t_3 (* a (/ d c))))
(if (<= c -2.12e+133)
(* t_1 (- t_3 b))
(if (<= c -1.7e-130)
(/ (+ (* c b) (fma a (- d) (fma a (- d) (* d a)))) t_2)
(if (<= c 3e-29)
t_0
(if (<= c 1.75e+44)
(/ (fma (- d) a (* c b)) t_2)
(if (<= c 1.55e+88) t_0 (* t_1 (- b t_3)))))))))
double code(double a, double b, double c, double d) {
double t_0 = fma((c / hypot(c, d)), (b / hypot(c, d)), (a / -d));
double t_1 = 1.0 / hypot(c, d);
double t_2 = (c * c) + (d * d);
double t_3 = a * (d / c);
double tmp;
if (c <= -2.12e+133) {
tmp = t_1 * (t_3 - b);
} else if (c <= -1.7e-130) {
tmp = ((c * b) + fma(a, -d, fma(a, -d, (d * a)))) / t_2;
} else if (c <= 3e-29) {
tmp = t_0;
} else if (c <= 1.75e+44) {
tmp = fma(-d, a, (c * b)) / t_2;
} else if (c <= 1.55e+88) {
tmp = t_0;
} else {
tmp = t_1 * (b - t_3);
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a / Float64(-d))) t_1 = Float64(1.0 / hypot(c, d)) t_2 = Float64(Float64(c * c) + Float64(d * d)) t_3 = Float64(a * Float64(d / c)) tmp = 0.0 if (c <= -2.12e+133) tmp = Float64(t_1 * Float64(t_3 - b)); elseif (c <= -1.7e-130) tmp = Float64(Float64(Float64(c * b) + fma(a, Float64(-d), fma(a, Float64(-d), Float64(d * a)))) / t_2); elseif (c <= 3e-29) tmp = t_0; elseif (c <= 1.75e+44) tmp = Float64(fma(Float64(-d), a, Float64(c * b)) / t_2); elseif (c <= 1.55e+88) tmp = t_0; else tmp = Float64(t_1 * Float64(b - t_3)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a / (-d)), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.12e+133], N[(t$95$1 * N[(t$95$3 - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.7e-130], N[(N[(N[(c * b), $MachinePrecision] + N[(a * (-d) + N[(a * (-d) + N[(d * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[c, 3e-29], t$95$0, If[LessEqual[c, 1.75e+44], N[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[c, 1.55e+88], t$95$0, N[(t$95$1 * N[(b - t$95$3), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a}{-d}\right)\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := c \cdot c + d \cdot d\\
t_3 := a \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -2.12 \cdot 10^{+133}:\\
\;\;\;\;t\_1 \cdot \left(t\_3 - b\right)\\
\mathbf{elif}\;c \leq -1.7 \cdot 10^{-130}:\\
\;\;\;\;\frac{c \cdot b + \mathsf{fma}\left(a, -d, \mathsf{fma}\left(a, -d, d \cdot a\right)\right)}{t\_2}\\
\mathbf{elif}\;c \leq 3 \cdot 10^{-29}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.75 \cdot 10^{+44}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{t\_2}\\
\mathbf{elif}\;c \leq 1.55 \cdot 10^{+88}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(b - t\_3\right)\\
\end{array}
\end{array}
if c < -2.12e133Initial program 30.2%
*-un-lft-identity30.2%
add-sqr-sqrt30.2%
times-frac30.3%
hypot-define30.3%
fma-neg30.3%
distribute-rgt-neg-in30.3%
hypot-define59.8%
Applied egg-rr59.8%
Taylor expanded in c around -inf 87.2%
+-commutative87.2%
neg-mul-187.2%
unsub-neg87.2%
associate-/l*92.7%
Simplified92.7%
if -2.12e133 < c < -1.70000000000000003e-130Initial program 90.6%
prod-diff90.6%
*-commutative90.6%
fma-define90.6%
associate-+l+90.6%
distribute-rgt-neg-in90.6%
fma-define90.7%
*-commutative90.7%
fma-undefine90.6%
distribute-lft-neg-in90.6%
*-commutative90.6%
distribute-rgt-neg-in90.6%
fma-define90.7%
Applied egg-rr90.7%
if -1.70000000000000003e-130 < c < 3.0000000000000003e-29 or 1.75e44 < c < 1.5500000000000001e88Initial program 65.9%
div-sub60.9%
*-commutative60.9%
add-sqr-sqrt60.9%
times-frac61.9%
fma-neg61.9%
hypot-define61.9%
hypot-define64.6%
associate-/l*70.3%
add-sqr-sqrt70.3%
pow270.3%
hypot-define70.3%
Applied egg-rr70.3%
Taylor expanded in d around inf 94.4%
if 3.0000000000000003e-29 < c < 1.75e44Initial program 89.5%
sub-neg89.5%
+-commutative89.5%
*-commutative89.5%
distribute-lft-neg-in89.5%
fma-define89.5%
Applied egg-rr89.5%
if 1.5500000000000001e88 < c Initial program 37.7%
*-un-lft-identity37.7%
add-sqr-sqrt37.7%
times-frac37.8%
hypot-define37.8%
fma-neg37.8%
distribute-rgt-neg-in37.8%
hypot-define62.4%
Applied egg-rr62.4%
Taylor expanded in c around inf 79.9%
mul-1-neg79.9%
unsub-neg79.9%
associate-/l*87.8%
Simplified87.8%
Final simplification92.0%
(FPCore (a b c d) :precision binary64 (if (<= (/ (- (* c b) (* d a)) (+ (* c c) (* d d))) 2e+281) (* (/ 1.0 (hypot c d)) (/ (fma b c (* d (- a))) (hypot c d))) (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ a (- d)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((c * b) - (d * a)) / ((c * c) + (d * d))) <= 2e+281) {
tmp = (1.0 / hypot(c, d)) * (fma(b, c, (d * -a)) / hypot(c, d));
} else {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (a / -d));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) <= 2e+281) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(b, c, Float64(d * Float64(-a))) / hypot(c, d))); else tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a / Float64(-d))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+281], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(b * c + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a / (-d)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+281}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a}{-d}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.0000000000000001e281Initial program 78.0%
*-un-lft-identity78.0%
add-sqr-sqrt78.0%
times-frac78.1%
hypot-define78.1%
fma-neg78.1%
distribute-rgt-neg-in78.1%
hypot-define96.9%
Applied egg-rr96.9%
if 2.0000000000000001e281 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 15.0%
div-sub10.0%
*-commutative10.0%
add-sqr-sqrt10.0%
times-frac11.2%
fma-neg11.2%
hypot-define11.2%
hypot-define44.3%
associate-/l*54.0%
add-sqr-sqrt54.0%
pow254.0%
hypot-define54.0%
Applied egg-rr54.0%
Taylor expanded in d around inf 73.3%
Final simplification91.3%
(FPCore (a b c d)
:precision binary64
(if (<= c -9.2e+133)
(* (/ 1.0 (hypot c d)) (- (* a (/ d c)) b))
(if (<= c -3.2e-141)
(/ (+ (* c b) (fma a (- d) (fma a (- d) (* d a)))) (+ (* c c) (* d d)))
(if (<= c 6e-26)
(- (* b (/ c (pow d 2.0))) (/ a d))
(* (/ c (hypot d c)) (/ b (hypot d c)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -9.2e+133) {
tmp = (1.0 / hypot(c, d)) * ((a * (d / c)) - b);
} else if (c <= -3.2e-141) {
tmp = ((c * b) + fma(a, -d, fma(a, -d, (d * a)))) / ((c * c) + (d * d));
} else if (c <= 6e-26) {
tmp = (b * (c / pow(d, 2.0))) - (a / d);
} else {
tmp = (c / hypot(d, c)) * (b / hypot(d, c));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -9.2e+133) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(a * Float64(d / c)) - b)); elseif (c <= -3.2e-141) tmp = Float64(Float64(Float64(c * b) + fma(a, Float64(-d), fma(a, Float64(-d), Float64(d * a)))) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 6e-26) tmp = Float64(Float64(b * Float64(c / (d ^ 2.0))) - Float64(a / d)); else tmp = Float64(Float64(c / hypot(d, c)) * Float64(b / hypot(d, c))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -9.2e+133], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -3.2e-141], N[(N[(N[(c * b), $MachinePrecision] + N[(a * (-d) + N[(a * (-d) + N[(d * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6e-26], N[(N[(b * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -9.2 \cdot 10^{+133}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a \cdot \frac{d}{c} - b\right)\\
\mathbf{elif}\;c \leq -3.2 \cdot 10^{-141}:\\
\;\;\;\;\frac{c \cdot b + \mathsf{fma}\left(a, -d, \mathsf{fma}\left(a, -d, d \cdot a\right)\right)}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 6 \cdot 10^{-26}:\\
\;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}
\end{array}
if c < -9.1999999999999996e133Initial program 30.2%
*-un-lft-identity30.2%
add-sqr-sqrt30.2%
times-frac30.3%
hypot-define30.3%
fma-neg30.3%
distribute-rgt-neg-in30.3%
hypot-define59.8%
Applied egg-rr59.8%
Taylor expanded in c around -inf 87.2%
+-commutative87.2%
neg-mul-187.2%
unsub-neg87.2%
associate-/l*92.7%
Simplified92.7%
if -9.1999999999999996e133 < c < -3.2000000000000001e-141Initial program 90.6%
prod-diff90.6%
*-commutative90.6%
fma-define90.6%
associate-+l+90.6%
distribute-rgt-neg-in90.6%
fma-define90.7%
*-commutative90.7%
fma-undefine90.6%
distribute-lft-neg-in90.6%
*-commutative90.6%
distribute-rgt-neg-in90.6%
fma-define90.7%
Applied egg-rr90.7%
if -3.2000000000000001e-141 < c < 6.00000000000000023e-26Initial program 70.0%
div-sub64.4%
*-commutative64.4%
add-sqr-sqrt64.4%
times-frac65.4%
fma-neg65.4%
hypot-define65.4%
hypot-define65.5%
associate-/l*71.6%
add-sqr-sqrt71.6%
pow271.6%
hypot-define71.6%
Applied egg-rr71.6%
*-un-lft-identity71.6%
unpow271.6%
times-frac99.8%
add-sqr-sqrt49.7%
sqrt-prod51.7%
sqr-neg51.7%
sqrt-unprod19.1%
add-sqr-sqrt34.9%
hypot-undefine28.9%
+-commutative28.9%
hypot-define34.9%
add-sqr-sqrt19.1%
sqrt-unprod51.7%
sqr-neg51.7%
sqrt-prod49.7%
add-sqr-sqrt99.8%
hypot-undefine71.6%
+-commutative71.6%
hypot-define99.8%
Applied egg-rr99.8%
Taylor expanded in c around 0 87.0%
+-commutative87.0%
mul-1-neg87.0%
unsub-neg87.0%
associate-/l*87.4%
Simplified87.4%
if 6.00000000000000023e-26 < c Initial program 51.6%
Taylor expanded in b around inf 45.4%
*-commutative45.4%
Simplified45.4%
add-sqr-sqrt45.4%
hypot-undefine45.4%
hypot-undefine45.4%
frac-times74.2%
hypot-undefine47.6%
+-commutative47.6%
hypot-undefine74.2%
hypot-undefine47.6%
+-commutative47.6%
hypot-undefine74.2%
Applied egg-rr74.2%
Final simplification85.2%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.2e+133)
(* (/ 1.0 (hypot c d)) (- (* a (/ d c)) b))
(if (<= c -2e-134)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= c 3.8e-26)
(- (* b (/ c (pow d 2.0))) (/ a d))
(* (/ c (hypot d c)) (/ b (hypot d c)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.2e+133) {
tmp = (1.0 / hypot(c, d)) * ((a * (d / c)) - b);
} else if (c <= -2e-134) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 3.8e-26) {
tmp = (b * (c / pow(d, 2.0))) - (a / d);
} else {
tmp = (c / hypot(d, c)) * (b / hypot(d, c));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.2e+133) {
tmp = (1.0 / Math.hypot(c, d)) * ((a * (d / c)) - b);
} else if (c <= -2e-134) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 3.8e-26) {
tmp = (b * (c / Math.pow(d, 2.0))) - (a / d);
} else {
tmp = (c / Math.hypot(d, c)) * (b / Math.hypot(d, c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.2e+133: tmp = (1.0 / math.hypot(c, d)) * ((a * (d / c)) - b) elif c <= -2e-134: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif c <= 3.8e-26: tmp = (b * (c / math.pow(d, 2.0))) - (a / d) else: tmp = (c / math.hypot(d, c)) * (b / math.hypot(d, c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.2e+133) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(a * Float64(d / c)) - b)); elseif (c <= -2e-134) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 3.8e-26) tmp = Float64(Float64(b * Float64(c / (d ^ 2.0))) - Float64(a / d)); else tmp = Float64(Float64(c / hypot(d, c)) * Float64(b / hypot(d, c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.2e+133) tmp = (1.0 / hypot(c, d)) * ((a * (d / c)) - b); elseif (c <= -2e-134) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (c <= 3.8e-26) tmp = (b * (c / (d ^ 2.0))) - (a / d); else tmp = (c / hypot(d, c)) * (b / hypot(d, c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.2e+133], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2e-134], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.8e-26], N[(N[(b * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.2 \cdot 10^{+133}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a \cdot \frac{d}{c} - b\right)\\
\mathbf{elif}\;c \leq -2 \cdot 10^{-134}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 3.8 \cdot 10^{-26}:\\
\;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}
\end{array}
if c < -2.2e133Initial program 30.2%
*-un-lft-identity30.2%
add-sqr-sqrt30.2%
times-frac30.3%
hypot-define30.3%
fma-neg30.3%
distribute-rgt-neg-in30.3%
hypot-define59.8%
Applied egg-rr59.8%
Taylor expanded in c around -inf 87.2%
+-commutative87.2%
neg-mul-187.2%
unsub-neg87.2%
associate-/l*92.7%
Simplified92.7%
if -2.2e133 < c < -2.00000000000000008e-134Initial program 90.6%
if -2.00000000000000008e-134 < c < 3.80000000000000015e-26Initial program 70.0%
div-sub64.4%
*-commutative64.4%
add-sqr-sqrt64.4%
times-frac65.4%
fma-neg65.4%
hypot-define65.4%
hypot-define65.5%
associate-/l*71.6%
add-sqr-sqrt71.6%
pow271.6%
hypot-define71.6%
Applied egg-rr71.6%
*-un-lft-identity71.6%
unpow271.6%
times-frac99.8%
add-sqr-sqrt49.7%
sqrt-prod51.7%
sqr-neg51.7%
sqrt-unprod19.1%
add-sqr-sqrt34.9%
hypot-undefine28.9%
+-commutative28.9%
hypot-define34.9%
add-sqr-sqrt19.1%
sqrt-unprod51.7%
sqr-neg51.7%
sqrt-prod49.7%
add-sqr-sqrt99.8%
hypot-undefine71.6%
+-commutative71.6%
hypot-define99.8%
Applied egg-rr99.8%
Taylor expanded in c around 0 87.0%
+-commutative87.0%
mul-1-neg87.0%
unsub-neg87.0%
associate-/l*87.4%
Simplified87.4%
if 3.80000000000000015e-26 < c Initial program 51.6%
Taylor expanded in b around inf 45.4%
*-commutative45.4%
Simplified45.4%
add-sqr-sqrt45.4%
hypot-undefine45.4%
hypot-undefine45.4%
frac-times74.2%
hypot-undefine47.6%
+-commutative47.6%
hypot-undefine74.2%
hypot-undefine47.6%
+-commutative47.6%
hypot-undefine74.2%
Applied egg-rr74.2%
Final simplification85.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* a (/ d c)))
(t_1 (/ 1.0 (hypot c d)))
(t_2 (+ (* c c) (* d d))))
(if (<= c -2.12e+133)
(* t_1 (- t_0 b))
(if (<= c -1.4e-128)
(/ (- (* c b) (* d a)) t_2)
(if (<= c 2e-29)
(- (* b (/ c (pow d 2.0))) (/ a d))
(if (<= c 2.1e+86)
(/ (fma (- d) a (* c b)) t_2)
(* t_1 (- b t_0))))))))
double code(double a, double b, double c, double d) {
double t_0 = a * (d / c);
double t_1 = 1.0 / hypot(c, d);
double t_2 = (c * c) + (d * d);
double tmp;
if (c <= -2.12e+133) {
tmp = t_1 * (t_0 - b);
} else if (c <= -1.4e-128) {
tmp = ((c * b) - (d * a)) / t_2;
} else if (c <= 2e-29) {
tmp = (b * (c / pow(d, 2.0))) - (a / d);
} else if (c <= 2.1e+86) {
tmp = fma(-d, a, (c * b)) / t_2;
} else {
tmp = t_1 * (b - t_0);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(a * Float64(d / c)) t_1 = Float64(1.0 / hypot(c, d)) t_2 = Float64(Float64(c * c) + Float64(d * d)) tmp = 0.0 if (c <= -2.12e+133) tmp = Float64(t_1 * Float64(t_0 - b)); elseif (c <= -1.4e-128) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / t_2); elseif (c <= 2e-29) tmp = Float64(Float64(b * Float64(c / (d ^ 2.0))) - Float64(a / d)); elseif (c <= 2.1e+86) tmp = Float64(fma(Float64(-d), a, Float64(c * b)) / t_2); else tmp = Float64(t_1 * Float64(b - t_0)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.12e+133], N[(t$95$1 * N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.4e-128], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[c, 2e-29], N[(N[(b * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.1e+86], N[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], N[(t$95$1 * N[(b - t$95$0), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \frac{d}{c}\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := c \cdot c + d \cdot d\\
\mathbf{if}\;c \leq -2.12 \cdot 10^{+133}:\\
\;\;\;\;t\_1 \cdot \left(t\_0 - b\right)\\
\mathbf{elif}\;c \leq -1.4 \cdot 10^{-128}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{t\_2}\\
\mathbf{elif}\;c \leq 2 \cdot 10^{-29}:\\
\;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 2.1 \cdot 10^{+86}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(b - t\_0\right)\\
\end{array}
\end{array}
if c < -2.12e133Initial program 30.2%
*-un-lft-identity30.2%
add-sqr-sqrt30.2%
times-frac30.3%
hypot-define30.3%
fma-neg30.3%
distribute-rgt-neg-in30.3%
hypot-define59.8%
Applied egg-rr59.8%
Taylor expanded in c around -inf 87.2%
+-commutative87.2%
neg-mul-187.2%
unsub-neg87.2%
associate-/l*92.7%
Simplified92.7%
if -2.12e133 < c < -1.3999999999999999e-128Initial program 90.6%
if -1.3999999999999999e-128 < c < 1.99999999999999989e-29Initial program 69.7%
div-sub64.0%
*-commutative64.0%
add-sqr-sqrt64.0%
times-frac65.1%
fma-neg65.1%
hypot-define65.1%
hypot-define65.1%
associate-/l*71.4%
add-sqr-sqrt71.4%
pow271.4%
hypot-define71.4%
Applied egg-rr71.4%
*-un-lft-identity71.4%
unpow271.4%
times-frac99.8%
add-sqr-sqrt49.1%
sqrt-prod51.2%
sqr-neg51.2%
sqrt-unprod19.3%
add-sqr-sqrt35.2%
hypot-undefine29.2%
+-commutative29.2%
hypot-define35.2%
add-sqr-sqrt19.3%
sqrt-unprod51.2%
sqr-neg51.2%
sqrt-prod49.1%
add-sqr-sqrt99.8%
hypot-undefine71.3%
+-commutative71.3%
hypot-define99.8%
Applied egg-rr99.8%
Taylor expanded in c around 0 86.8%
+-commutative86.8%
mul-1-neg86.8%
unsub-neg86.8%
associate-/l*87.3%
Simplified87.3%
if 1.99999999999999989e-29 < c < 2.0999999999999999e86Initial program 73.2%
sub-neg73.2%
+-commutative73.2%
*-commutative73.2%
distribute-lft-neg-in73.2%
fma-define73.3%
Applied egg-rr73.3%
if 2.0999999999999999e86 < c Initial program 37.3%
*-un-lft-identity37.3%
add-sqr-sqrt37.3%
times-frac37.5%
hypot-define37.5%
fma-neg37.5%
distribute-rgt-neg-in37.5%
hypot-define60.4%
Applied egg-rr60.4%
Taylor expanded in c around inf 76.7%
mul-1-neg76.7%
unsub-neg76.7%
associate-/l*84.1%
Simplified84.1%
Final simplification86.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= c -2e+134)
(- (/ b c) (* a (* (/ d c) (/ 1.0 c))))
(if (<= c -9e-137)
t_0
(if (<= c 1.2e-28)
(- (* b (/ c (pow d 2.0))) (/ a d))
(if (<= c 7e+83) t_0 (* (/ 1.0 (hypot c d)) (- b (* a (/ d c))))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (c <= -2e+134) {
tmp = (b / c) - (a * ((d / c) * (1.0 / c)));
} else if (c <= -9e-137) {
tmp = t_0;
} else if (c <= 1.2e-28) {
tmp = (b * (c / pow(d, 2.0))) - (a / d);
} else if (c <= 7e+83) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * (b - (a * (d / c)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (c <= -2e+134) {
tmp = (b / c) - (a * ((d / c) * (1.0 / c)));
} else if (c <= -9e-137) {
tmp = t_0;
} else if (c <= 1.2e-28) {
tmp = (b * (c / Math.pow(d, 2.0))) - (a / d);
} else if (c <= 7e+83) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * (b - (a * (d / c)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if c <= -2e+134: tmp = (b / c) - (a * ((d / c) * (1.0 / c))) elif c <= -9e-137: tmp = t_0 elif c <= 1.2e-28: tmp = (b * (c / math.pow(d, 2.0))) - (a / d) elif c <= 7e+83: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * (b - (a * (d / c))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -2e+134) tmp = Float64(Float64(b / c) - Float64(a * Float64(Float64(d / c) * Float64(1.0 / c)))); elseif (c <= -9e-137) tmp = t_0; elseif (c <= 1.2e-28) tmp = Float64(Float64(b * Float64(c / (d ^ 2.0))) - Float64(a / d)); elseif (c <= 7e+83) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b - Float64(a * Float64(d / c)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -2e+134) tmp = (b / c) - (a * ((d / c) * (1.0 / c))); elseif (c <= -9e-137) tmp = t_0; elseif (c <= 1.2e-28) tmp = (b * (c / (d ^ 2.0))) - (a / d); elseif (c <= 7e+83) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * (b - (a * (d / c))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2e+134], N[(N[(b / c), $MachinePrecision] - N[(a * N[(N[(d / c), $MachinePrecision] * N[(1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -9e-137], t$95$0, If[LessEqual[c, 1.2e-28], N[(N[(b * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7e+83], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -2 \cdot 10^{+134}:\\
\;\;\;\;\frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\
\mathbf{elif}\;c \leq -9 \cdot 10^{-137}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{-28}:\\
\;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 7 \cdot 10^{+83}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - a \cdot \frac{d}{c}\right)\\
\end{array}
\end{array}
if c < -1.99999999999999984e134Initial program 30.2%
Taylor expanded in c around inf 74.5%
+-commutative74.5%
mul-1-neg74.5%
unsub-neg74.5%
associate-/l*77.3%
Simplified77.3%
*-un-lft-identity77.3%
unpow277.3%
times-frac83.3%
Applied egg-rr83.3%
if -1.99999999999999984e134 < c < -8.9999999999999994e-137 or 1.2000000000000001e-28 < c < 6.99999999999999954e83Initial program 84.2%
if -8.9999999999999994e-137 < c < 1.2000000000000001e-28Initial program 69.7%
div-sub64.0%
*-commutative64.0%
add-sqr-sqrt64.0%
times-frac65.1%
fma-neg65.1%
hypot-define65.1%
hypot-define65.1%
associate-/l*71.4%
add-sqr-sqrt71.4%
pow271.4%
hypot-define71.4%
Applied egg-rr71.4%
*-un-lft-identity71.4%
unpow271.4%
times-frac99.8%
add-sqr-sqrt49.1%
sqrt-prod51.2%
sqr-neg51.2%
sqrt-unprod19.3%
add-sqr-sqrt35.2%
hypot-undefine29.2%
+-commutative29.2%
hypot-define35.2%
add-sqr-sqrt19.3%
sqrt-unprod51.2%
sqr-neg51.2%
sqrt-prod49.1%
add-sqr-sqrt99.8%
hypot-undefine71.3%
+-commutative71.3%
hypot-define99.8%
Applied egg-rr99.8%
Taylor expanded in c around 0 86.8%
+-commutative86.8%
mul-1-neg86.8%
unsub-neg86.8%
associate-/l*87.3%
Simplified87.3%
if 6.99999999999999954e83 < c Initial program 37.3%
*-un-lft-identity37.3%
add-sqr-sqrt37.3%
times-frac37.5%
hypot-define37.5%
fma-neg37.5%
distribute-rgt-neg-in37.5%
hypot-define60.4%
Applied egg-rr60.4%
Taylor expanded in c around inf 76.7%
mul-1-neg76.7%
unsub-neg76.7%
associate-/l*84.1%
Simplified84.1%
Final simplification85.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (/ 1.0 (hypot c d)))
(t_2 (* a (/ d c))))
(if (<= c -4.9e+135)
(* t_1 (- t_2 b))
(if (<= c -1.7e-129)
t_0
(if (<= c 3.1e-29)
(- (* b (/ c (pow d 2.0))) (/ a d))
(if (<= c 2.5e+81) t_0 (* t_1 (- b t_2))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = 1.0 / hypot(c, d);
double t_2 = a * (d / c);
double tmp;
if (c <= -4.9e+135) {
tmp = t_1 * (t_2 - b);
} else if (c <= -1.7e-129) {
tmp = t_0;
} else if (c <= 3.1e-29) {
tmp = (b * (c / pow(d, 2.0))) - (a / d);
} else if (c <= 2.5e+81) {
tmp = t_0;
} else {
tmp = t_1 * (b - t_2);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = 1.0 / Math.hypot(c, d);
double t_2 = a * (d / c);
double tmp;
if (c <= -4.9e+135) {
tmp = t_1 * (t_2 - b);
} else if (c <= -1.7e-129) {
tmp = t_0;
} else if (c <= 3.1e-29) {
tmp = (b * (c / Math.pow(d, 2.0))) - (a / d);
} else if (c <= 2.5e+81) {
tmp = t_0;
} else {
tmp = t_1 * (b - t_2);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) t_1 = 1.0 / math.hypot(c, d) t_2 = a * (d / c) tmp = 0 if c <= -4.9e+135: tmp = t_1 * (t_2 - b) elif c <= -1.7e-129: tmp = t_0 elif c <= 3.1e-29: tmp = (b * (c / math.pow(d, 2.0))) - (a / d) elif c <= 2.5e+81: tmp = t_0 else: tmp = t_1 * (b - t_2) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(1.0 / hypot(c, d)) t_2 = Float64(a * Float64(d / c)) tmp = 0.0 if (c <= -4.9e+135) tmp = Float64(t_1 * Float64(t_2 - b)); elseif (c <= -1.7e-129) tmp = t_0; elseif (c <= 3.1e-29) tmp = Float64(Float64(b * Float64(c / (d ^ 2.0))) - Float64(a / d)); elseif (c <= 2.5e+81) tmp = t_0; else tmp = Float64(t_1 * Float64(b - t_2)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); t_1 = 1.0 / hypot(c, d); t_2 = a * (d / c); tmp = 0.0; if (c <= -4.9e+135) tmp = t_1 * (t_2 - b); elseif (c <= -1.7e-129) tmp = t_0; elseif (c <= 3.1e-29) tmp = (b * (c / (d ^ 2.0))) - (a / d); elseif (c <= 2.5e+81) tmp = t_0; else tmp = t_1 * (b - t_2); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -4.9e+135], N[(t$95$1 * N[(t$95$2 - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.7e-129], t$95$0, If[LessEqual[c, 3.1e-29], N[(N[(b * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.5e+81], t$95$0, N[(t$95$1 * N[(b - t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := a \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -4.9 \cdot 10^{+135}:\\
\;\;\;\;t\_1 \cdot \left(t\_2 - b\right)\\
\mathbf{elif}\;c \leq -1.7 \cdot 10^{-129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 3.1 \cdot 10^{-29}:\\
\;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 2.5 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(b - t\_2\right)\\
\end{array}
\end{array}
if c < -4.9000000000000001e135Initial program 30.2%
*-un-lft-identity30.2%
add-sqr-sqrt30.2%
times-frac30.3%
hypot-define30.3%
fma-neg30.3%
distribute-rgt-neg-in30.3%
hypot-define59.8%
Applied egg-rr59.8%
Taylor expanded in c around -inf 87.2%
+-commutative87.2%
neg-mul-187.2%
unsub-neg87.2%
associate-/l*92.7%
Simplified92.7%
if -4.9000000000000001e135 < c < -1.70000000000000007e-129 or 3.10000000000000026e-29 < c < 2.4999999999999999e81Initial program 84.2%
if -1.70000000000000007e-129 < c < 3.10000000000000026e-29Initial program 69.7%
div-sub64.0%
*-commutative64.0%
add-sqr-sqrt64.0%
times-frac65.1%
fma-neg65.1%
hypot-define65.1%
hypot-define65.1%
associate-/l*71.4%
add-sqr-sqrt71.4%
pow271.4%
hypot-define71.4%
Applied egg-rr71.4%
*-un-lft-identity71.4%
unpow271.4%
times-frac99.8%
add-sqr-sqrt49.1%
sqrt-prod51.2%
sqr-neg51.2%
sqrt-unprod19.3%
add-sqr-sqrt35.2%
hypot-undefine29.2%
+-commutative29.2%
hypot-define35.2%
add-sqr-sqrt19.3%
sqrt-unprod51.2%
sqr-neg51.2%
sqrt-prod49.1%
add-sqr-sqrt99.8%
hypot-undefine71.3%
+-commutative71.3%
hypot-define99.8%
Applied egg-rr99.8%
Taylor expanded in c around 0 86.8%
+-commutative86.8%
mul-1-neg86.8%
unsub-neg86.8%
associate-/l*87.3%
Simplified87.3%
if 2.4999999999999999e81 < c Initial program 37.3%
*-un-lft-identity37.3%
add-sqr-sqrt37.3%
times-frac37.5%
hypot-define37.5%
fma-neg37.5%
distribute-rgt-neg-in37.5%
hypot-define60.4%
Applied egg-rr60.4%
Taylor expanded in c around inf 76.7%
mul-1-neg76.7%
unsub-neg76.7%
associate-/l*84.1%
Simplified84.1%
Final simplification86.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (- (/ b c) (* a (* (/ d c) (/ 1.0 c))))))
(if (<= c -2.8e+135)
t_1
(if (<= c -1.12e-138)
t_0
(if (<= c 2.2e-29)
(- (* b (/ c (pow d 2.0))) (/ a d))
(if (<= c 1.12e+86) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = (b / c) - (a * ((d / c) * (1.0 / c)));
double tmp;
if (c <= -2.8e+135) {
tmp = t_1;
} else if (c <= -1.12e-138) {
tmp = t_0;
} else if (c <= 2.2e-29) {
tmp = (b * (c / pow(d, 2.0))) - (a / d);
} else if (c <= 1.12e+86) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
t_1 = (b / c) - (a * ((d / c) * (1.0d0 / c)))
if (c <= (-2.8d+135)) then
tmp = t_1
else if (c <= (-1.12d-138)) then
tmp = t_0
else if (c <= 2.2d-29) then
tmp = (b * (c / (d ** 2.0d0))) - (a / d)
else if (c <= 1.12d+86) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = (b / c) - (a * ((d / c) * (1.0 / c)));
double tmp;
if (c <= -2.8e+135) {
tmp = t_1;
} else if (c <= -1.12e-138) {
tmp = t_0;
} else if (c <= 2.2e-29) {
tmp = (b * (c / Math.pow(d, 2.0))) - (a / d);
} else if (c <= 1.12e+86) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) t_1 = (b / c) - (a * ((d / c) * (1.0 / c))) tmp = 0 if c <= -2.8e+135: tmp = t_1 elif c <= -1.12e-138: tmp = t_0 elif c <= 2.2e-29: tmp = (b * (c / math.pow(d, 2.0))) - (a / d) elif c <= 1.12e+86: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(b / c) - Float64(a * Float64(Float64(d / c) * Float64(1.0 / c)))) tmp = 0.0 if (c <= -2.8e+135) tmp = t_1; elseif (c <= -1.12e-138) tmp = t_0; elseif (c <= 2.2e-29) tmp = Float64(Float64(b * Float64(c / (d ^ 2.0))) - Float64(a / d)); elseif (c <= 1.12e+86) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); t_1 = (b / c) - (a * ((d / c) * (1.0 / c))); tmp = 0.0; if (c <= -2.8e+135) tmp = t_1; elseif (c <= -1.12e-138) tmp = t_0; elseif (c <= 2.2e-29) tmp = (b * (c / (d ^ 2.0))) - (a / d); elseif (c <= 1.12e+86) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(a * N[(N[(d / c), $MachinePrecision] * N[(1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.8e+135], t$95$1, If[LessEqual[c, -1.12e-138], t$95$0, If[LessEqual[c, 2.2e-29], N[(N[(b * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.12e+86], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\
\mathbf{if}\;c \leq -2.8 \cdot 10^{+135}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -1.12 \cdot 10^{-138}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2.2 \cdot 10^{-29}:\\
\;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 1.12 \cdot 10^{+86}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -2.80000000000000002e135 or 1.12e86 < c Initial program 33.9%
Taylor expanded in c around inf 72.2%
+-commutative72.2%
mul-1-neg72.2%
unsub-neg72.2%
associate-/l*76.2%
Simplified76.2%
*-un-lft-identity76.2%
unpow276.2%
times-frac82.6%
Applied egg-rr82.6%
if -2.80000000000000002e135 < c < -1.1199999999999999e-138 or 2.1999999999999999e-29 < c < 1.12e86Initial program 84.2%
if -1.1199999999999999e-138 < c < 2.1999999999999999e-29Initial program 69.7%
div-sub64.0%
*-commutative64.0%
add-sqr-sqrt64.0%
times-frac65.1%
fma-neg65.1%
hypot-define65.1%
hypot-define65.1%
associate-/l*71.4%
add-sqr-sqrt71.4%
pow271.4%
hypot-define71.4%
Applied egg-rr71.4%
*-un-lft-identity71.4%
unpow271.4%
times-frac99.8%
add-sqr-sqrt49.1%
sqrt-prod51.2%
sqr-neg51.2%
sqrt-unprod19.3%
add-sqr-sqrt35.2%
hypot-undefine29.2%
+-commutative29.2%
hypot-define35.2%
add-sqr-sqrt19.3%
sqrt-unprod51.2%
sqr-neg51.2%
sqrt-prod49.1%
add-sqr-sqrt99.8%
hypot-undefine71.3%
+-commutative71.3%
hypot-define99.8%
Applied egg-rr99.8%
Taylor expanded in c around 0 86.8%
+-commutative86.8%
mul-1-neg86.8%
unsub-neg86.8%
associate-/l*87.3%
Simplified87.3%
Final simplification84.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (- (/ b c) (* a (* (/ d c) (/ 1.0 c))))))
(if (<= c -1.3e+134)
t_1
(if (<= c -6.8e-140)
t_0
(if (<= c 2.8e-179) (/ a (- d)) (if (<= c 5.5e+79) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = (b / c) - (a * ((d / c) * (1.0 / c)));
double tmp;
if (c <= -1.3e+134) {
tmp = t_1;
} else if (c <= -6.8e-140) {
tmp = t_0;
} else if (c <= 2.8e-179) {
tmp = a / -d;
} else if (c <= 5.5e+79) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
t_1 = (b / c) - (a * ((d / c) * (1.0d0 / c)))
if (c <= (-1.3d+134)) then
tmp = t_1
else if (c <= (-6.8d-140)) then
tmp = t_0
else if (c <= 2.8d-179) then
tmp = a / -d
else if (c <= 5.5d+79) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = (b / c) - (a * ((d / c) * (1.0 / c)));
double tmp;
if (c <= -1.3e+134) {
tmp = t_1;
} else if (c <= -6.8e-140) {
tmp = t_0;
} else if (c <= 2.8e-179) {
tmp = a / -d;
} else if (c <= 5.5e+79) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) t_1 = (b / c) - (a * ((d / c) * (1.0 / c))) tmp = 0 if c <= -1.3e+134: tmp = t_1 elif c <= -6.8e-140: tmp = t_0 elif c <= 2.8e-179: tmp = a / -d elif c <= 5.5e+79: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(b / c) - Float64(a * Float64(Float64(d / c) * Float64(1.0 / c)))) tmp = 0.0 if (c <= -1.3e+134) tmp = t_1; elseif (c <= -6.8e-140) tmp = t_0; elseif (c <= 2.8e-179) tmp = Float64(a / Float64(-d)); elseif (c <= 5.5e+79) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); t_1 = (b / c) - (a * ((d / c) * (1.0 / c))); tmp = 0.0; if (c <= -1.3e+134) tmp = t_1; elseif (c <= -6.8e-140) tmp = t_0; elseif (c <= 2.8e-179) tmp = a / -d; elseif (c <= 5.5e+79) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(a * N[(N[(d / c), $MachinePrecision] * N[(1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.3e+134], t$95$1, If[LessEqual[c, -6.8e-140], t$95$0, If[LessEqual[c, 2.8e-179], N[(a / (-d)), $MachinePrecision], If[LessEqual[c, 5.5e+79], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\
\mathbf{if}\;c \leq -1.3 \cdot 10^{+134}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -6.8 \cdot 10^{-140}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2.8 \cdot 10^{-179}:\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{elif}\;c \leq 5.5 \cdot 10^{+79}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -1.3000000000000001e134 or 5.50000000000000007e79 < c Initial program 33.9%
Taylor expanded in c around inf 72.2%
+-commutative72.2%
mul-1-neg72.2%
unsub-neg72.2%
associate-/l*76.2%
Simplified76.2%
*-un-lft-identity76.2%
unpow276.2%
times-frac82.6%
Applied egg-rr82.6%
if -1.3000000000000001e134 < c < -6.80000000000000017e-140 or 2.8000000000000001e-179 < c < 5.50000000000000007e79Initial program 81.6%
if -6.80000000000000017e-140 < c < 2.8000000000000001e-179Initial program 66.8%
Taylor expanded in c around 0 83.7%
associate-*r/83.7%
neg-mul-183.7%
Simplified83.7%
Final simplification82.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (* c b) (+ (* c c) (* d d)))))
(if (<= c -2.45e+92)
(/ b c)
(if (<= c -2.3e-84)
t_0
(if (<= c 5e-26) (/ a (- d)) (if (<= c 5.2e+83) t_0 (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) / ((c * c) + (d * d));
double tmp;
if (c <= -2.45e+92) {
tmp = b / c;
} else if (c <= -2.3e-84) {
tmp = t_0;
} else if (c <= 5e-26) {
tmp = a / -d;
} else if (c <= 5.2e+83) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (c * b) / ((c * c) + (d * d))
if (c <= (-2.45d+92)) then
tmp = b / c
else if (c <= (-2.3d-84)) then
tmp = t_0
else if (c <= 5d-26) then
tmp = a / -d
else if (c <= 5.2d+83) then
tmp = t_0
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (c * b) / ((c * c) + (d * d));
double tmp;
if (c <= -2.45e+92) {
tmp = b / c;
} else if (c <= -2.3e-84) {
tmp = t_0;
} else if (c <= 5e-26) {
tmp = a / -d;
} else if (c <= 5.2e+83) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) / ((c * c) + (d * d)) tmp = 0 if c <= -2.45e+92: tmp = b / c elif c <= -2.3e-84: tmp = t_0 elif c <= 5e-26: tmp = a / -d elif c <= 5.2e+83: tmp = t_0 else: tmp = b / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -2.45e+92) tmp = Float64(b / c); elseif (c <= -2.3e-84) tmp = t_0; elseif (c <= 5e-26) tmp = Float64(a / Float64(-d)); elseif (c <= 5.2e+83) tmp = t_0; else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -2.45e+92) tmp = b / c; elseif (c <= -2.3e-84) tmp = t_0; elseif (c <= 5e-26) tmp = a / -d; elseif (c <= 5.2e+83) tmp = t_0; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.45e+92], N[(b / c), $MachinePrecision], If[LessEqual[c, -2.3e-84], t$95$0, If[LessEqual[c, 5e-26], N[(a / (-d)), $MachinePrecision], If[LessEqual[c, 5.2e+83], t$95$0, N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -2.45 \cdot 10^{+92}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -2.3 \cdot 10^{-84}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 5 \cdot 10^{-26}:\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{elif}\;c \leq 5.2 \cdot 10^{+83}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.4500000000000001e92 or 5.2000000000000002e83 < c Initial program 38.4%
Taylor expanded in c around inf 76.7%
if -2.4500000000000001e92 < c < -2.29999999999999981e-84 or 5.00000000000000019e-26 < c < 5.2000000000000002e83Initial program 81.1%
Taylor expanded in b around inf 61.5%
*-commutative61.5%
Simplified61.5%
if -2.29999999999999981e-84 < c < 5.00000000000000019e-26Initial program 72.1%
Taylor expanded in c around 0 76.4%
associate-*r/76.4%
neg-mul-176.4%
Simplified76.4%
Final simplification72.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (/ b c) (* a (* (/ d c) (/ 1.0 c))))))
(if (<= c -4.1e+89)
t_0
(if (<= c -8e-85)
(/ (* c b) (+ (* c c) (* d d)))
(if (<= c 4.2e-25) (/ a (- d)) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b / c) - (a * ((d / c) * (1.0 / c)));
double tmp;
if (c <= -4.1e+89) {
tmp = t_0;
} else if (c <= -8e-85) {
tmp = (c * b) / ((c * c) + (d * d));
} else if (c <= 4.2e-25) {
tmp = a / -d;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (b / c) - (a * ((d / c) * (1.0d0 / c)))
if (c <= (-4.1d+89)) then
tmp = t_0
else if (c <= (-8d-85)) then
tmp = (c * b) / ((c * c) + (d * d))
else if (c <= 4.2d-25) then
tmp = a / -d
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b / c) - (a * ((d / c) * (1.0 / c)));
double tmp;
if (c <= -4.1e+89) {
tmp = t_0;
} else if (c <= -8e-85) {
tmp = (c * b) / ((c * c) + (d * d));
} else if (c <= 4.2e-25) {
tmp = a / -d;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b / c) - (a * ((d / c) * (1.0 / c))) tmp = 0 if c <= -4.1e+89: tmp = t_0 elif c <= -8e-85: tmp = (c * b) / ((c * c) + (d * d)) elif c <= 4.2e-25: tmp = a / -d else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b / c) - Float64(a * Float64(Float64(d / c) * Float64(1.0 / c)))) tmp = 0.0 if (c <= -4.1e+89) tmp = t_0; elseif (c <= -8e-85) tmp = Float64(Float64(c * b) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 4.2e-25) tmp = Float64(a / Float64(-d)); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b / c) - (a * ((d / c) * (1.0 / c))); tmp = 0.0; if (c <= -4.1e+89) tmp = t_0; elseif (c <= -8e-85) tmp = (c * b) / ((c * c) + (d * d)); elseif (c <= 4.2e-25) tmp = a / -d; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / c), $MachinePrecision] - N[(a * N[(N[(d / c), $MachinePrecision] * N[(1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -4.1e+89], t$95$0, If[LessEqual[c, -8e-85], N[(N[(c * b), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.2e-25], N[(a / (-d)), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\
\mathbf{if}\;c \leq -4.1 \cdot 10^{+89}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -8 \cdot 10^{-85}:\\
\;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 4.2 \cdot 10^{-25}:\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4.09999999999999985e89 or 4.20000000000000005e-25 < c Initial program 47.3%
Taylor expanded in c around inf 68.6%
+-commutative68.6%
mul-1-neg68.6%
unsub-neg68.6%
associate-/l*70.5%
Simplified70.5%
*-un-lft-identity70.5%
unpow270.5%
times-frac74.9%
Applied egg-rr74.9%
if -4.09999999999999985e89 < c < -7.9999999999999998e-85Initial program 87.0%
Taylor expanded in b around inf 66.1%
*-commutative66.1%
Simplified66.1%
if -7.9999999999999998e-85 < c < 4.20000000000000005e-25Initial program 72.3%
Taylor expanded in c around 0 76.6%
associate-*r/76.6%
neg-mul-176.6%
Simplified76.6%
Final simplification74.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.02e+61) (not (<= d 6.8e-59))) (/ a (- d)) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.02e+61) || !(d <= 6.8e-59)) {
tmp = a / -d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-1.02d+61)) .or. (.not. (d <= 6.8d-59))) then
tmp = a / -d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.02e+61) || !(d <= 6.8e-59)) {
tmp = a / -d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.02e+61) or not (d <= 6.8e-59): tmp = a / -d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.02e+61) || !(d <= 6.8e-59)) tmp = Float64(a / Float64(-d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.02e+61) || ~((d <= 6.8e-59))) tmp = a / -d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.02e+61], N[Not[LessEqual[d, 6.8e-59]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.02 \cdot 10^{+61} \lor \neg \left(d \leq 6.8 \cdot 10^{-59}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.01999999999999999e61 or 6.80000000000000035e-59 < d Initial program 55.1%
Taylor expanded in c around 0 65.3%
associate-*r/65.3%
neg-mul-165.3%
Simplified65.3%
if -1.01999999999999999e61 < d < 6.80000000000000035e-59Initial program 71.6%
Taylor expanded in c around inf 70.5%
Final simplification67.8%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 63.0%
*-un-lft-identity63.0%
add-sqr-sqrt63.0%
times-frac63.1%
hypot-define63.1%
fma-neg63.1%
distribute-rgt-neg-in63.1%
hypot-define78.3%
Applied egg-rr78.3%
Taylor expanded in c around inf 28.9%
mul-1-neg28.9%
unsub-neg28.9%
associate-/l*30.1%
Simplified30.1%
Taylor expanded in d around -inf 9.1%
Final simplification9.1%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 63.0%
Taylor expanded in c around inf 44.4%
Final simplification44.4%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024043
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))