
(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 15 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
(let* ((t_0 (/ (fma a c (* b d)) (hypot c d))))
(if (<= c -2.1e+34)
(/ (- (- a) (/ b (/ c d))) (hypot c d))
(if (<= c -5e-77)
(* (/ 1.0 (hypot c d)) t_0)
(if (<= c 9e-294)
(+ (/ b d) (/ a (* d (* d (/ 1.0 c)))))
(if (<= c 1.75e+65)
(/ t_0 (hypot c d))
(* (pow (sqrt (/ c (hypot c d))) 2.0) (/ a (hypot c d)))))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(a, c, (b * d)) / hypot(c, d);
double tmp;
if (c <= -2.1e+34) {
tmp = (-a - (b / (c / d))) / hypot(c, d);
} else if (c <= -5e-77) {
tmp = (1.0 / hypot(c, d)) * t_0;
} else if (c <= 9e-294) {
tmp = (b / d) + (a / (d * (d * (1.0 / c))));
} else if (c <= 1.75e+65) {
tmp = t_0 / hypot(c, d);
} else {
tmp = pow(sqrt((c / hypot(c, d))), 2.0) * (a / hypot(c, d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(a, c, Float64(b * d)) / hypot(c, d)) tmp = 0.0 if (c <= -2.1e+34) tmp = Float64(Float64(Float64(-a) - Float64(b / Float64(c / d))) / hypot(c, d)); elseif (c <= -5e-77) tmp = Float64(Float64(1.0 / hypot(c, d)) * t_0); elseif (c <= 9e-294) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d * Float64(1.0 / c))))); elseif (c <= 1.75e+65) tmp = Float64(t_0 / hypot(c, d)); else tmp = Float64((sqrt(Float64(c / hypot(c, d))) ^ 2.0) * Float64(a / hypot(c, d))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.1e+34], N[(N[((-a) - N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -5e-77], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[c, 9e-294], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d * N[(1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.75e+65], N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Sqrt[N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\
\;\;\;\;\frac{\left(-a\right) - \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -5 \cdot 10^{-77}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot t_0\\
\mathbf{elif}\;c \leq 9 \cdot 10^{-294}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \left(d \cdot \frac{1}{c}\right)}\\
\mathbf{elif}\;c \leq 1.75 \cdot 10^{+65}:\\
\;\;\;\;\frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\frac{c}{\mathsf{hypot}\left(c, d\right)}}\right)}^{2} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -2.10000000000000017e34Initial program 44.0%
*-un-lft-identity44.0%
add-sqr-sqrt44.0%
times-frac44.0%
hypot-def44.0%
fma-def44.0%
hypot-def60.2%
Applied egg-rr60.2%
associate-*l/60.3%
*-un-lft-identity60.3%
Applied egg-rr60.3%
Taylor expanded in c around -inf 76.1%
neg-mul-176.1%
+-commutative76.1%
unsub-neg76.1%
mul-1-neg76.1%
associate-/l*81.5%
distribute-neg-frac81.5%
Simplified81.5%
if -2.10000000000000017e34 < c < -4.99999999999999963e-77Initial program 84.6%
*-un-lft-identity84.6%
add-sqr-sqrt84.6%
times-frac84.9%
hypot-def84.9%
fma-def84.9%
hypot-def92.5%
Applied egg-rr92.5%
if -4.99999999999999963e-77 < c < 8.99999999999999963e-294Initial program 61.8%
Taylor expanded in c around 0 87.4%
associate-/l*88.5%
Simplified88.5%
pow288.5%
div-inv88.5%
associate-*l*96.7%
Applied egg-rr96.7%
if 8.99999999999999963e-294 < c < 1.75e65Initial program 76.8%
*-un-lft-identity76.8%
add-sqr-sqrt76.8%
times-frac76.7%
hypot-def76.7%
fma-def76.7%
hypot-def93.1%
Applied egg-rr93.1%
associate-*l/93.3%
*-un-lft-identity93.3%
Applied egg-rr93.3%
if 1.75e65 < c Initial program 43.3%
Taylor expanded in a around inf 43.3%
*-commutative43.3%
Simplified43.3%
add-sqr-sqrt43.3%
hypot-udef43.3%
hypot-udef43.3%
times-frac89.5%
Applied egg-rr89.5%
add-sqr-sqrt89.5%
pow289.5%
Applied egg-rr89.5%
Final simplification90.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (/ (fma a c (* b d)) (hypot c d)) (hypot c d))))
(if (<= c -2.1e+34)
(/ (- (- a) (/ b (/ c d))) (hypot c d))
(if (<= c -2.3e-74)
t_0
(if (<= c 2.6e-293)
(+ (/ b d) (/ a (* d (* d (/ 1.0 c)))))
(if (<= c 1.72e+59) t_0 (* (/ c (hypot c d)) (/ a (hypot c d)))))))))
double code(double a, double b, double c, double d) {
double t_0 = (fma(a, c, (b * d)) / hypot(c, d)) / hypot(c, d);
double tmp;
if (c <= -2.1e+34) {
tmp = (-a - (b / (c / d))) / hypot(c, d);
} else if (c <= -2.3e-74) {
tmp = t_0;
} else if (c <= 2.6e-293) {
tmp = (b / d) + (a / (d * (d * (1.0 / c))));
} else if (c <= 1.72e+59) {
tmp = t_0;
} else {
tmp = (c / hypot(c, d)) * (a / hypot(c, d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(fma(a, c, Float64(b * d)) / hypot(c, d)) / hypot(c, d)) tmp = 0.0 if (c <= -2.1e+34) tmp = Float64(Float64(Float64(-a) - Float64(b / Float64(c / d))) / hypot(c, d)); elseif (c <= -2.3e-74) tmp = t_0; elseif (c <= 2.6e-293) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d * Float64(1.0 / c))))); elseif (c <= 1.72e+59) tmp = t_0; else tmp = Float64(Float64(c / hypot(c, d)) * Float64(a / hypot(c, d))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.1e+34], N[(N[((-a) - N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.3e-74], t$95$0, If[LessEqual[c, 2.6e-293], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d * N[(1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.72e+59], t$95$0, N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\
\;\;\;\;\frac{\left(-a\right) - \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -2.3 \cdot 10^{-74}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.6 \cdot 10^{-293}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \left(d \cdot \frac{1}{c}\right)}\\
\mathbf{elif}\;c \leq 1.72 \cdot 10^{+59}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -2.10000000000000017e34Initial program 44.0%
*-un-lft-identity44.0%
add-sqr-sqrt44.0%
times-frac44.0%
hypot-def44.0%
fma-def44.0%
hypot-def60.2%
Applied egg-rr60.2%
associate-*l/60.3%
*-un-lft-identity60.3%
Applied egg-rr60.3%
Taylor expanded in c around -inf 76.1%
neg-mul-176.1%
+-commutative76.1%
unsub-neg76.1%
mul-1-neg76.1%
associate-/l*81.5%
distribute-neg-frac81.5%
Simplified81.5%
if -2.10000000000000017e34 < c < -2.2999999999999998e-74 or 2.5999999999999998e-293 < c < 1.71999999999999996e59Initial program 78.8%
*-un-lft-identity78.8%
add-sqr-sqrt78.8%
times-frac78.8%
hypot-def78.8%
fma-def78.8%
hypot-def92.9%
Applied egg-rr92.9%
associate-*l/93.1%
*-un-lft-identity93.1%
Applied egg-rr93.1%
if -2.2999999999999998e-74 < c < 2.5999999999999998e-293Initial program 61.8%
Taylor expanded in c around 0 87.4%
associate-/l*88.5%
Simplified88.5%
pow288.5%
div-inv88.5%
associate-*l*96.7%
Applied egg-rr96.7%
if 1.71999999999999996e59 < c Initial program 43.3%
Taylor expanded in a around inf 43.3%
*-commutative43.3%
Simplified43.3%
add-sqr-sqrt43.3%
hypot-udef43.3%
hypot-udef43.3%
times-frac89.5%
Applied egg-rr89.5%
Final simplification90.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (fma a c (* b d)) (hypot c d))))
(if (<= c -2.1e+34)
(/ (- (- a) (/ b (/ c d))) (hypot c d))
(if (<= c -5.3e-76)
(* (/ 1.0 (hypot c d)) t_0)
(if (<= c 7.8e-293)
(+ (/ b d) (/ a (* d (* d (/ 1.0 c)))))
(if (<= c 3.25e+69)
(/ t_0 (hypot c d))
(* (/ c (hypot c d)) (/ a (hypot c d)))))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(a, c, (b * d)) / hypot(c, d);
double tmp;
if (c <= -2.1e+34) {
tmp = (-a - (b / (c / d))) / hypot(c, d);
} else if (c <= -5.3e-76) {
tmp = (1.0 / hypot(c, d)) * t_0;
} else if (c <= 7.8e-293) {
tmp = (b / d) + (a / (d * (d * (1.0 / c))));
} else if (c <= 3.25e+69) {
tmp = t_0 / hypot(c, d);
} else {
tmp = (c / hypot(c, d)) * (a / hypot(c, d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(a, c, Float64(b * d)) / hypot(c, d)) tmp = 0.0 if (c <= -2.1e+34) tmp = Float64(Float64(Float64(-a) - Float64(b / Float64(c / d))) / hypot(c, d)); elseif (c <= -5.3e-76) tmp = Float64(Float64(1.0 / hypot(c, d)) * t_0); elseif (c <= 7.8e-293) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d * Float64(1.0 / c))))); elseif (c <= 3.25e+69) tmp = Float64(t_0 / hypot(c, d)); else tmp = Float64(Float64(c / hypot(c, d)) * Float64(a / hypot(c, d))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.1e+34], N[(N[((-a) - N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -5.3e-76], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[c, 7.8e-293], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d * N[(1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.25e+69], N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\
\;\;\;\;\frac{\left(-a\right) - \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -5.3 \cdot 10^{-76}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot t_0\\
\mathbf{elif}\;c \leq 7.8 \cdot 10^{-293}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \left(d \cdot \frac{1}{c}\right)}\\
\mathbf{elif}\;c \leq 3.25 \cdot 10^{+69}:\\
\;\;\;\;\frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -2.10000000000000017e34Initial program 44.0%
*-un-lft-identity44.0%
add-sqr-sqrt44.0%
times-frac44.0%
hypot-def44.0%
fma-def44.0%
hypot-def60.2%
Applied egg-rr60.2%
associate-*l/60.3%
*-un-lft-identity60.3%
Applied egg-rr60.3%
Taylor expanded in c around -inf 76.1%
neg-mul-176.1%
+-commutative76.1%
unsub-neg76.1%
mul-1-neg76.1%
associate-/l*81.5%
distribute-neg-frac81.5%
Simplified81.5%
if -2.10000000000000017e34 < c < -5.3e-76Initial program 84.6%
*-un-lft-identity84.6%
add-sqr-sqrt84.6%
times-frac84.9%
hypot-def84.9%
fma-def84.9%
hypot-def92.5%
Applied egg-rr92.5%
if -5.3e-76 < c < 7.8e-293Initial program 61.8%
Taylor expanded in c around 0 87.4%
associate-/l*88.5%
Simplified88.5%
pow288.5%
div-inv88.5%
associate-*l*96.7%
Applied egg-rr96.7%
if 7.8e-293 < c < 3.25e69Initial program 76.8%
*-un-lft-identity76.8%
add-sqr-sqrt76.8%
times-frac76.7%
hypot-def76.7%
fma-def76.7%
hypot-def93.1%
Applied egg-rr93.1%
associate-*l/93.3%
*-un-lft-identity93.3%
Applied egg-rr93.3%
if 3.25e69 < c Initial program 43.3%
Taylor expanded in a around inf 43.3%
*-commutative43.3%
Simplified43.3%
add-sqr-sqrt43.3%
hypot-udef43.3%
hypot-udef43.3%
times-frac89.5%
Applied egg-rr89.5%
Final simplification90.4%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.1e+34)
(/ (- (- a) (/ b (/ c d))) (hypot c d))
(if (<= c -1.45e-74)
(/ (+ (* b d) (* c a)) (+ (* c c) (* d d)))
(if (<= c 5.2e+53)
(* (/ 1.0 d) (+ b (/ a (/ d c))))
(* (/ c (hypot c d)) (/ a (hypot c d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.1e+34) {
tmp = (-a - (b / (c / d))) / hypot(c, d);
} else if (c <= -1.45e-74) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 5.2e+53) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = (c / hypot(c, d)) * (a / hypot(c, d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.1e+34) {
tmp = (-a - (b / (c / d))) / Math.hypot(c, d);
} else if (c <= -1.45e-74) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 5.2e+53) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = (c / Math.hypot(c, d)) * (a / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.1e+34: tmp = (-a - (b / (c / d))) / math.hypot(c, d) elif c <= -1.45e-74: tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)) elif c <= 5.2e+53: tmp = (1.0 / d) * (b + (a / (d / c))) else: tmp = (c / math.hypot(c, d)) * (a / math.hypot(c, d)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.1e+34) tmp = Float64(Float64(Float64(-a) - Float64(b / Float64(c / d))) / hypot(c, d)); elseif (c <= -1.45e-74) tmp = Float64(Float64(Float64(b * d) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 5.2e+53) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); else tmp = Float64(Float64(c / hypot(c, d)) * Float64(a / hypot(c, d))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.1e+34) tmp = (-a - (b / (c / d))) / hypot(c, d); elseif (c <= -1.45e-74) tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)); elseif (c <= 5.2e+53) tmp = (1.0 / d) * (b + (a / (d / c))); else tmp = (c / hypot(c, d)) * (a / hypot(c, d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.1e+34], N[(N[((-a) - N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.45e-74], N[(N[(N[(b * d), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.2e+53], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\
\;\;\;\;\frac{\left(-a\right) - \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -1.45 \cdot 10^{-74}:\\
\;\;\;\;\frac{b \cdot d + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 5.2 \cdot 10^{+53}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -2.10000000000000017e34Initial program 44.0%
*-un-lft-identity44.0%
add-sqr-sqrt44.0%
times-frac44.0%
hypot-def44.0%
fma-def44.0%
hypot-def60.2%
Applied egg-rr60.2%
associate-*l/60.3%
*-un-lft-identity60.3%
Applied egg-rr60.3%
Taylor expanded in c around -inf 76.1%
neg-mul-176.1%
+-commutative76.1%
unsub-neg76.1%
mul-1-neg76.1%
associate-/l*81.5%
distribute-neg-frac81.5%
Simplified81.5%
if -2.10000000000000017e34 < c < -1.45e-74Initial program 84.6%
if -1.45e-74 < c < 5.19999999999999996e53Initial program 71.0%
*-un-lft-identity71.0%
add-sqr-sqrt71.0%
times-frac71.0%
hypot-def71.0%
fma-def71.0%
hypot-def85.1%
Applied egg-rr85.1%
Taylor expanded in c around 0 51.9%
associate-/l*51.9%
Simplified51.9%
Taylor expanded in c around 0 89.8%
if 5.19999999999999996e53 < c Initial program 43.3%
Taylor expanded in a around inf 43.3%
*-commutative43.3%
Simplified43.3%
add-sqr-sqrt43.3%
hypot-udef43.3%
hypot-udef43.3%
times-frac89.5%
Applied egg-rr89.5%
Final simplification87.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (/ a c) (/ b (/ (pow c 2.0) d)))))
(if (<= c -2.1e+34)
t_0
(if (<= c -1.45e-68)
(/ (+ (* b d) (* c a)) (+ (* c c) (* d d)))
(if (<= c 1e+108) (* (/ 1.0 d) (+ b (/ a (/ d c)))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (a / c) + (b / (pow(c, 2.0) / d));
double tmp;
if (c <= -2.1e+34) {
tmp = t_0;
} else if (c <= -1.45e-68) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 1e+108) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} 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 = (a / c) + (b / ((c ** 2.0d0) / d))
if (c <= (-2.1d+34)) then
tmp = t_0
else if (c <= (-1.45d-68)) then
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d))
else if (c <= 1d+108) then
tmp = (1.0d0 / d) * (b + (a / (d / c)))
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 = (a / c) + (b / (Math.pow(c, 2.0) / d));
double tmp;
if (c <= -2.1e+34) {
tmp = t_0;
} else if (c <= -1.45e-68) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 1e+108) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (a / c) + (b / (math.pow(c, 2.0) / d)) tmp = 0 if c <= -2.1e+34: tmp = t_0 elif c <= -1.45e-68: tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)) elif c <= 1e+108: tmp = (1.0 / d) * (b + (a / (d / c))) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a / c) + Float64(b / Float64((c ^ 2.0) / d))) tmp = 0.0 if (c <= -2.1e+34) tmp = t_0; elseif (c <= -1.45e-68) tmp = Float64(Float64(Float64(b * d) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 1e+108) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a / c) + (b / ((c ^ 2.0) / d)); tmp = 0.0; if (c <= -2.1e+34) tmp = t_0; elseif (c <= -1.45e-68) tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)); elseif (c <= 1e+108) tmp = (1.0 / d) * (b + (a / (d / c))); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a / c), $MachinePrecision] + N[(b / N[(N[Power[c, 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.1e+34], t$95$0, If[LessEqual[c, -1.45e-68], N[(N[(N[(b * d), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1e+108], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{c} + \frac{b}{\frac{{c}^{2}}{d}}\\
\mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq -1.45 \cdot 10^{-68}:\\
\;\;\;\;\frac{b \cdot d + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 10^{+108}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if c < -2.10000000000000017e34 or 1e108 < c Initial program 43.6%
Taylor expanded in c around inf 77.0%
associate-/l*80.2%
Simplified80.2%
if -2.10000000000000017e34 < c < -1.45e-68Initial program 84.6%
if -1.45e-68 < c < 1e108Initial program 69.6%
*-un-lft-identity69.6%
add-sqr-sqrt69.6%
times-frac69.5%
hypot-def69.5%
fma-def69.5%
hypot-def83.7%
Applied egg-rr83.7%
Taylor expanded in c around 0 49.9%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in c around 0 88.1%
Final simplification84.6%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.1e+34)
(+ (/ a c) (/ b (/ (pow c 2.0) d)))
(if (<= c -1.65e-68)
(/ (+ (* b d) (* c a)) (+ (* c c) (* d d)))
(if (<= c 8.2e+23)
(* (/ 1.0 d) (+ b (/ a (/ d c))))
(/ (+ a (* d (/ b c))) (hypot c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.1e+34) {
tmp = (a / c) + (b / (pow(c, 2.0) / d));
} else if (c <= -1.65e-68) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 8.2e+23) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = (a + (d * (b / c))) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.1e+34) {
tmp = (a / c) + (b / (Math.pow(c, 2.0) / d));
} else if (c <= -1.65e-68) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 8.2e+23) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = (a + (d * (b / c))) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.1e+34: tmp = (a / c) + (b / (math.pow(c, 2.0) / d)) elif c <= -1.65e-68: tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)) elif c <= 8.2e+23: tmp = (1.0 / d) * (b + (a / (d / c))) else: tmp = (a + (d * (b / c))) / math.hypot(c, d) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.1e+34) tmp = Float64(Float64(a / c) + Float64(b / Float64((c ^ 2.0) / d))); elseif (c <= -1.65e-68) tmp = Float64(Float64(Float64(b * d) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 8.2e+23) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); else tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.1e+34) tmp = (a / c) + (b / ((c ^ 2.0) / d)); elseif (c <= -1.65e-68) tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)); elseif (c <= 8.2e+23) tmp = (1.0 / d) * (b + (a / (d / c))); else tmp = (a + (d * (b / c))) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.1e+34], N[(N[(a / c), $MachinePrecision] + N[(b / N[(N[Power[c, 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.65e-68], N[(N[(N[(b * d), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 8.2e+23], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{\frac{{c}^{2}}{d}}\\
\mathbf{elif}\;c \leq -1.65 \cdot 10^{-68}:\\
\;\;\;\;\frac{b \cdot d + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 8.2 \cdot 10^{+23}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a + d \cdot \frac{b}{c}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -2.10000000000000017e34Initial program 44.0%
Taylor expanded in c around inf 70.6%
associate-/l*74.6%
Simplified74.6%
if -2.10000000000000017e34 < c < -1.6499999999999999e-68Initial program 84.6%
if -1.6499999999999999e-68 < c < 8.19999999999999992e23Initial program 71.1%
*-un-lft-identity71.1%
add-sqr-sqrt71.1%
times-frac71.1%
hypot-def71.1%
fma-def71.1%
hypot-def84.8%
Applied egg-rr84.8%
Taylor expanded in c around 0 52.3%
associate-/l*52.3%
Simplified52.3%
Taylor expanded in c around 0 91.2%
if 8.19999999999999992e23 < c Initial program 44.6%
*-un-lft-identity44.6%
add-sqr-sqrt44.6%
times-frac44.6%
hypot-def44.6%
fma-def44.6%
hypot-def64.2%
Applied egg-rr64.2%
associate-*l/64.3%
*-un-lft-identity64.3%
Applied egg-rr64.3%
Taylor expanded in c around inf 80.8%
associate-/l*84.3%
Simplified84.3%
associate-/r/85.9%
Applied egg-rr85.9%
Final simplification85.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -2e+34)
(/ (- (- a) (/ b (/ c d))) (hypot c d))
(if (<= c -1.3e-68)
(/ (+ (* b d) (* c a)) (+ (* c c) (* d d)))
(if (<= c 3.5e+19)
(* (/ 1.0 d) (+ b (/ a (/ d c))))
(/ (+ a (* d (/ b c))) (hypot c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2e+34) {
tmp = (-a - (b / (c / d))) / hypot(c, d);
} else if (c <= -1.3e-68) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 3.5e+19) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = (a + (d * (b / c))) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2e+34) {
tmp = (-a - (b / (c / d))) / Math.hypot(c, d);
} else if (c <= -1.3e-68) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 3.5e+19) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = (a + (d * (b / c))) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2e+34: tmp = (-a - (b / (c / d))) / math.hypot(c, d) elif c <= -1.3e-68: tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)) elif c <= 3.5e+19: tmp = (1.0 / d) * (b + (a / (d / c))) else: tmp = (a + (d * (b / c))) / math.hypot(c, d) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2e+34) tmp = Float64(Float64(Float64(-a) - Float64(b / Float64(c / d))) / hypot(c, d)); elseif (c <= -1.3e-68) tmp = Float64(Float64(Float64(b * d) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 3.5e+19) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); else tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2e+34) tmp = (-a - (b / (c / d))) / hypot(c, d); elseif (c <= -1.3e-68) tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)); elseif (c <= 3.5e+19) tmp = (1.0 / d) * (b + (a / (d / c))); else tmp = (a + (d * (b / c))) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2e+34], N[(N[((-a) - N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.3e-68], N[(N[(N[(b * d), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.5e+19], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2 \cdot 10^{+34}:\\
\;\;\;\;\frac{\left(-a\right) - \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -1.3 \cdot 10^{-68}:\\
\;\;\;\;\frac{b \cdot d + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 3.5 \cdot 10^{+19}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a + d \cdot \frac{b}{c}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -1.99999999999999989e34Initial program 44.0%
*-un-lft-identity44.0%
add-sqr-sqrt44.0%
times-frac44.0%
hypot-def44.0%
fma-def44.0%
hypot-def60.2%
Applied egg-rr60.2%
associate-*l/60.3%
*-un-lft-identity60.3%
Applied egg-rr60.3%
Taylor expanded in c around -inf 76.1%
neg-mul-176.1%
+-commutative76.1%
unsub-neg76.1%
mul-1-neg76.1%
associate-/l*81.5%
distribute-neg-frac81.5%
Simplified81.5%
if -1.99999999999999989e34 < c < -1.2999999999999999e-68Initial program 84.6%
if -1.2999999999999999e-68 < c < 3.5e19Initial program 71.1%
*-un-lft-identity71.1%
add-sqr-sqrt71.1%
times-frac71.1%
hypot-def71.1%
fma-def71.1%
hypot-def84.8%
Applied egg-rr84.8%
Taylor expanded in c around 0 52.3%
associate-/l*52.3%
Simplified52.3%
Taylor expanded in c around 0 91.2%
if 3.5e19 < c Initial program 44.6%
*-un-lft-identity44.6%
add-sqr-sqrt44.6%
times-frac44.6%
hypot-def44.6%
fma-def44.6%
hypot-def64.2%
Applied egg-rr64.2%
associate-*l/64.3%
*-un-lft-identity64.3%
Applied egg-rr64.3%
Taylor expanded in c around inf 80.8%
associate-/l*84.3%
Simplified84.3%
associate-/r/85.9%
Applied egg-rr85.9%
Final simplification87.2%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.75e+109)
(/ a c)
(if (<= c -5e-77)
(/ (+ (* b d) (* c a)) (+ (* c c) (* d d)))
(if (<= c 1.15e+106)
(* (/ 1.0 d) (+ b (/ a (/ d c))))
(/ a (hypot c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.75e+109) {
tmp = a / c;
} else if (c <= -5e-77) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 1.15e+106) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = a / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.75e+109) {
tmp = a / c;
} else if (c <= -5e-77) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 1.15e+106) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = a / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.75e+109: tmp = a / c elif c <= -5e-77: tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)) elif c <= 1.15e+106: tmp = (1.0 / d) * (b + (a / (d / c))) else: tmp = a / math.hypot(c, d) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.75e+109) tmp = Float64(a / c); elseif (c <= -5e-77) tmp = Float64(Float64(Float64(b * d) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 1.15e+106) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); else tmp = Float64(a / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.75e+109) tmp = a / c; elseif (c <= -5e-77) tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)); elseif (c <= 1.15e+106) tmp = (1.0 / d) * (b + (a / (d / c))); else tmp = a / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.75e+109], N[(a / c), $MachinePrecision], If[LessEqual[c, -5e-77], N[(N[(N[(b * d), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.15e+106], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.75 \cdot 10^{+109}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq -5 \cdot 10^{-77}:\\
\;\;\;\;\frac{b \cdot d + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.15 \cdot 10^{+106}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -1.74999999999999992e109Initial program 36.1%
Taylor expanded in c around inf 71.5%
if -1.74999999999999992e109 < c < -4.99999999999999963e-77Initial program 76.7%
if -4.99999999999999963e-77 < c < 1.1500000000000001e106Initial program 69.9%
*-un-lft-identity69.9%
add-sqr-sqrt69.9%
times-frac69.8%
hypot-def69.8%
fma-def69.8%
hypot-def84.2%
Applied egg-rr84.2%
Taylor expanded in c around 0 50.7%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in c around 0 88.7%
if 1.1500000000000001e106 < c Initial program 43.3%
*-un-lft-identity43.3%
add-sqr-sqrt43.3%
times-frac43.4%
hypot-def43.4%
fma-def43.4%
hypot-def62.3%
Applied egg-rr62.3%
associate-*l/62.4%
*-un-lft-identity62.4%
Applied egg-rr62.4%
Taylor expanded in c around inf 83.5%
Final simplification83.1%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.4e+110)
(* a (/ -1.0 (hypot c d)))
(if (<= c -1.2e-72)
(/ (+ (* b d) (* c a)) (+ (* c c) (* d d)))
(if (<= c 7.8e+105)
(* (/ 1.0 d) (+ b (/ a (/ d c))))
(/ a (hypot c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.4e+110) {
tmp = a * (-1.0 / hypot(c, d));
} else if (c <= -1.2e-72) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 7.8e+105) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = a / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.4e+110) {
tmp = a * (-1.0 / Math.hypot(c, d));
} else if (c <= -1.2e-72) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 7.8e+105) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = a / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.4e+110: tmp = a * (-1.0 / math.hypot(c, d)) elif c <= -1.2e-72: tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)) elif c <= 7.8e+105: tmp = (1.0 / d) * (b + (a / (d / c))) else: tmp = a / math.hypot(c, d) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.4e+110) tmp = Float64(a * Float64(-1.0 / hypot(c, d))); elseif (c <= -1.2e-72) tmp = Float64(Float64(Float64(b * d) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 7.8e+105) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); else tmp = Float64(a / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.4e+110) tmp = a * (-1.0 / hypot(c, d)); elseif (c <= -1.2e-72) tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)); elseif (c <= 7.8e+105) tmp = (1.0 / d) * (b + (a / (d / c))); else tmp = a / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.4e+110], N[(a * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.2e-72], N[(N[(N[(b * d), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.8e+105], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.4 \cdot 10^{+110}:\\
\;\;\;\;a \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -1.2 \cdot 10^{-72}:\\
\;\;\;\;\frac{b \cdot d + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 7.8 \cdot 10^{+105}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -2.40000000000000012e110Initial program 36.1%
*-un-lft-identity36.1%
add-sqr-sqrt36.1%
times-frac36.1%
hypot-def36.1%
fma-def36.1%
hypot-def56.3%
Applied egg-rr56.3%
Taylor expanded in c around -inf 71.5%
neg-mul-171.5%
Simplified71.5%
if -2.40000000000000012e110 < c < -1.2e-72Initial program 76.7%
if -1.2e-72 < c < 7.79999999999999957e105Initial program 69.9%
*-un-lft-identity69.9%
add-sqr-sqrt69.9%
times-frac69.8%
hypot-def69.8%
fma-def69.8%
hypot-def84.2%
Applied egg-rr84.2%
Taylor expanded in c around 0 50.7%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in c around 0 88.7%
if 7.79999999999999957e105 < c Initial program 43.3%
*-un-lft-identity43.3%
add-sqr-sqrt43.3%
times-frac43.4%
hypot-def43.4%
fma-def43.4%
hypot-def62.3%
Applied egg-rr62.3%
associate-*l/62.4%
*-un-lft-identity62.4%
Applied egg-rr62.4%
Taylor expanded in c around inf 83.5%
Final simplification83.1%
(FPCore (a b c d)
:precision binary64
(if (<= c -4.1e+108)
(/ a c)
(if (<= c -4.2e-72)
(/ (+ (* b d) (* c a)) (+ (* c c) (* d d)))
(if (<= c 1.16e+108) (* (/ 1.0 d) (+ b (/ a (/ d c)))) (/ a c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.1e+108) {
tmp = a / c;
} else if (c <= -4.2e-72) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 1.16e+108) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} 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 (c <= (-4.1d+108)) then
tmp = a / c
else if (c <= (-4.2d-72)) then
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d))
else if (c <= 1.16d+108) then
tmp = (1.0d0 / d) * (b + (a / (d / c)))
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 (c <= -4.1e+108) {
tmp = a / c;
} else if (c <= -4.2e-72) {
tmp = ((b * d) + (c * a)) / ((c * c) + (d * d));
} else if (c <= 1.16e+108) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -4.1e+108: tmp = a / c elif c <= -4.2e-72: tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)) elif c <= 1.16e+108: tmp = (1.0 / d) * (b + (a / (d / c))) else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -4.1e+108) tmp = Float64(a / c); elseif (c <= -4.2e-72) tmp = Float64(Float64(Float64(b * d) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 1.16e+108) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -4.1e+108) tmp = a / c; elseif (c <= -4.2e-72) tmp = ((b * d) + (c * a)) / ((c * c) + (d * d)); elseif (c <= 1.16e+108) tmp = (1.0 / d) * (b + (a / (d / c))); else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.1e+108], N[(a / c), $MachinePrecision], If[LessEqual[c, -4.2e-72], N[(N[(N[(b * d), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.16e+108], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.1 \cdot 10^{+108}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq -4.2 \cdot 10^{-72}:\\
\;\;\;\;\frac{b \cdot d + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.16 \cdot 10^{+108}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -4.0999999999999999e108 or 1.15999999999999995e108 < c Initial program 39.8%
Taylor expanded in c around inf 78.7%
if -4.0999999999999999e108 < c < -4.2e-72Initial program 76.7%
if -4.2e-72 < c < 1.15999999999999995e108Initial program 69.6%
*-un-lft-identity69.6%
add-sqr-sqrt69.6%
times-frac69.5%
hypot-def69.5%
fma-def69.5%
hypot-def83.7%
Applied egg-rr83.7%
Taylor expanded in c around 0 49.9%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in c around 0 88.1%
Final simplification83.0%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.1e+34)
(/ a c)
(if (<= c -2.1e-60)
(/ (* c a) (+ (* c c) (* d d)))
(if (<= c 2.95e+109) (* (/ 1.0 d) (+ b (/ a (/ d c)))) (/ a c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.1e+34) {
tmp = a / c;
} else if (c <= -2.1e-60) {
tmp = (c * a) / ((c * c) + (d * d));
} else if (c <= 2.95e+109) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} 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 (c <= (-2.1d+34)) then
tmp = a / c
else if (c <= (-2.1d-60)) then
tmp = (c * a) / ((c * c) + (d * d))
else if (c <= 2.95d+109) then
tmp = (1.0d0 / d) * (b + (a / (d / c)))
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 (c <= -2.1e+34) {
tmp = a / c;
} else if (c <= -2.1e-60) {
tmp = (c * a) / ((c * c) + (d * d));
} else if (c <= 2.95e+109) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.1e+34: tmp = a / c elif c <= -2.1e-60: tmp = (c * a) / ((c * c) + (d * d)) elif c <= 2.95e+109: tmp = (1.0 / d) * (b + (a / (d / c))) else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.1e+34) tmp = Float64(a / c); elseif (c <= -2.1e-60) tmp = Float64(Float64(c * a) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 2.95e+109) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.1e+34) tmp = a / c; elseif (c <= -2.1e-60) tmp = (c * a) / ((c * c) + (d * d)); elseif (c <= 2.95e+109) tmp = (1.0 / d) * (b + (a / (d / c))); else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.1e+34], N[(a / c), $MachinePrecision], If[LessEqual[c, -2.1e-60], N[(N[(c * a), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.95e+109], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq -2.1 \cdot 10^{-60}:\\
\;\;\;\;\frac{c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 2.95 \cdot 10^{+109}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -2.10000000000000017e34 or 2.9499999999999999e109 < c Initial program 43.6%
Taylor expanded in c around inf 74.6%
if -2.10000000000000017e34 < c < -2.09999999999999991e-60Initial program 84.6%
Taylor expanded in a around inf 66.5%
*-commutative66.5%
Simplified66.5%
if -2.09999999999999991e-60 < c < 2.9499999999999999e109Initial program 69.6%
*-un-lft-identity69.6%
add-sqr-sqrt69.6%
times-frac69.5%
hypot-def69.5%
fma-def69.5%
hypot-def83.7%
Applied egg-rr83.7%
Taylor expanded in c around 0 49.9%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in c around 0 88.1%
Final simplification80.5%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.1e-60) (not (<= c 9.8e+107))) (/ a c) (* (/ 1.0 d) (+ b (/ a (/ d c))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.1e-60) || !(c <= 9.8e+107)) {
tmp = a / c;
} else {
tmp = (1.0 / d) * (b + (a / (d / 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 ((c <= (-2.1d-60)) .or. (.not. (c <= 9.8d+107))) then
tmp = a / c
else
tmp = (1.0d0 / d) * (b + (a / (d / c)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.1e-60) || !(c <= 9.8e+107)) {
tmp = a / c;
} else {
tmp = (1.0 / d) * (b + (a / (d / c)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.1e-60) or not (c <= 9.8e+107): tmp = a / c else: tmp = (1.0 / d) * (b + (a / (d / c))) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.1e-60) || !(c <= 9.8e+107)) tmp = Float64(a / c); else tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.1e-60) || ~((c <= 9.8e+107))) tmp = a / c; else tmp = (1.0 / d) * (b + (a / (d / c))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.1e-60], N[Not[LessEqual[c, 9.8e+107]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.1 \cdot 10^{-60} \lor \neg \left(c \leq 9.8 \cdot 10^{+107}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\end{array}
\end{array}
if c < -2.09999999999999991e-60 or 9.8000000000000003e107 < c Initial program 51.9%
Taylor expanded in c around inf 69.4%
if -2.09999999999999991e-60 < c < 9.8000000000000003e107Initial program 69.6%
*-un-lft-identity69.6%
add-sqr-sqrt69.6%
times-frac69.5%
hypot-def69.5%
fma-def69.5%
hypot-def83.7%
Applied egg-rr83.7%
Taylor expanded in c around 0 49.9%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in c around 0 88.1%
Final simplification78.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -4.6e-77)
(/ a c)
(if (<= c 3.2e-161)
(/ b d)
(if (<= c 1.12e-48)
(/ (* (/ c d) a) d)
(if (<= c 4.5e+53) (/ b d) (/ a c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.6e-77) {
tmp = a / c;
} else if (c <= 3.2e-161) {
tmp = b / d;
} else if (c <= 1.12e-48) {
tmp = ((c / d) * a) / d;
} else if (c <= 4.5e+53) {
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 (c <= (-4.6d-77)) then
tmp = a / c
else if (c <= 3.2d-161) then
tmp = b / d
else if (c <= 1.12d-48) then
tmp = ((c / d) * a) / d
else if (c <= 4.5d+53) 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 (c <= -4.6e-77) {
tmp = a / c;
} else if (c <= 3.2e-161) {
tmp = b / d;
} else if (c <= 1.12e-48) {
tmp = ((c / d) * a) / d;
} else if (c <= 4.5e+53) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -4.6e-77: tmp = a / c elif c <= 3.2e-161: tmp = b / d elif c <= 1.12e-48: tmp = ((c / d) * a) / d elif c <= 4.5e+53: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -4.6e-77) tmp = Float64(a / c); elseif (c <= 3.2e-161) tmp = Float64(b / d); elseif (c <= 1.12e-48) tmp = Float64(Float64(Float64(c / d) * a) / d); elseif (c <= 4.5e+53) 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 (c <= -4.6e-77) tmp = a / c; elseif (c <= 3.2e-161) tmp = b / d; elseif (c <= 1.12e-48) tmp = ((c / d) * a) / d; elseif (c <= 4.5e+53) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.6e-77], N[(a / c), $MachinePrecision], If[LessEqual[c, 3.2e-161], N[(b / d), $MachinePrecision], If[LessEqual[c, 1.12e-48], N[(N[(N[(c / d), $MachinePrecision] * a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4.5e+53], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.6 \cdot 10^{-77}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 3.2 \cdot 10^{-161}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 1.12 \cdot 10^{-48}:\\
\;\;\;\;\frac{\frac{c}{d} \cdot a}{d}\\
\mathbf{elif}\;c \leq 4.5 \cdot 10^{+53}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -4.59999999999999997e-77 or 4.5000000000000002e53 < c Initial program 51.8%
Taylor expanded in c around inf 68.4%
if -4.59999999999999997e-77 < c < 3.19999999999999985e-161 or 1.11999999999999999e-48 < c < 4.5000000000000002e53Initial program 68.1%
Taylor expanded in c around 0 73.5%
if 3.19999999999999985e-161 < c < 1.11999999999999999e-48Initial program 80.8%
Taylor expanded in a around inf 55.0%
*-commutative55.0%
Simplified55.0%
Taylor expanded in c around 0 55.0%
*-commutative55.0%
associate-*r/51.4%
Simplified51.4%
associate-*r/55.0%
unpow255.0%
associate-/r*58.9%
*-commutative58.9%
associate-*l/55.2%
associate-/r/58.8%
div-inv58.7%
clear-num58.8%
Applied egg-rr58.8%
Final simplification69.3%
(FPCore (a b c d) :precision binary64 (if (or (<= c -4.4e-79) (not (<= c 3.7e+55))) (/ a c) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -4.4e-79) || !(c <= 3.7e+55)) {
tmp = a / c;
} 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) :: tmp
if ((c <= (-4.4d-79)) .or. (.not. (c <= 3.7d+55))) then
tmp = a / c
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -4.4e-79) || !(c <= 3.7e+55)) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -4.4e-79) or not (c <= 3.7e+55): tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -4.4e-79) || !(c <= 3.7e+55)) tmp = Float64(a / c); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -4.4e-79) || ~((c <= 3.7e+55))) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -4.4e-79], N[Not[LessEqual[c, 3.7e+55]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.4 \cdot 10^{-79} \lor \neg \left(c \leq 3.7 \cdot 10^{+55}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -4.3999999999999998e-79 or 3.7000000000000002e55 < c Initial program 51.8%
Taylor expanded in c around inf 68.4%
if -4.3999999999999998e-79 < c < 3.7000000000000002e55Initial program 70.8%
Taylor expanded in c around 0 66.2%
Final simplification67.4%
(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 60.7%
Taylor expanded in c around inf 42.7%
Final simplification42.7%
(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 2023306
(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))))