
(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 11 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 (+ (* a c) (* b d))) (t_1 (/ b (/ c d))))
(if (<= c -2.06e+102)
(/ (- (- a) t_1) (hypot c d))
(if (<= c -2.3e-164)
(/ t_0 (+ (* c c) (* d d)))
(if (<= c 1.05e-105)
(* (/ 1.0 d) (+ b (* a (/ c d))))
(if (<= c 6.6e+78)
(/ t_0 (pow (hypot c d) 2.0))
(/ (+ a t_1) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = b / (c / d);
double tmp;
if (c <= -2.06e+102) {
tmp = (-a - t_1) / hypot(c, d);
} else if (c <= -2.3e-164) {
tmp = t_0 / ((c * c) + (d * d));
} else if (c <= 1.05e-105) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 6.6e+78) {
tmp = t_0 / pow(hypot(c, d), 2.0);
} else {
tmp = (a + t_1) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = b / (c / d);
double tmp;
if (c <= -2.06e+102) {
tmp = (-a - t_1) / Math.hypot(c, d);
} else if (c <= -2.3e-164) {
tmp = t_0 / ((c * c) + (d * d));
} else if (c <= 1.05e-105) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 6.6e+78) {
tmp = t_0 / Math.pow(Math.hypot(c, d), 2.0);
} else {
tmp = (a + t_1) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (a * c) + (b * d) t_1 = b / (c / d) tmp = 0 if c <= -2.06e+102: tmp = (-a - t_1) / math.hypot(c, d) elif c <= -2.3e-164: tmp = t_0 / ((c * c) + (d * d)) elif c <= 1.05e-105: tmp = (1.0 / d) * (b + (a * (c / d))) elif c <= 6.6e+78: tmp = t_0 / math.pow(math.hypot(c, d), 2.0) else: tmp = (a + t_1) / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) t_1 = Float64(b / Float64(c / d)) tmp = 0.0 if (c <= -2.06e+102) tmp = Float64(Float64(Float64(-a) - t_1) / hypot(c, d)); elseif (c <= -2.3e-164) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 1.05e-105) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))); elseif (c <= 6.6e+78) tmp = Float64(t_0 / (hypot(c, d) ^ 2.0)); else tmp = Float64(Float64(a + t_1) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a * c) + (b * d); t_1 = b / (c / d); tmp = 0.0; if (c <= -2.06e+102) tmp = (-a - t_1) / hypot(c, d); elseif (c <= -2.3e-164) tmp = t_0 / ((c * c) + (d * d)); elseif (c <= 1.05e-105) tmp = (1.0 / d) * (b + (a * (c / d))); elseif (c <= 6.6e+78) tmp = t_0 / (hypot(c, d) ^ 2.0); else tmp = (a + t_1) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.06e+102], N[(N[((-a) - t$95$1), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.3e-164], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.05e-105], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.6e+78], N[(t$95$0 / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(a + t$95$1), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
t_1 := \frac{b}{\frac{c}{d}}\\
\mathbf{if}\;c \leq -2.06 \cdot 10^{+102}:\\
\;\;\;\;\frac{\left(-a\right) - t\_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -2.3 \cdot 10^{-164}:\\
\;\;\;\;\frac{t\_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.05 \cdot 10^{-105}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\mathbf{elif}\;c \leq 6.6 \cdot 10^{+78}:\\
\;\;\;\;\frac{t\_0}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + t\_1}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -2.05999999999999999e102Initial program 33.3%
*-un-lft-identity33.3%
add-sqr-sqrt33.3%
times-frac33.2%
hypot-def33.2%
fma-def33.2%
hypot-def53.4%
Applied egg-rr53.4%
fma-def53.4%
*-commutative53.4%
associate-*l/53.3%
div-inv53.5%
+-commutative53.5%
fma-def53.5%
Applied egg-rr53.5%
Taylor expanded in c around -inf 67.2%
mul-1-neg67.2%
unsub-neg67.2%
neg-mul-167.2%
associate-/l*85.1%
Simplified85.1%
if -2.05999999999999999e102 < c < -2.29999999999999985e-164Initial program 83.0%
if -2.29999999999999985e-164 < c < 1.05e-105Initial program 66.1%
*-un-lft-identity66.1%
add-sqr-sqrt66.1%
times-frac65.9%
hypot-def66.0%
fma-def65.9%
hypot-def82.6%
Applied egg-rr82.6%
Taylor expanded in c around 0 50.3%
associate-/l*50.3%
Simplified50.3%
Taylor expanded in c around 0 92.1%
clear-num92.0%
associate-/r/92.1%
clear-num92.1%
Applied egg-rr92.1%
if 1.05e-105 < c < 6.6e78Initial program 81.5%
expm1-log1p-u78.9%
expm1-udef50.8%
add-sqr-sqrt50.8%
pow250.8%
hypot-def50.8%
Applied egg-rr50.8%
expm1-def78.9%
expm1-log1p81.5%
Simplified81.5%
if 6.6e78 < c Initial program 41.2%
*-un-lft-identity41.2%
add-sqr-sqrt41.2%
times-frac41.2%
hypot-def41.2%
fma-def41.2%
hypot-def61.1%
Applied egg-rr61.1%
fma-def61.0%
*-commutative61.0%
associate-*l/61.0%
div-inv61.1%
+-commutative61.1%
fma-def61.2%
Applied egg-rr61.2%
Taylor expanded in d around 0 82.9%
associate-/l*88.8%
Simplified88.8%
Final simplification86.7%
(FPCore (a b c d) :precision binary64 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) INFINITY) (/ (/ (fma b d (* a c)) (hypot c d)) (hypot c d)) (* (/ c (hypot c d)) (/ a (hypot c 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 = (fma(b, d, (a * c)) / hypot(c, d)) / hypot(c, d);
} else {
tmp = (c / hypot(c, d)) * (a / hypot(c, 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(fma(b, d, Float64(a * c)) / hypot(c, d)) / 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_] := 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[(N[(b * d + N[(a * c), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / 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}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, d, a \cdot c\right)}{\mathsf{hypot}\left(c, d\right)}}{\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 (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 77.9%
*-un-lft-identity77.9%
add-sqr-sqrt77.9%
times-frac77.8%
hypot-def77.8%
fma-def77.8%
hypot-def93.8%
Applied egg-rr93.8%
fma-def93.8%
*-commutative93.8%
associate-*l/93.8%
div-inv93.9%
+-commutative93.9%
fma-def93.9%
Applied egg-rr93.9%
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 inf 1.5%
*-commutative1.5%
Simplified1.5%
add-sqr-sqrt1.5%
hypot-udef1.5%
hypot-udef1.5%
times-frac54.5%
Applied egg-rr54.5%
Final simplification85.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (+ (/ a c) (* d (/ b (pow c 2.0))))))
(if (<= c -3.7e+59)
t_1
(if (<= c -2.3e-164)
t_0
(if (<= c 3.3e-106)
(* (/ 1.0 d) (+ b (* a (/ c d))))
(if (<= c 1.45e+78) t_0 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 = (a / c) + (d * (b / pow(c, 2.0)));
double tmp;
if (c <= -3.7e+59) {
tmp = t_1;
} else if (c <= -2.3e-164) {
tmp = t_0;
} else if (c <= 3.3e-106) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 1.45e+78) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
t_1 = (a / c) + (d * (b / (c ** 2.0d0)))
if (c <= (-3.7d+59)) then
tmp = t_1
else if (c <= (-2.3d-164)) then
tmp = t_0
else if (c <= 3.3d-106) then
tmp = (1.0d0 / d) * (b + (a * (c / d)))
else if (c <= 1.45d+78) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = (a / c) + (d * (b / Math.pow(c, 2.0)));
double tmp;
if (c <= -3.7e+59) {
tmp = t_1;
} else if (c <= -2.3e-164) {
tmp = t_0;
} else if (c <= 3.3e-106) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 1.45e+78) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = (a / c) + (d * (b / math.pow(c, 2.0))) tmp = 0 if c <= -3.7e+59: tmp = t_1 elif c <= -2.3e-164: tmp = t_0 elif c <= 3.3e-106: tmp = (1.0 / d) * (b + (a * (c / d))) elif c <= 1.45e+78: tmp = t_0 else: tmp = 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(Float64(a / c) + Float64(d * Float64(b / (c ^ 2.0)))) tmp = 0.0 if (c <= -3.7e+59) tmp = t_1; elseif (c <= -2.3e-164) tmp = t_0; elseif (c <= 3.3e-106) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))); elseif (c <= 1.45e+78) tmp = t_0; else tmp = 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 = (a / c) + (d * (b / (c ^ 2.0))); tmp = 0.0; if (c <= -3.7e+59) tmp = t_1; elseif (c <= -2.3e-164) tmp = t_0; elseif (c <= 3.3e-106) tmp = (1.0 / d) * (b + (a * (c / d))); elseif (c <= 1.45e+78) tmp = t_0; else tmp = 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[(N[(a / c), $MachinePrecision] + N[(d * N[(b / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.7e+59], t$95$1, If[LessEqual[c, -2.3e-164], t$95$0, If[LessEqual[c, 3.3e-106], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.45e+78], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{a}{c} + d \cdot \frac{b}{{c}^{2}}\\
\mathbf{if}\;c \leq -3.7 \cdot 10^{+59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq -2.3 \cdot 10^{-164}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 3.3 \cdot 10^{-106}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if c < -3.69999999999999997e59 or 1.45000000000000008e78 < c Initial program 41.7%
Taylor expanded in c around inf 71.6%
associate-/l*74.9%
associate-/r/77.6%
Simplified77.6%
if -3.69999999999999997e59 < c < -2.29999999999999985e-164 or 3.30000000000000016e-106 < c < 1.45000000000000008e78Initial program 83.6%
if -2.29999999999999985e-164 < c < 3.30000000000000016e-106Initial program 66.1%
*-un-lft-identity66.1%
add-sqr-sqrt66.1%
times-frac65.9%
hypot-def66.0%
fma-def65.9%
hypot-def82.6%
Applied egg-rr82.6%
Taylor expanded in c around 0 50.3%
associate-/l*50.3%
Simplified50.3%
Taylor expanded in c around 0 92.1%
clear-num92.0%
associate-/r/92.1%
clear-num92.1%
Applied egg-rr92.1%
Final simplification83.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -1.05e+60)
(+ (/ a c) (* d (/ b (pow c 2.0))))
(if (<= c -2.3e-164)
t_0
(if (<= c 1.45e-105)
(* (/ 1.0 d) (+ b (* a (/ c d))))
(if (<= c 6.2e+78) t_0 (/ (+ a (/ b (/ 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 (c <= -1.05e+60) {
tmp = (a / c) + (d * (b / pow(c, 2.0)));
} else if (c <= -2.3e-164) {
tmp = t_0;
} else if (c <= 1.45e-105) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 6.2e+78) {
tmp = t_0;
} else {
tmp = (a + (b / (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 (c <= -1.05e+60) {
tmp = (a / c) + (d * (b / Math.pow(c, 2.0)));
} else if (c <= -2.3e-164) {
tmp = t_0;
} else if (c <= 1.45e-105) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 6.2e+78) {
tmp = t_0;
} else {
tmp = (a + (b / (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 c <= -1.05e+60: tmp = (a / c) + (d * (b / math.pow(c, 2.0))) elif c <= -2.3e-164: tmp = t_0 elif c <= 1.45e-105: tmp = (1.0 / d) * (b + (a * (c / d))) elif c <= 6.2e+78: tmp = t_0 else: tmp = (a + (b / (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 (c <= -1.05e+60) tmp = Float64(Float64(a / c) + Float64(d * Float64(b / (c ^ 2.0)))); elseif (c <= -2.3e-164) tmp = t_0; elseif (c <= 1.45e-105) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))); elseif (c <= 6.2e+78) tmp = t_0; else tmp = Float64(Float64(a + Float64(b / Float64(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 (c <= -1.05e+60) tmp = (a / c) + (d * (b / (c ^ 2.0))); elseif (c <= -2.3e-164) tmp = t_0; elseif (c <= 1.45e-105) tmp = (1.0 / d) * (b + (a * (c / d))); elseif (c <= 6.2e+78) tmp = t_0; else tmp = (a + (b / (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[c, -1.05e+60], N[(N[(a / c), $MachinePrecision] + N[(d * N[(b / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.3e-164], t$95$0, If[LessEqual[c, 1.45e-105], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.2e+78], t$95$0, N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $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}\;c \leq -1.05 \cdot 10^{+60}:\\
\;\;\;\;\frac{a}{c} + d \cdot \frac{b}{{c}^{2}}\\
\mathbf{elif}\;c \leq -2.3 \cdot 10^{-164}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-105}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\mathbf{elif}\;c \leq 6.2 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -1.0500000000000001e60Initial program 42.2%
Taylor expanded in c around inf 65.2%
associate-/l*69.4%
associate-/r/72.7%
Simplified72.7%
if -1.0500000000000001e60 < c < -2.29999999999999985e-164 or 1.45000000000000002e-105 < c < 6.2e78Initial program 83.6%
if -2.29999999999999985e-164 < c < 1.45000000000000002e-105Initial program 66.1%
*-un-lft-identity66.1%
add-sqr-sqrt66.1%
times-frac65.9%
hypot-def66.0%
fma-def65.9%
hypot-def82.6%
Applied egg-rr82.6%
Taylor expanded in c around 0 50.3%
associate-/l*50.3%
Simplified50.3%
Taylor expanded in c around 0 92.1%
clear-num92.0%
associate-/r/92.1%
clear-num92.1%
Applied egg-rr92.1%
if 6.2e78 < c Initial program 41.2%
*-un-lft-identity41.2%
add-sqr-sqrt41.2%
times-frac41.2%
hypot-def41.2%
fma-def41.2%
hypot-def61.1%
Applied egg-rr61.1%
fma-def61.0%
*-commutative61.0%
associate-*l/61.0%
div-inv61.1%
+-commutative61.1%
fma-def61.2%
Applied egg-rr61.2%
Taylor expanded in d around 0 82.9%
associate-/l*88.8%
Simplified88.8%
Final simplification84.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))) (t_1 (/ b (/ c d))))
(if (<= c -2.2e+102)
(/ (- (- a) t_1) (hypot c d))
(if (<= c -2.3e-164)
t_0
(if (<= c 3.9e-106)
(* (/ 1.0 d) (+ b (* a (/ c d))))
(if (<= c 4.2e+78) t_0 (/ (+ a t_1) (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 t_1 = b / (c / d);
double tmp;
if (c <= -2.2e+102) {
tmp = (-a - t_1) / hypot(c, d);
} else if (c <= -2.3e-164) {
tmp = t_0;
} else if (c <= 3.9e-106) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 4.2e+78) {
tmp = t_0;
} else {
tmp = (a + t_1) / 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 t_1 = b / (c / d);
double tmp;
if (c <= -2.2e+102) {
tmp = (-a - t_1) / Math.hypot(c, d);
} else if (c <= -2.3e-164) {
tmp = t_0;
} else if (c <= 3.9e-106) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 4.2e+78) {
tmp = t_0;
} else {
tmp = (a + t_1) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = b / (c / d) tmp = 0 if c <= -2.2e+102: tmp = (-a - t_1) / math.hypot(c, d) elif c <= -2.3e-164: tmp = t_0 elif c <= 3.9e-106: tmp = (1.0 / d) * (b + (a * (c / d))) elif c <= 4.2e+78: tmp = t_0 else: tmp = (a + t_1) / 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))) t_1 = Float64(b / Float64(c / d)) tmp = 0.0 if (c <= -2.2e+102) tmp = Float64(Float64(Float64(-a) - t_1) / hypot(c, d)); elseif (c <= -2.3e-164) tmp = t_0; elseif (c <= 3.9e-106) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))); elseif (c <= 4.2e+78) tmp = t_0; else tmp = Float64(Float64(a + t_1) / 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)); t_1 = b / (c / d); tmp = 0.0; if (c <= -2.2e+102) tmp = (-a - t_1) / hypot(c, d); elseif (c <= -2.3e-164) tmp = t_0; elseif (c <= 3.9e-106) tmp = (1.0 / d) * (b + (a * (c / d))); elseif (c <= 4.2e+78) tmp = t_0; else tmp = (a + t_1) / 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]}, Block[{t$95$1 = N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.2e+102], N[(N[((-a) - t$95$1), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.3e-164], t$95$0, If[LessEqual[c, 3.9e-106], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.2e+78], t$95$0, N[(N[(a + t$95$1), $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}\\
t_1 := \frac{b}{\frac{c}{d}}\\
\mathbf{if}\;c \leq -2.2 \cdot 10^{+102}:\\
\;\;\;\;\frac{\left(-a\right) - t\_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -2.3 \cdot 10^{-164}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 3.9 \cdot 10^{-106}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\mathbf{elif}\;c \leq 4.2 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a + t\_1}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -2.20000000000000007e102Initial program 33.3%
*-un-lft-identity33.3%
add-sqr-sqrt33.3%
times-frac33.2%
hypot-def33.2%
fma-def33.2%
hypot-def53.4%
Applied egg-rr53.4%
fma-def53.4%
*-commutative53.4%
associate-*l/53.3%
div-inv53.5%
+-commutative53.5%
fma-def53.5%
Applied egg-rr53.5%
Taylor expanded in c around -inf 67.2%
mul-1-neg67.2%
unsub-neg67.2%
neg-mul-167.2%
associate-/l*85.1%
Simplified85.1%
if -2.20000000000000007e102 < c < -2.29999999999999985e-164 or 3.9000000000000001e-106 < c < 4.2000000000000002e78Initial program 82.5%
if -2.29999999999999985e-164 < c < 3.9000000000000001e-106Initial program 66.1%
*-un-lft-identity66.1%
add-sqr-sqrt66.1%
times-frac65.9%
hypot-def66.0%
fma-def65.9%
hypot-def82.6%
Applied egg-rr82.6%
Taylor expanded in c around 0 50.3%
associate-/l*50.3%
Simplified50.3%
Taylor expanded in c around 0 92.1%
clear-num92.0%
associate-/r/92.1%
clear-num92.1%
Applied egg-rr92.1%
if 4.2000000000000002e78 < c Initial program 41.2%
*-un-lft-identity41.2%
add-sqr-sqrt41.2%
times-frac41.2%
hypot-def41.2%
fma-def41.2%
hypot-def61.1%
Applied egg-rr61.1%
fma-def61.0%
*-commutative61.0%
associate-*l/61.0%
div-inv61.1%
+-commutative61.1%
fma-def61.2%
Applied egg-rr61.2%
Taylor expanded in d around 0 82.9%
associate-/l*88.8%
Simplified88.8%
Final simplification86.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -2.15e+102)
(/ (- a) (hypot c d))
(if (<= c -2.3e-164)
t_0
(if (<= c 1.75e-105)
(* (/ 1.0 d) (+ b (* a (/ c d))))
(if (<= c 1.05e+153) t_0 (/ a c)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -2.15e+102) {
tmp = -a / hypot(c, d);
} else if (c <= -2.3e-164) {
tmp = t_0;
} else if (c <= 1.75e-105) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 1.05e+153) {
tmp = t_0;
} else {
tmp = a / c;
}
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 (c <= -2.15e+102) {
tmp = -a / Math.hypot(c, d);
} else if (c <= -2.3e-164) {
tmp = t_0;
} else if (c <= 1.75e-105) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 1.05e+153) {
tmp = t_0;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -2.15e+102: tmp = -a / math.hypot(c, d) elif c <= -2.3e-164: tmp = t_0 elif c <= 1.75e-105: tmp = (1.0 / d) * (b + (a * (c / d))) elif c <= 1.05e+153: tmp = t_0 else: tmp = a / c 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 (c <= -2.15e+102) tmp = Float64(Float64(-a) / hypot(c, d)); elseif (c <= -2.3e-164) tmp = t_0; elseif (c <= 1.75e-105) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))); elseif (c <= 1.05e+153) tmp = t_0; else tmp = Float64(a / c); 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 (c <= -2.15e+102) tmp = -a / hypot(c, d); elseif (c <= -2.3e-164) tmp = t_0; elseif (c <= 1.75e-105) tmp = (1.0 / d) * (b + (a * (c / d))); elseif (c <= 1.05e+153) tmp = t_0; else tmp = a / c; 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[c, -2.15e+102], N[((-a) / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.3e-164], t$95$0, If[LessEqual[c, 1.75e-105], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.05e+153], t$95$0, N[(a / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -2.15 \cdot 10^{+102}:\\
\;\;\;\;\frac{-a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -2.3 \cdot 10^{-164}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.75 \cdot 10^{-105}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\mathbf{elif}\;c \leq 1.05 \cdot 10^{+153}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -2.15e102Initial program 33.3%
*-un-lft-identity33.3%
add-sqr-sqrt33.3%
times-frac33.2%
hypot-def33.2%
fma-def33.2%
hypot-def53.4%
Applied egg-rr53.4%
fma-def53.4%
*-commutative53.4%
associate-*l/53.3%
div-inv53.5%
+-commutative53.5%
fma-def53.5%
Applied egg-rr53.5%
Taylor expanded in c around -inf 69.7%
neg-mul-169.7%
Simplified69.7%
if -2.15e102 < c < -2.29999999999999985e-164 or 1.75e-105 < c < 1.05000000000000008e153Initial program 81.2%
if -2.29999999999999985e-164 < c < 1.75e-105Initial program 66.1%
*-un-lft-identity66.1%
add-sqr-sqrt66.1%
times-frac65.9%
hypot-def66.0%
fma-def65.9%
hypot-def82.6%
Applied egg-rr82.6%
Taylor expanded in c around 0 50.3%
associate-/l*50.3%
Simplified50.3%
Taylor expanded in c around 0 92.1%
clear-num92.0%
associate-/r/92.1%
clear-num92.1%
Applied egg-rr92.1%
if 1.05000000000000008e153 < c Initial program 29.2%
Taylor expanded in c around inf 81.7%
Final simplification82.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -2.1e+102)
(/ a c)
(if (<= c -2.3e-164)
t_0
(if (<= c 3e-106)
(* (/ 1.0 d) (+ b (* a (/ c d))))
(if (<= c 9.2e+151) t_0 (/ a c)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -2.1e+102) {
tmp = a / c;
} else if (c <= -2.3e-164) {
tmp = t_0;
} else if (c <= 3e-106) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 9.2e+151) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
if (c <= (-2.1d+102)) then
tmp = a / c
else if (c <= (-2.3d-164)) then
tmp = t_0
else if (c <= 3d-106) then
tmp = (1.0d0 / d) * (b + (a * (c / d)))
else if (c <= 9.2d+151) then
tmp = t_0
else
tmp = a / c
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 (c <= -2.1e+102) {
tmp = a / c;
} else if (c <= -2.3e-164) {
tmp = t_0;
} else if (c <= 3e-106) {
tmp = (1.0 / d) * (b + (a * (c / d)));
} else if (c <= 9.2e+151) {
tmp = t_0;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -2.1e+102: tmp = a / c elif c <= -2.3e-164: tmp = t_0 elif c <= 3e-106: tmp = (1.0 / d) * (b + (a * (c / d))) elif c <= 9.2e+151: tmp = t_0 else: tmp = a / c 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 (c <= -2.1e+102) tmp = Float64(a / c); elseif (c <= -2.3e-164) tmp = t_0; elseif (c <= 3e-106) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))); elseif (c <= 9.2e+151) tmp = t_0; else tmp = Float64(a / c); 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 (c <= -2.1e+102) tmp = a / c; elseif (c <= -2.3e-164) tmp = t_0; elseif (c <= 3e-106) tmp = (1.0 / d) * (b + (a * (c / d))); elseif (c <= 9.2e+151) tmp = t_0; else tmp = a / c; 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[c, -2.1e+102], N[(a / c), $MachinePrecision], If[LessEqual[c, -2.3e-164], t$95$0, If[LessEqual[c, 3e-106], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 9.2e+151], t$95$0, N[(a / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -2.1 \cdot 10^{+102}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq -2.3 \cdot 10^{-164}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 3 \cdot 10^{-106}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\mathbf{elif}\;c \leq 9.2 \cdot 10^{+151}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -2.10000000000000001e102 or 9.2000000000000003e151 < c Initial program 31.4%
Taylor expanded in c around inf 75.1%
if -2.10000000000000001e102 < c < -2.29999999999999985e-164 or 3.00000000000000019e-106 < c < 9.2000000000000003e151Initial program 81.2%
if -2.29999999999999985e-164 < c < 3.00000000000000019e-106Initial program 66.1%
*-un-lft-identity66.1%
add-sqr-sqrt66.1%
times-frac65.9%
hypot-def66.0%
fma-def65.9%
hypot-def82.6%
Applied egg-rr82.6%
Taylor expanded in c around 0 50.3%
associate-/l*50.3%
Simplified50.3%
Taylor expanded in c around 0 92.1%
clear-num92.0%
associate-/r/92.1%
clear-num92.1%
Applied egg-rr92.1%
Final simplification82.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 d) (+ b (* a (/ c d))))))
(if (<= c -1.35e-27)
(/ a c)
(if (<= c 6e-101)
t_0
(if (<= c 8.6e+42)
(/ (* a c) (+ (* c c) (* d d)))
(if (<= c 2.1e+77) t_0 (/ a c)))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / d) * (b + (a * (c / d)));
double tmp;
if (c <= -1.35e-27) {
tmp = a / c;
} else if (c <= 6e-101) {
tmp = t_0;
} else if (c <= 8.6e+42) {
tmp = (a * c) / ((c * c) + (d * d));
} else if (c <= 2.1e+77) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / d) * (b + (a * (c / d)))
if (c <= (-1.35d-27)) then
tmp = a / c
else if (c <= 6d-101) then
tmp = t_0
else if (c <= 8.6d+42) then
tmp = (a * c) / ((c * c) + (d * d))
else if (c <= 2.1d+77) then
tmp = t_0
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (1.0 / d) * (b + (a * (c / d)));
double tmp;
if (c <= -1.35e-27) {
tmp = a / c;
} else if (c <= 6e-101) {
tmp = t_0;
} else if (c <= 8.6e+42) {
tmp = (a * c) / ((c * c) + (d * d));
} else if (c <= 2.1e+77) {
tmp = t_0;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / d) * (b + (a * (c / d))) tmp = 0 if c <= -1.35e-27: tmp = a / c elif c <= 6e-101: tmp = t_0 elif c <= 8.6e+42: tmp = (a * c) / ((c * c) + (d * d)) elif c <= 2.1e+77: tmp = t_0 else: tmp = a / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))) tmp = 0.0 if (c <= -1.35e-27) tmp = Float64(a / c); elseif (c <= 6e-101) tmp = t_0; elseif (c <= 8.6e+42) tmp = Float64(Float64(a * c) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 2.1e+77) tmp = t_0; else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / d) * (b + (a * (c / d))); tmp = 0.0; if (c <= -1.35e-27) tmp = a / c; elseif (c <= 6e-101) tmp = t_0; elseif (c <= 8.6e+42) tmp = (a * c) / ((c * c) + (d * d)); elseif (c <= 2.1e+77) tmp = t_0; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.35e-27], N[(a / c), $MachinePrecision], If[LessEqual[c, 6e-101], t$95$0, If[LessEqual[c, 8.6e+42], N[(N[(a * c), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.1e+77], t$95$0, N[(a / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\mathbf{if}\;c \leq -1.35 \cdot 10^{-27}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 6 \cdot 10^{-101}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 8.6 \cdot 10^{+42}:\\
\;\;\;\;\frac{a \cdot c}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 2.1 \cdot 10^{+77}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -1.34999999999999994e-27 or 2.0999999999999999e77 < c Initial program 47.8%
Taylor expanded in c around inf 68.8%
if -1.34999999999999994e-27 < c < 6.0000000000000006e-101 or 8.5999999999999996e42 < c < 2.0999999999999999e77Initial program 72.5%
*-un-lft-identity72.5%
add-sqr-sqrt72.5%
times-frac72.4%
hypot-def72.5%
fma-def72.5%
hypot-def84.7%
Applied egg-rr84.7%
Taylor expanded in c around 0 47.3%
associate-/l*47.3%
Simplified47.3%
Taylor expanded in c around 0 83.7%
clear-num83.7%
associate-/r/83.7%
clear-num83.7%
Applied egg-rr83.7%
if 6.0000000000000006e-101 < c < 8.5999999999999996e42Initial program 85.3%
Taylor expanded in a around inf 68.7%
*-commutative68.7%
Simplified68.7%
Final simplification75.4%
(FPCore (a b c d) :precision binary64 (if (or (<= c -5.5e-32) (not (<= c 2.65e+78))) (/ a c) (* (/ 1.0 d) (+ b (* a (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.5e-32) || !(c <= 2.65e+78)) {
tmp = a / c;
} else {
tmp = (1.0 / d) * (b + (a * (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 ((c <= (-5.5d-32)) .or. (.not. (c <= 2.65d+78))) then
tmp = a / c
else
tmp = (1.0d0 / d) * (b + (a * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.5e-32) || !(c <= 2.65e+78)) {
tmp = a / c;
} else {
tmp = (1.0 / d) * (b + (a * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -5.5e-32) or not (c <= 2.65e+78): tmp = a / c else: tmp = (1.0 / d) * (b + (a * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -5.5e-32) || !(c <= 2.65e+78)) tmp = Float64(a / c); else tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -5.5e-32) || ~((c <= 2.65e+78))) tmp = a / c; else tmp = (1.0 / d) * (b + (a * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -5.5e-32], N[Not[LessEqual[c, 2.65e+78]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{-32} \lor \neg \left(c \leq 2.65 \cdot 10^{+78}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\end{array}
\end{array}
if c < -5.50000000000000024e-32 or 2.64999999999999981e78 < c Initial program 47.8%
Taylor expanded in c around inf 68.8%
if -5.50000000000000024e-32 < c < 2.64999999999999981e78Initial program 74.4%
*-un-lft-identity74.4%
add-sqr-sqrt74.4%
times-frac74.4%
hypot-def74.4%
fma-def74.4%
hypot-def84.8%
Applied egg-rr84.8%
Taylor expanded in c around 0 42.7%
associate-/l*42.7%
Simplified42.7%
Taylor expanded in c around 0 78.3%
clear-num78.3%
associate-/r/78.3%
clear-num78.3%
Applied egg-rr78.3%
Final simplification73.8%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.7e-27) (not (<= c 2.05e+77))) (/ a c) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.7e-27) || !(c <= 2.05e+77)) {
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 <= (-2.7d-27)) .or. (.not. (c <= 2.05d+77))) 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 <= -2.7e-27) || !(c <= 2.05e+77)) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.7e-27) or not (c <= 2.05e+77): tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.7e-27) || !(c <= 2.05e+77)) 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 <= -2.7e-27) || ~((c <= 2.05e+77))) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.7e-27], N[Not[LessEqual[c, 2.05e+77]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.7 \cdot 10^{-27} \lor \neg \left(c \leq 2.05 \cdot 10^{+77}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -2.69999999999999989e-27 or 2.05e77 < c Initial program 47.8%
Taylor expanded in c around inf 68.8%
if -2.69999999999999989e-27 < c < 2.05e77Initial program 74.4%
Taylor expanded in c around 0 61.8%
Final simplification65.2%
(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 61.7%
Taylor expanded in c around inf 43.1%
Final simplification43.1%
(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 2024031
(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))))