
(FPCore (a b c d) :precision binary64 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * 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 = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot c + b \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 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * 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 = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) INFINITY) (* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d))) (/ (/ b (hypot c d)) (/ (hypot c d) d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
} else {
tmp = (b / hypot(c, d)) / (hypot(c, d) / d);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d))); else tmp = Float64(Float64(b / hypot(c, d)) / Float64(hypot(c, d) / d)); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 80.8%
+-commutative80.8%
fma-undefine80.8%
clear-num80.8%
associate-/l*80.8%
add-sqr-sqrt80.8%
times-frac80.9%
fma-undefine80.9%
+-commutative80.9%
hypot-define80.9%
fma-define80.9%
fma-undefine80.9%
+-commutative80.9%
hypot-define94.1%
Applied egg-rr94.1%
if +inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
Taylor expanded in a around 0 1.3%
*-commutative1.3%
add-sqr-sqrt1.3%
hypot-undefine1.3%
hypot-undefine1.3%
times-frac66.7%
Applied egg-rr66.7%
*-commutative66.7%
clear-num66.7%
un-div-inv66.7%
Applied egg-rr66.7%
Final simplification88.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d))))
(if (<= d -7.2e-21)
(* (/ b (hypot c d)) (/ d (hypot c d)))
(if (<= d -1.05e-144)
(/ (fma c a (* b d)) t_0)
(if (<= d 3.8e-133)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 1.9e+74)
(/ (+ (* a c) (* b d)) t_0)
(/ 1.0 (/ (hypot c d) (fma a (/ c d) b)))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double tmp;
if (d <= -7.2e-21) {
tmp = (b / hypot(c, d)) * (d / hypot(c, d));
} else if (d <= -1.05e-144) {
tmp = fma(c, a, (b * d)) / t_0;
} else if (d <= 3.8e-133) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 1.9e+74) {
tmp = ((a * c) + (b * d)) / t_0;
} else {
tmp = 1.0 / (hypot(c, d) / fma(a, (c / d), b));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) tmp = 0.0 if (d <= -7.2e-21) tmp = Float64(Float64(b / hypot(c, d)) * Float64(d / hypot(c, d))); elseif (d <= -1.05e-144) tmp = Float64(fma(c, a, Float64(b * d)) / t_0); elseif (d <= 3.8e-133) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 1.9e+74) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / t_0); else tmp = Float64(1.0 / Float64(hypot(c, d) / fma(a, Float64(c / d), b))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.2e-21], N[(N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.05e-144], N[(N[(c * a + N[(b * d), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 3.8e-133], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.9e+74], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(1.0 / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / N[(a * N[(c / d), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
\mathbf{if}\;d \leq -7.2 \cdot 10^{-21}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1.05 \cdot 10^{-144}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, a, b \cdot d\right)}{t\_0}\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{-133}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{+74}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{hypot}\left(c, d\right)}{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}}\\
\end{array}
\end{array}
if d < -7.19999999999999979e-21Initial program 47.8%
Taylor expanded in a around 0 43.7%
*-commutative43.7%
add-sqr-sqrt43.7%
hypot-undefine43.7%
hypot-undefine43.7%
times-frac79.8%
Applied egg-rr79.8%
if -7.19999999999999979e-21 < d < -1.0500000000000001e-144Initial program 99.7%
*-commutative99.7%
fma-define99.7%
Applied egg-rr99.7%
if -1.0500000000000001e-144 < d < 3.8000000000000003e-133Initial program 73.8%
Taylor expanded in c around inf 83.7%
associate-/l*85.2%
associate-/r/83.8%
Simplified83.8%
pow283.8%
associate-*l/83.7%
associate-/r*88.3%
Applied egg-rr88.3%
if 3.8000000000000003e-133 < d < 1.8999999999999999e74Initial program 88.7%
if 1.8999999999999999e74 < d Initial program 44.4%
+-commutative44.4%
fma-undefine44.4%
clear-num44.4%
associate-/l*44.4%
add-sqr-sqrt44.4%
times-frac44.4%
fma-undefine44.4%
+-commutative44.4%
hypot-define44.4%
fma-define44.4%
fma-undefine44.4%
+-commutative44.4%
hypot-define59.5%
Applied egg-rr59.5%
Taylor expanded in d around -inf 28.3%
distribute-lft-out28.3%
associate-/l*28.4%
Simplified28.4%
associate-*l/28.4%
associate-/l*28.4%
add-sqr-sqrt10.1%
sqrt-unprod51.8%
mul-1-neg51.8%
mul-1-neg51.8%
sqr-neg51.8%
sqrt-unprod56.3%
add-sqr-sqrt94.4%
+-commutative94.4%
div-inv94.3%
clear-num94.3%
fma-define94.3%
Applied egg-rr94.3%
Final simplification88.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d))))
(if (<= d -7.2e-21)
(* (/ b (hypot c d)) (/ d (hypot c d)))
(if (<= d -7.6e-147)
(/ (fma c a (* b d)) t_0)
(if (<= d 2.05e-131)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 4.1e+63)
(/ (+ (* a c) (* b d)) t_0)
(* (/ 1.0 (hypot c d)) (+ b (* c (/ a d))))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double tmp;
if (d <= -7.2e-21) {
tmp = (b / hypot(c, d)) * (d / hypot(c, d));
} else if (d <= -7.6e-147) {
tmp = fma(c, a, (b * d)) / t_0;
} else if (d <= 2.05e-131) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 4.1e+63) {
tmp = ((a * c) + (b * d)) / t_0;
} else {
tmp = (1.0 / hypot(c, d)) * (b + (c * (a / d)));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) tmp = 0.0 if (d <= -7.2e-21) tmp = Float64(Float64(b / hypot(c, d)) * Float64(d / hypot(c, d))); elseif (d <= -7.6e-147) tmp = Float64(fma(c, a, Float64(b * d)) / t_0); elseif (d <= 2.05e-131) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 4.1e+63) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / t_0); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b + Float64(c * Float64(a / d)))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.2e-21], N[(N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.6e-147], N[(N[(c * a + N[(b * d), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 2.05e-131], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.1e+63], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
\mathbf{if}\;d \leq -7.2 \cdot 10^{-21}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -7.6 \cdot 10^{-147}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, a, b \cdot d\right)}{t\_0}\\
\mathbf{elif}\;d \leq 2.05 \cdot 10^{-131}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 4.1 \cdot 10^{+63}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + c \cdot \frac{a}{d}\right)\\
\end{array}
\end{array}
if d < -7.19999999999999979e-21Initial program 47.8%
Taylor expanded in a around 0 43.7%
*-commutative43.7%
add-sqr-sqrt43.7%
hypot-undefine43.7%
hypot-undefine43.7%
times-frac79.8%
Applied egg-rr79.8%
if -7.19999999999999979e-21 < d < -7.60000000000000055e-147Initial program 99.7%
*-commutative99.7%
fma-define99.7%
Applied egg-rr99.7%
if -7.60000000000000055e-147 < d < 2.0500000000000001e-131Initial program 73.8%
Taylor expanded in c around inf 83.7%
associate-/l*85.2%
associate-/r/83.8%
Simplified83.8%
pow283.8%
associate-*l/83.7%
associate-/r*88.3%
Applied egg-rr88.3%
if 2.0500000000000001e-131 < d < 4.09999999999999993e63Initial program 88.2%
if 4.09999999999999993e63 < d Initial program 46.5%
+-commutative46.5%
fma-undefine46.5%
clear-num46.4%
associate-/l*46.5%
add-sqr-sqrt46.5%
times-frac46.4%
fma-undefine46.4%
+-commutative46.4%
hypot-define46.4%
fma-define46.4%
fma-undefine46.4%
+-commutative46.4%
hypot-define60.9%
Applied egg-rr60.9%
Taylor expanded in c around 0 92.5%
associate-/l*94.4%
associate-/r/94.4%
Simplified94.4%
Final simplification88.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (+ b (* c (/ a d)))))
(if (<= d -3.7e+83)
(* t_1 (/ -1.0 (hypot c d)))
(if (<= d -2.3e-147)
t_0
(if (<= d 8.2e-134)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 7.5e+63) t_0 (* (/ 1.0 (hypot c d)) t_1)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = b + (c * (a / d));
double tmp;
if (d <= -3.7e+83) {
tmp = t_1 * (-1.0 / hypot(c, d));
} else if (d <= -2.3e-147) {
tmp = t_0;
} else if (d <= 8.2e-134) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 7.5e+63) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * t_1;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = b + (c * (a / d));
double tmp;
if (d <= -3.7e+83) {
tmp = t_1 * (-1.0 / Math.hypot(c, d));
} else if (d <= -2.3e-147) {
tmp = t_0;
} else if (d <= 8.2e-134) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 7.5e+63) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = b + (c * (a / d)) tmp = 0 if d <= -3.7e+83: tmp = t_1 * (-1.0 / math.hypot(c, d)) elif d <= -2.3e-147: tmp = t_0 elif d <= 8.2e-134: tmp = (a / c) + (((b * d) / c) / c) elif d <= 7.5e+63: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(b + Float64(c * Float64(a / d))) tmp = 0.0 if (d <= -3.7e+83) tmp = Float64(t_1 * Float64(-1.0 / hypot(c, d))); elseif (d <= -2.3e-147) tmp = t_0; elseif (d <= 8.2e-134) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 7.5e+63) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * t_1); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); t_1 = b + (c * (a / d)); tmp = 0.0; if (d <= -3.7e+83) tmp = t_1 * (-1.0 / hypot(c, d)); elseif (d <= -2.3e-147) tmp = t_0; elseif (d <= 8.2e-134) tmp = (a / c) + (((b * d) / c) / c); elseif (d <= 7.5e+63) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.7e+83], N[(t$95$1 * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.3e-147], t$95$0, If[LessEqual[d, 8.2e-134], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.5e+63], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
t_1 := b + c \cdot \frac{a}{d}\\
\mathbf{if}\;d \leq -3.7 \cdot 10^{+83}:\\
\;\;\;\;t\_1 \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -2.3 \cdot 10^{-147}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 8.2 \cdot 10^{-134}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+63}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot t\_1\\
\end{array}
\end{array}
if d < -3.7000000000000002e83Initial program 40.5%
+-commutative40.5%
fma-undefine40.5%
clear-num40.5%
associate-/l*40.5%
add-sqr-sqrt40.5%
times-frac40.6%
fma-undefine40.6%
+-commutative40.6%
hypot-define40.6%
fma-define40.6%
fma-undefine40.6%
+-commutative40.6%
hypot-define55.7%
Applied egg-rr55.7%
Taylor expanded in d around -inf 76.2%
mul-1-neg76.2%
unsub-neg76.2%
neg-mul-176.2%
associate-/l*82.9%
associate-/r/82.9%
Simplified82.9%
if -3.7000000000000002e83 < d < -2.2999999999999999e-147 or 8.2000000000000004e-134 < d < 7.5000000000000005e63Initial program 84.4%
if -2.2999999999999999e-147 < d < 8.2000000000000004e-134Initial program 73.8%
Taylor expanded in c around inf 83.7%
associate-/l*85.2%
associate-/r/83.8%
Simplified83.8%
pow283.8%
associate-*l/83.7%
associate-/r*88.3%
Applied egg-rr88.3%
if 7.5000000000000005e63 < d Initial program 46.5%
+-commutative46.5%
fma-undefine46.5%
clear-num46.4%
associate-/l*46.5%
add-sqr-sqrt46.5%
times-frac46.4%
fma-undefine46.4%
+-commutative46.4%
hypot-define46.4%
fma-define46.4%
fma-undefine46.4%
+-commutative46.4%
hypot-define60.9%
Applied egg-rr60.9%
Taylor expanded in c around 0 92.5%
associate-/l*94.4%
associate-/r/94.4%
Simplified94.4%
Final simplification87.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d))) (t_1 (+ b (* c (/ a d)))))
(if (<= d -8.4e+83)
(* t_1 (/ -1.0 (hypot c d)))
(if (<= d -1.06e-138)
(/ (fma c a (* b d)) t_0)
(if (<= d 3.4e-132)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 1.35e+64)
(/ (+ (* a c) (* b d)) t_0)
(* (/ 1.0 (hypot c d)) t_1)))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = b + (c * (a / d));
double tmp;
if (d <= -8.4e+83) {
tmp = t_1 * (-1.0 / hypot(c, d));
} else if (d <= -1.06e-138) {
tmp = fma(c, a, (b * d)) / t_0;
} else if (d <= 3.4e-132) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 1.35e+64) {
tmp = ((a * c) + (b * d)) / t_0;
} else {
tmp = (1.0 / hypot(c, d)) * t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) t_1 = Float64(b + Float64(c * Float64(a / d))) tmp = 0.0 if (d <= -8.4e+83) tmp = Float64(t_1 * Float64(-1.0 / hypot(c, d))); elseif (d <= -1.06e-138) tmp = Float64(fma(c, a, Float64(b * d)) / t_0); elseif (d <= 3.4e-132) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 1.35e+64) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / t_0); else tmp = Float64(Float64(1.0 / hypot(c, d)) * t_1); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -8.4e+83], N[(t$95$1 * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.06e-138], N[(N[(c * a + N[(b * d), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 3.4e-132], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.35e+64], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := b + c \cdot \frac{a}{d}\\
\mathbf{if}\;d \leq -8.4 \cdot 10^{+83}:\\
\;\;\;\;t\_1 \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1.06 \cdot 10^{-138}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, a, b \cdot d\right)}{t\_0}\\
\mathbf{elif}\;d \leq 3.4 \cdot 10^{-132}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 1.35 \cdot 10^{+64}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot t\_1\\
\end{array}
\end{array}
if d < -8.4000000000000001e83Initial program 40.5%
+-commutative40.5%
fma-undefine40.5%
clear-num40.5%
associate-/l*40.5%
add-sqr-sqrt40.5%
times-frac40.6%
fma-undefine40.6%
+-commutative40.6%
hypot-define40.6%
fma-define40.6%
fma-undefine40.6%
+-commutative40.6%
hypot-define55.7%
Applied egg-rr55.7%
Taylor expanded in d around -inf 76.2%
mul-1-neg76.2%
unsub-neg76.2%
neg-mul-176.2%
associate-/l*82.9%
associate-/r/82.9%
Simplified82.9%
if -8.4000000000000001e83 < d < -1.0599999999999999e-138Initial program 80.3%
*-commutative80.3%
fma-define80.3%
Applied egg-rr80.3%
if -1.0599999999999999e-138 < d < 3.39999999999999983e-132Initial program 73.8%
Taylor expanded in c around inf 83.7%
associate-/l*85.2%
associate-/r/83.8%
Simplified83.8%
pow283.8%
associate-*l/83.7%
associate-/r*88.3%
Applied egg-rr88.3%
if 3.39999999999999983e-132 < d < 1.35e64Initial program 88.2%
if 1.35e64 < d Initial program 46.5%
+-commutative46.5%
fma-undefine46.5%
clear-num46.4%
associate-/l*46.5%
add-sqr-sqrt46.5%
times-frac46.4%
fma-undefine46.4%
+-commutative46.4%
hypot-define46.4%
fma-define46.4%
fma-undefine46.4%
+-commutative46.4%
hypot-define60.9%
Applied egg-rr60.9%
Taylor expanded in c around 0 92.5%
associate-/l*94.4%
associate-/r/94.4%
Simplified94.4%
Final simplification87.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -1.85e+84)
(* b (/ -1.0 (hypot c d)))
(if (<= d -1.3e-138)
t_0
(if (<= d 1.72e-133)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 1.2e+63) t_0 (+ (/ b d) (* c (/ a (pow d 2.0))))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.85e+84) {
tmp = b * (-1.0 / hypot(c, d));
} else if (d <= -1.3e-138) {
tmp = t_0;
} else if (d <= 1.72e-133) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 1.2e+63) {
tmp = t_0;
} else {
tmp = (b / d) + (c * (a / pow(d, 2.0)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.85e+84) {
tmp = b * (-1.0 / Math.hypot(c, d));
} else if (d <= -1.3e-138) {
tmp = t_0;
} else if (d <= 1.72e-133) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 1.2e+63) {
tmp = t_0;
} else {
tmp = (b / d) + (c * (a / Math.pow(d, 2.0)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.85e+84: tmp = b * (-1.0 / math.hypot(c, d)) elif d <= -1.3e-138: tmp = t_0 elif d <= 1.72e-133: tmp = (a / c) + (((b * d) / c) / c) elif d <= 1.2e+63: tmp = t_0 else: tmp = (b / d) + (c * (a / math.pow(d, 2.0))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -1.85e+84) tmp = Float64(b * Float64(-1.0 / hypot(c, d))); elseif (d <= -1.3e-138) tmp = t_0; elseif (d <= 1.72e-133) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 1.2e+63) tmp = t_0; else tmp = Float64(Float64(b / d) + Float64(c * Float64(a / (d ^ 2.0)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.85e+84) tmp = b * (-1.0 / hypot(c, d)); elseif (d <= -1.3e-138) tmp = t_0; elseif (d <= 1.72e-133) tmp = (a / c) + (((b * d) / c) / c); elseif (d <= 1.2e+63) tmp = t_0; else tmp = (b / d) + (c * (a / (d ^ 2.0))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.85e+84], N[(b * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.3e-138], t$95$0, If[LessEqual[d, 1.72e-133], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.2e+63], t$95$0, N[(N[(b / d), $MachinePrecision] + N[(c * N[(a / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.85 \cdot 10^{+84}:\\
\;\;\;\;b \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1.3 \cdot 10^{-138}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.72 \cdot 10^{-133}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 1.2 \cdot 10^{+63}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{a}{{d}^{2}}\\
\end{array}
\end{array}
if d < -1.85e84Initial program 40.5%
+-commutative40.5%
fma-undefine40.5%
clear-num40.5%
associate-/l*40.5%
add-sqr-sqrt40.5%
times-frac40.6%
fma-undefine40.6%
+-commutative40.6%
hypot-define40.6%
fma-define40.6%
fma-undefine40.6%
+-commutative40.6%
hypot-define55.7%
Applied egg-rr55.7%
Taylor expanded in d around -inf 76.3%
neg-mul-176.3%
Simplified76.3%
if -1.85e84 < d < -1.3e-138 or 1.71999999999999995e-133 < d < 1.2e63Initial program 84.4%
if -1.3e-138 < d < 1.71999999999999995e-133Initial program 73.8%
Taylor expanded in c around inf 83.7%
associate-/l*85.2%
associate-/r/83.8%
Simplified83.8%
pow283.8%
associate-*l/83.7%
associate-/r*88.3%
Applied egg-rr88.3%
if 1.2e63 < d Initial program 46.5%
Taylor expanded in c around 0 84.4%
associate-/l*84.6%
associate-/r/84.6%
Simplified84.6%
Final simplification84.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -3.9e+83)
(* b (/ -1.0 (hypot c d)))
(if (<= d -5e-147)
t_0
(if (<= d 5.6e-134)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 4.7e+72) t_0 (/ (+ b (/ (* a c) d)) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -3.9e+83) {
tmp = b * (-1.0 / hypot(c, d));
} else if (d <= -5e-147) {
tmp = t_0;
} else if (d <= 5.6e-134) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 4.7e+72) {
tmp = t_0;
} else {
tmp = (b + ((a * c) / d)) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -3.9e+83) {
tmp = b * (-1.0 / Math.hypot(c, d));
} else if (d <= -5e-147) {
tmp = t_0;
} else if (d <= 5.6e-134) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 4.7e+72) {
tmp = t_0;
} else {
tmp = (b + ((a * c) / d)) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -3.9e+83: tmp = b * (-1.0 / math.hypot(c, d)) elif d <= -5e-147: tmp = t_0 elif d <= 5.6e-134: tmp = (a / c) + (((b * d) / c) / c) elif d <= 4.7e+72: tmp = t_0 else: tmp = (b + ((a * c) / d)) / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -3.9e+83) tmp = Float64(b * Float64(-1.0 / hypot(c, d))); elseif (d <= -5e-147) tmp = t_0; elseif (d <= 5.6e-134) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 4.7e+72) tmp = t_0; else tmp = Float64(Float64(b + Float64(Float64(a * c) / d)) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -3.9e+83) tmp = b * (-1.0 / hypot(c, d)); elseif (d <= -5e-147) tmp = t_0; elseif (d <= 5.6e-134) tmp = (a / c) + (((b * d) / c) / c); elseif (d <= 4.7e+72) tmp = t_0; else tmp = (b + ((a * c) / d)) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.9e+83], N[(b * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-147], t$95$0, If[LessEqual[d, 5.6e-134], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.7e+72], t$95$0, N[(N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -3.9 \cdot 10^{+83}:\\
\;\;\;\;b \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-147}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 5.6 \cdot 10^{-134}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 4.7 \cdot 10^{+72}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a \cdot c}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -3.9000000000000002e83Initial program 40.5%
+-commutative40.5%
fma-undefine40.5%
clear-num40.5%
associate-/l*40.5%
add-sqr-sqrt40.5%
times-frac40.6%
fma-undefine40.6%
+-commutative40.6%
hypot-define40.6%
fma-define40.6%
fma-undefine40.6%
+-commutative40.6%
hypot-define55.7%
Applied egg-rr55.7%
Taylor expanded in d around -inf 76.3%
neg-mul-176.3%
Simplified76.3%
if -3.9000000000000002e83 < d < -5.00000000000000013e-147 or 5.5999999999999997e-134 < d < 4.70000000000000034e72Initial program 84.8%
if -5.00000000000000013e-147 < d < 5.5999999999999997e-134Initial program 73.8%
Taylor expanded in c around inf 83.7%
associate-/l*85.2%
associate-/r/83.8%
Simplified83.8%
pow283.8%
associate-*l/83.7%
associate-/r*88.3%
Applied egg-rr88.3%
if 4.70000000000000034e72 < d Initial program 44.4%
+-commutative44.4%
fma-undefine44.4%
clear-num44.4%
associate-/l*44.4%
add-sqr-sqrt44.4%
times-frac44.4%
fma-undefine44.4%
+-commutative44.4%
hypot-define44.4%
fma-define44.4%
fma-undefine44.4%
+-commutative44.4%
hypot-define59.5%
Applied egg-rr59.5%
Taylor expanded in d around -inf 28.3%
mul-1-neg28.3%
unsub-neg28.3%
neg-mul-128.3%
associate-/l*28.4%
associate-/r/28.4%
Simplified28.4%
*-commutative28.4%
div-inv28.4%
cancel-sign-sub-inv28.4%
div-inv28.4%
distribute-lft-neg-in28.4%
add-sqr-sqrt14.3%
sqrt-unprod28.0%
sqr-neg28.0%
sqrt-unprod21.2%
add-sqr-sqrt40.3%
div-inv40.3%
add-sqr-sqrt13.6%
sqrt-unprod57.4%
sqr-neg57.4%
sqrt-unprod56.5%
add-sqr-sqrt94.6%
*-commutative94.6%
associate-*r/92.6%
Applied egg-rr92.6%
Final simplification85.9%
(FPCore (a b c d)
:precision binary64
(if (<= d -4.8e-84)
(/ (+ b (/ (* a c) d)) (- (hypot c d)))
(if (<= d 2.2e-133)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 2.7e+62)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(* (/ 1.0 (hypot c d)) (+ b (* c (/ a d))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.8e-84) {
tmp = (b + ((a * c) / d)) / -hypot(c, d);
} else if (d <= 2.2e-133) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 2.7e+62) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (1.0 / hypot(c, d)) * (b + (c * (a / d)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.8e-84) {
tmp = (b + ((a * c) / d)) / -Math.hypot(c, d);
} else if (d <= 2.2e-133) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 2.7e+62) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (1.0 / Math.hypot(c, d)) * (b + (c * (a / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -4.8e-84: tmp = (b + ((a * c) / d)) / -math.hypot(c, d) elif d <= 2.2e-133: tmp = (a / c) + (((b * d) / c) / c) elif d <= 2.7e+62: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = (1.0 / math.hypot(c, d)) * (b + (c * (a / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -4.8e-84) tmp = Float64(Float64(b + Float64(Float64(a * c) / d)) / Float64(-hypot(c, d))); elseif (d <= 2.2e-133) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 2.7e+62) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b + Float64(c * Float64(a / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -4.8e-84) tmp = (b + ((a * c) / d)) / -hypot(c, d); elseif (d <= 2.2e-133) tmp = (a / c) + (((b * d) / c) / c); elseif (d <= 2.7e+62) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = (1.0 / hypot(c, d)) * (b + (c * (a / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.8e-84], N[(N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, 2.2e-133], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.7e+62], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.8 \cdot 10^{-84}:\\
\;\;\;\;\frac{b + \frac{a \cdot c}{d}}{-\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq 2.2 \cdot 10^{-133}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{+62}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + c \cdot \frac{a}{d}\right)\\
\end{array}
\end{array}
if d < -4.80000000000000035e-84Initial program 53.3%
+-commutative53.3%
fma-undefine53.3%
clear-num53.3%
associate-/l*53.3%
add-sqr-sqrt53.3%
times-frac53.3%
fma-undefine53.3%
+-commutative53.3%
hypot-define53.3%
fma-define53.3%
fma-undefine53.3%
+-commutative53.3%
hypot-define67.5%
Applied egg-rr67.5%
Taylor expanded in d around -inf 72.5%
mul-1-neg72.5%
unsub-neg72.5%
neg-mul-172.5%
associate-/l*76.6%
associate-/r/74.2%
Simplified74.2%
associate-*l/74.4%
*-un-lft-identity74.4%
frac-2neg74.4%
Applied egg-rr72.8%
if -4.80000000000000035e-84 < d < 2.2000000000000001e-133Initial program 77.0%
Taylor expanded in c around inf 83.3%
associate-/l*84.6%
associate-/r/83.4%
Simplified83.4%
pow283.4%
associate-*l/83.3%
associate-/r*87.4%
Applied egg-rr87.4%
if 2.2000000000000001e-133 < d < 2.7e62Initial program 88.2%
if 2.7e62 < d Initial program 46.5%
+-commutative46.5%
fma-undefine46.5%
clear-num46.4%
associate-/l*46.5%
add-sqr-sqrt46.5%
times-frac46.4%
fma-undefine46.4%
+-commutative46.4%
hypot-define46.4%
fma-define46.4%
fma-undefine46.4%
+-commutative46.4%
hypot-define60.9%
Applied egg-rr60.9%
Taylor expanded in c around 0 92.5%
associate-/l*94.4%
associate-/r/94.4%
Simplified94.4%
Final simplification84.8%
(FPCore (a b c d)
:precision binary64
(if (<= d -5.9e-86)
(* (+ b (/ a (/ d c))) (/ -1.0 (hypot c d)))
(if (<= d 6e-132)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 9.5e+63)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(* (/ 1.0 (hypot c d)) (+ b (* c (/ a d))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.9e-86) {
tmp = (b + (a / (d / c))) * (-1.0 / hypot(c, d));
} else if (d <= 6e-132) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 9.5e+63) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (1.0 / hypot(c, d)) * (b + (c * (a / d)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.9e-86) {
tmp = (b + (a / (d / c))) * (-1.0 / Math.hypot(c, d));
} else if (d <= 6e-132) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 9.5e+63) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (1.0 / Math.hypot(c, d)) * (b + (c * (a / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -5.9e-86: tmp = (b + (a / (d / c))) * (-1.0 / math.hypot(c, d)) elif d <= 6e-132: tmp = (a / c) + (((b * d) / c) / c) elif d <= 9.5e+63: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = (1.0 / math.hypot(c, d)) * (b + (c * (a / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -5.9e-86) tmp = Float64(Float64(b + Float64(a / Float64(d / c))) * Float64(-1.0 / hypot(c, d))); elseif (d <= 6e-132) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 9.5e+63) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b + Float64(c * Float64(a / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -5.9e-86) tmp = (b + (a / (d / c))) * (-1.0 / hypot(c, d)); elseif (d <= 6e-132) tmp = (a / c) + (((b * d) / c) / c); elseif (d <= 9.5e+63) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = (1.0 / hypot(c, d)) * (b + (c * (a / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.9e-86], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6e-132], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.5e+63], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.9 \cdot 10^{-86}:\\
\;\;\;\;\left(b + \frac{a}{\frac{d}{c}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq 6 \cdot 10^{-132}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 9.5 \cdot 10^{+63}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + c \cdot \frac{a}{d}\right)\\
\end{array}
\end{array}
if d < -5.89999999999999998e-86Initial program 53.3%
+-commutative53.3%
fma-undefine53.3%
clear-num53.3%
associate-/l*53.3%
add-sqr-sqrt53.3%
times-frac53.3%
fma-undefine53.3%
+-commutative53.3%
hypot-define53.3%
fma-define53.3%
fma-undefine53.3%
+-commutative53.3%
hypot-define67.5%
Applied egg-rr67.5%
Taylor expanded in d around -inf 72.5%
distribute-lft-out72.5%
associate-/l*76.6%
Simplified76.6%
if -5.89999999999999998e-86 < d < 5.9999999999999999e-132Initial program 77.0%
Taylor expanded in c around inf 83.3%
associate-/l*84.6%
associate-/r/83.4%
Simplified83.4%
pow283.4%
associate-*l/83.3%
associate-/r*87.4%
Applied egg-rr87.4%
if 5.9999999999999999e-132 < d < 9.5000000000000003e63Initial program 88.2%
if 9.5000000000000003e63 < d Initial program 46.5%
+-commutative46.5%
fma-undefine46.5%
clear-num46.4%
associate-/l*46.5%
add-sqr-sqrt46.5%
times-frac46.4%
fma-undefine46.4%
+-commutative46.4%
hypot-define46.4%
fma-define46.4%
fma-undefine46.4%
+-commutative46.4%
hypot-define60.9%
Applied egg-rr60.9%
Taylor expanded in c around 0 92.5%
associate-/l*94.4%
associate-/r/94.4%
Simplified94.4%
Final simplification85.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ b (/ (* a c) d))))
(if (<= d -3.8e-84)
(/ t_0 (- (hypot c d)))
(if (<= d 5.6e-133)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 1.2e+69)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(/ t_0 (hypot c d)))))))
double code(double a, double b, double c, double d) {
double t_0 = b + ((a * c) / d);
double tmp;
if (d <= -3.8e-84) {
tmp = t_0 / -hypot(c, d);
} else if (d <= 5.6e-133) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 1.2e+69) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = t_0 / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = b + ((a * c) / d);
double tmp;
if (d <= -3.8e-84) {
tmp = t_0 / -Math.hypot(c, d);
} else if (d <= 5.6e-133) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 1.2e+69) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = t_0 / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = b + ((a * c) / d) tmp = 0 if d <= -3.8e-84: tmp = t_0 / -math.hypot(c, d) elif d <= 5.6e-133: tmp = (a / c) + (((b * d) / c) / c) elif d <= 1.2e+69: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = t_0 / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(b + Float64(Float64(a * c) / d)) tmp = 0.0 if (d <= -3.8e-84) tmp = Float64(t_0 / Float64(-hypot(c, d))); elseif (d <= 5.6e-133) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 1.2e+69) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(t_0 / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = b + ((a * c) / d); tmp = 0.0; if (d <= -3.8e-84) tmp = t_0 / -hypot(c, d); elseif (d <= 5.6e-133) tmp = (a / c) + (((b * d) / c) / c); elseif (d <= 1.2e+69) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = t_0 / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.8e-84], N[(t$95$0 / (-N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, 5.6e-133], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.2e+69], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b + \frac{a \cdot c}{d}\\
\mathbf{if}\;d \leq -3.8 \cdot 10^{-84}:\\
\;\;\;\;\frac{t\_0}{-\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq 5.6 \cdot 10^{-133}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 1.2 \cdot 10^{+69}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -3.79999999999999986e-84Initial program 53.3%
+-commutative53.3%
fma-undefine53.3%
clear-num53.3%
associate-/l*53.3%
add-sqr-sqrt53.3%
times-frac53.3%
fma-undefine53.3%
+-commutative53.3%
hypot-define53.3%
fma-define53.3%
fma-undefine53.3%
+-commutative53.3%
hypot-define67.5%
Applied egg-rr67.5%
Taylor expanded in d around -inf 72.5%
mul-1-neg72.5%
unsub-neg72.5%
neg-mul-172.5%
associate-/l*76.6%
associate-/r/74.2%
Simplified74.2%
associate-*l/74.4%
*-un-lft-identity74.4%
frac-2neg74.4%
Applied egg-rr72.8%
if -3.79999999999999986e-84 < d < 5.5999999999999997e-133Initial program 77.0%
Taylor expanded in c around inf 83.3%
associate-/l*84.6%
associate-/r/83.4%
Simplified83.4%
pow283.4%
associate-*l/83.3%
associate-/r*87.4%
Applied egg-rr87.4%
if 5.5999999999999997e-133 < d < 1.2000000000000001e69Initial program 88.7%
if 1.2000000000000001e69 < d Initial program 44.4%
+-commutative44.4%
fma-undefine44.4%
clear-num44.4%
associate-/l*44.4%
add-sqr-sqrt44.4%
times-frac44.4%
fma-undefine44.4%
+-commutative44.4%
hypot-define44.4%
fma-define44.4%
fma-undefine44.4%
+-commutative44.4%
hypot-define59.5%
Applied egg-rr59.5%
Taylor expanded in d around -inf 28.3%
mul-1-neg28.3%
unsub-neg28.3%
neg-mul-128.3%
associate-/l*28.4%
associate-/r/28.4%
Simplified28.4%
*-commutative28.4%
div-inv28.4%
cancel-sign-sub-inv28.4%
div-inv28.4%
distribute-lft-neg-in28.4%
add-sqr-sqrt14.3%
sqrt-unprod28.0%
sqr-neg28.0%
sqrt-unprod21.2%
add-sqr-sqrt40.3%
div-inv40.3%
add-sqr-sqrt13.6%
sqrt-unprod57.4%
sqr-neg57.4%
sqrt-unprod56.5%
add-sqr-sqrt94.6%
*-commutative94.6%
associate-*r/92.6%
Applied egg-rr92.6%
Final simplification84.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -7.9e+83)
(* b (/ -1.0 (hypot c d)))
(if (<= d -1.7e-139)
t_0
(if (<= d 3.1e-133)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 9.8e+83) t_0 (/ b d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -7.9e+83) {
tmp = b * (-1.0 / hypot(c, d));
} else if (d <= -1.7e-139) {
tmp = t_0;
} else if (d <= 3.1e-133) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 9.8e+83) {
tmp = t_0;
} else {
tmp = b / d;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -7.9e+83) {
tmp = b * (-1.0 / Math.hypot(c, d));
} else if (d <= -1.7e-139) {
tmp = t_0;
} else if (d <= 3.1e-133) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 9.8e+83) {
tmp = t_0;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -7.9e+83: tmp = b * (-1.0 / math.hypot(c, d)) elif d <= -1.7e-139: tmp = t_0 elif d <= 3.1e-133: tmp = (a / c) + (((b * d) / c) / c) elif d <= 9.8e+83: tmp = t_0 else: tmp = b / d return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -7.9e+83) tmp = Float64(b * Float64(-1.0 / hypot(c, d))); elseif (d <= -1.7e-139) tmp = t_0; elseif (d <= 3.1e-133) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 9.8e+83) tmp = t_0; else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -7.9e+83) tmp = b * (-1.0 / hypot(c, d)); elseif (d <= -1.7e-139) tmp = t_0; elseif (d <= 3.1e-133) tmp = (a / c) + (((b * d) / c) / c); elseif (d <= 9.8e+83) tmp = t_0; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.9e+83], N[(b * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.7e-139], t$95$0, If[LessEqual[d, 3.1e-133], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.8e+83], t$95$0, N[(b / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -7.9 \cdot 10^{+83}:\\
\;\;\;\;b \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1.7 \cdot 10^{-139}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.1 \cdot 10^{-133}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 9.8 \cdot 10^{+83}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -7.89999999999999974e83Initial program 40.5%
+-commutative40.5%
fma-undefine40.5%
clear-num40.5%
associate-/l*40.5%
add-sqr-sqrt40.5%
times-frac40.6%
fma-undefine40.6%
+-commutative40.6%
hypot-define40.6%
fma-define40.6%
fma-undefine40.6%
+-commutative40.6%
hypot-define55.7%
Applied egg-rr55.7%
Taylor expanded in d around -inf 76.3%
neg-mul-176.3%
Simplified76.3%
if -7.89999999999999974e83 < d < -1.69999999999999999e-139 or 3.10000000000000016e-133 < d < 9.79999999999999957e83Initial program 85.1%
if -1.69999999999999999e-139 < d < 3.10000000000000016e-133Initial program 73.8%
Taylor expanded in c around inf 83.7%
associate-/l*85.2%
associate-/r/83.8%
Simplified83.8%
pow283.8%
associate-*l/83.7%
associate-/r*88.3%
Applied egg-rr88.3%
if 9.79999999999999957e83 < d Initial program 42.3%
Taylor expanded in c around 0 83.4%
Final simplification84.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -1.18e+83)
(/ b d)
(if (<= d -1.4e-146)
t_0
(if (<= d 1.45e-131)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 9.8e+83) t_0 (/ b d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.18e+83) {
tmp = b / d;
} else if (d <= -1.4e-146) {
tmp = t_0;
} else if (d <= 1.45e-131) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 9.8e+83) {
tmp = t_0;
} else {
tmp = b / 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) :: t_0
real(8) :: tmp
t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
if (d <= (-1.18d+83)) then
tmp = b / d
else if (d <= (-1.4d-146)) then
tmp = t_0
else if (d <= 1.45d-131) then
tmp = (a / c) + (((b * d) / c) / c)
else if (d <= 9.8d+83) then
tmp = t_0
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.18e+83) {
tmp = b / d;
} else if (d <= -1.4e-146) {
tmp = t_0;
} else if (d <= 1.45e-131) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 9.8e+83) {
tmp = t_0;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.18e+83: tmp = b / d elif d <= -1.4e-146: tmp = t_0 elif d <= 1.45e-131: tmp = (a / c) + (((b * d) / c) / c) elif d <= 9.8e+83: tmp = t_0 else: tmp = b / d return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -1.18e+83) tmp = Float64(b / d); elseif (d <= -1.4e-146) tmp = t_0; elseif (d <= 1.45e-131) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 9.8e+83) tmp = t_0; else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.18e+83) tmp = b / d; elseif (d <= -1.4e-146) tmp = t_0; elseif (d <= 1.45e-131) tmp = (a / c) + (((b * d) / c) / c); elseif (d <= 9.8e+83) tmp = t_0; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.18e+83], N[(b / d), $MachinePrecision], If[LessEqual[d, -1.4e-146], t$95$0, If[LessEqual[d, 1.45e-131], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.8e+83], t$95$0, N[(b / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.18 \cdot 10^{+83}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -1.4 \cdot 10^{-146}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.45 \cdot 10^{-131}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 9.8 \cdot 10^{+83}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -1.1799999999999999e83 or 9.79999999999999957e83 < d Initial program 42.1%
Taylor expanded in c around 0 79.8%
if -1.1799999999999999e83 < d < -1.40000000000000001e-146 or 1.4500000000000001e-131 < d < 9.79999999999999957e83Initial program 85.0%
if -1.40000000000000001e-146 < d < 1.4500000000000001e-131Initial program 73.8%
Taylor expanded in c around inf 83.7%
associate-/l*85.2%
associate-/r/83.8%
Simplified83.8%
pow283.8%
associate-*l/83.7%
associate-/r*88.3%
Applied egg-rr88.3%
Final simplification83.9%
(FPCore (a b c d)
:precision binary64
(if (or (<= d -3.8e+17)
(and (not (<= d 2.6e-66)) (or (<= d 8.5e-33) (not (<= d 1.8e+62)))))
(/ b d)
(+ (/ a c) (/ (/ (* b d) c) c))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.8e+17) || (!(d <= 2.6e-66) && ((d <= 8.5e-33) || !(d <= 1.8e+62)))) {
tmp = b / d;
} else {
tmp = (a / c) + (((b * d) / c) / 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 <= (-3.8d+17)) .or. (.not. (d <= 2.6d-66)) .and. (d <= 8.5d-33) .or. (.not. (d <= 1.8d+62))) then
tmp = b / d
else
tmp = (a / c) + (((b * d) / c) / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.8e+17) || (!(d <= 2.6e-66) && ((d <= 8.5e-33) || !(d <= 1.8e+62)))) {
tmp = b / d;
} else {
tmp = (a / c) + (((b * d) / c) / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3.8e+17) or (not (d <= 2.6e-66) and ((d <= 8.5e-33) or not (d <= 1.8e+62))): tmp = b / d else: tmp = (a / c) + (((b * d) / c) / c) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3.8e+17) || (!(d <= 2.6e-66) && ((d <= 8.5e-33) || !(d <= 1.8e+62)))) tmp = Float64(b / d); else tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -3.8e+17) || (~((d <= 2.6e-66)) && ((d <= 8.5e-33) || ~((d <= 1.8e+62))))) tmp = b / d; else tmp = (a / c) + (((b * d) / c) / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.8e+17], And[N[Not[LessEqual[d, 2.6e-66]], $MachinePrecision], Or[LessEqual[d, 8.5e-33], N[Not[LessEqual[d, 1.8e+62]], $MachinePrecision]]]], N[(b / d), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.8 \cdot 10^{+17} \lor \neg \left(d \leq 2.6 \cdot 10^{-66}\right) \land \left(d \leq 8.5 \cdot 10^{-33} \lor \neg \left(d \leq 1.8 \cdot 10^{+62}\right)\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\end{array}
\end{array}
if d < -3.8e17 or 2.5999999999999999e-66 < d < 8.49999999999999945e-33 or 1.8e62 < d Initial program 51.8%
Taylor expanded in c around 0 76.3%
if -3.8e17 < d < 2.5999999999999999e-66 or 8.49999999999999945e-33 < d < 1.8e62Initial program 78.1%
Taylor expanded in c around inf 70.1%
associate-/l*71.0%
associate-/r/70.2%
Simplified70.2%
pow270.2%
associate-*l/70.1%
associate-/r*74.9%
Applied egg-rr74.9%
Final simplification75.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (/ a c) (/ (/ (* b d) c) c))))
(if (<= d -4.4e+14)
(/ b d)
(if (<= d 1.5e-97)
t_0
(if (<= d 330000000.0)
(/ (* b d) (+ (* c c) (* d d)))
(if (<= d 1.85e+62) t_0 (/ b d)))))))
double code(double a, double b, double c, double d) {
double t_0 = (a / c) + (((b * d) / c) / c);
double tmp;
if (d <= -4.4e+14) {
tmp = b / d;
} else if (d <= 1.5e-97) {
tmp = t_0;
} else if (d <= 330000000.0) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 1.85e+62) {
tmp = t_0;
} else {
tmp = b / 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) :: t_0
real(8) :: tmp
t_0 = (a / c) + (((b * d) / c) / c)
if (d <= (-4.4d+14)) then
tmp = b / d
else if (d <= 1.5d-97) then
tmp = t_0
else if (d <= 330000000.0d0) then
tmp = (b * d) / ((c * c) + (d * d))
else if (d <= 1.85d+62) then
tmp = t_0
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (a / c) + (((b * d) / c) / c);
double tmp;
if (d <= -4.4e+14) {
tmp = b / d;
} else if (d <= 1.5e-97) {
tmp = t_0;
} else if (d <= 330000000.0) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 1.85e+62) {
tmp = t_0;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = (a / c) + (((b * d) / c) / c) tmp = 0 if d <= -4.4e+14: tmp = b / d elif d <= 1.5e-97: tmp = t_0 elif d <= 330000000.0: tmp = (b * d) / ((c * c) + (d * d)) elif d <= 1.85e+62: tmp = t_0 else: tmp = b / d return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)) tmp = 0.0 if (d <= -4.4e+14) tmp = Float64(b / d); elseif (d <= 1.5e-97) tmp = t_0; elseif (d <= 330000000.0) tmp = Float64(Float64(b * d) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 1.85e+62) tmp = t_0; else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a / c) + (((b * d) / c) / c); tmp = 0.0; if (d <= -4.4e+14) tmp = b / d; elseif (d <= 1.5e-97) tmp = t_0; elseif (d <= 330000000.0) tmp = (b * d) / ((c * c) + (d * d)); elseif (d <= 1.85e+62) tmp = t_0; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.4e+14], N[(b / d), $MachinePrecision], If[LessEqual[d, 1.5e-97], t$95$0, If[LessEqual[d, 330000000.0], N[(N[(b * d), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.85e+62], t$95$0, N[(b / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{if}\;d \leq -4.4 \cdot 10^{+14}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 1.5 \cdot 10^{-97}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 330000000:\\
\;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 1.85 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -4.4e14 or 1.85000000000000007e62 < d Initial program 47.2%
Taylor expanded in c around 0 76.5%
if -4.4e14 < d < 1.50000000000000012e-97 or 3.3e8 < d < 1.85000000000000007e62Initial program 75.6%
Taylor expanded in c around inf 73.6%
associate-/l*74.6%
associate-/r/73.8%
Simplified73.8%
pow273.8%
associate-*l/73.6%
associate-/r*79.2%
Applied egg-rr79.2%
if 1.50000000000000012e-97 < d < 3.3e8Initial program 96.0%
Taylor expanded in a around 0 66.7%
Final simplification76.6%
(FPCore (a b c d)
:precision binary64
(if (or (<= d -7.2e-94)
(and (not (<= d 2.35e-66))
(or (<= d 330000000.0) (not (<= d 7.2e+62)))))
(/ b d)
(/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.2e-94) || (!(d <= 2.35e-66) && ((d <= 330000000.0) || !(d <= 7.2e+62)))) {
tmp = b / d;
} else {
tmp = a / 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 <= (-7.2d-94)) .or. (.not. (d <= 2.35d-66)) .and. (d <= 330000000.0d0) .or. (.not. (d <= 7.2d+62))) then
tmp = b / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.2e-94) || (!(d <= 2.35e-66) && ((d <= 330000000.0) || !(d <= 7.2e+62)))) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -7.2e-94) or (not (d <= 2.35e-66) and ((d <= 330000000.0) or not (d <= 7.2e+62))): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -7.2e-94) || (!(d <= 2.35e-66) && ((d <= 330000000.0) || !(d <= 7.2e+62)))) tmp = Float64(b / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -7.2e-94) || (~((d <= 2.35e-66)) && ((d <= 330000000.0) || ~((d <= 7.2e+62))))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7.2e-94], And[N[Not[LessEqual[d, 2.35e-66]], $MachinePrecision], Or[LessEqual[d, 330000000.0], N[Not[LessEqual[d, 7.2e+62]], $MachinePrecision]]]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.2 \cdot 10^{-94} \lor \neg \left(d \leq 2.35 \cdot 10^{-66}\right) \land \left(d \leq 330000000 \lor \neg \left(d \leq 7.2 \cdot 10^{+62}\right)\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -7.2e-94 or 2.35e-66 < d < 3.3e8 or 7.2e62 < d Initial program 57.4%
Taylor expanded in c around 0 69.0%
if -7.2e-94 < d < 2.35e-66 or 3.3e8 < d < 7.2e62Initial program 77.4%
Taylor expanded in c around inf 75.3%
Final simplification71.5%
(FPCore (a b c d) :precision binary64 (if (<= d 4e+84) (/ a c) (/ a d)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= 4e+84) {
tmp = a / c;
} else {
tmp = a / 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 (d <= 4d+84) then
tmp = a / c
else
tmp = a / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= 4e+84) {
tmp = a / c;
} else {
tmp = a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= 4e+84: tmp = a / c else: tmp = a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= 4e+84) tmp = Float64(a / c); else tmp = Float64(a / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= 4e+84) tmp = a / c; else tmp = a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, 4e+84], N[(a / c), $MachinePrecision], N[(a / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq 4 \cdot 10^{+84}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\end{array}
if d < 4.00000000000000023e84Initial program 70.8%
Taylor expanded in c around inf 47.3%
if 4.00000000000000023e84 < d Initial program 43.2%
+-commutative43.2%
fma-undefine43.2%
clear-num43.1%
associate-/l*43.2%
add-sqr-sqrt43.2%
times-frac43.1%
fma-undefine43.1%
+-commutative43.1%
hypot-define43.1%
fma-define43.1%
fma-undefine43.1%
+-commutative43.1%
hypot-define59.1%
Applied egg-rr59.1%
Taylor expanded in c around inf 20.2%
Taylor expanded in c around 0 18.4%
Final simplification41.6%
(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 65.4%
Taylor expanded in c around inf 39.9%
Final simplification39.9%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (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 = (a + (b * (d / c))) / (c + (d * (d / c)))
else
tmp = (b + (a * (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 = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (a + (b * (d / c))) / (c + (d * (d / c))) else: tmp = (b + (a * (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(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(b + Float64(a * 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 = (a + (b * (d / c))) / (c + (d * (d / c))); else tmp = (b + (a * (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[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * 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{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024036
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))