
(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 13 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 (/ t_0 (+ (* c c) (* d d)))))
(if (<= t_1 2e+300)
(/ (/ t_0 (hypot c d)) (hypot c d))
(if (<= t_1 INFINITY)
(* (+ b (/ a (/ d c))) (/ (- -1.0) d))
(* (/ c (hypot c d)) (/ a (hypot c d)))))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= 2e+300) {
tmp = (t_0 / hypot(c, d)) / hypot(c, d);
} else if (t_1 <= ((double) INFINITY)) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} 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 t_0 = (a * c) + (b * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= 2e+300) {
tmp = (t_0 / Math.hypot(c, d)) / Math.hypot(c, d);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} else {
tmp = (c / Math.hypot(c, d)) * (a / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): t_0 = (a * c) + (b * d) t_1 = t_0 / ((c * c) + (d * d)) tmp = 0 if t_1 <= 2e+300: tmp = (t_0 / math.hypot(c, d)) / math.hypot(c, d) elif t_1 <= math.inf: tmp = (b + (a / (d / c))) * (-(-1.0) / d) else: tmp = (c / math.hypot(c, d)) * (a / math.hypot(c, d)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_1 <= 2e+300) tmp = Float64(Float64(t_0 / hypot(c, d)) / hypot(c, d)); elseif (t_1 <= Inf) tmp = Float64(Float64(b + Float64(a / Float64(d / c))) * Float64(Float64(-(-1.0)) / d)); 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) t_0 = (a * c) + (b * d); t_1 = t_0 / ((c * c) + (d * d)); tmp = 0.0; if (t_1 <= 2e+300) tmp = (t_0 / hypot(c, d)) / hypot(c, d); elseif (t_1 <= Inf) tmp = (b + (a / (d / c))) * (-(-1.0) / d); else tmp = (c / hypot(c, d)) * (a / 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[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+300], N[(N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((--1.0) / d), $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 := a \cdot c + b \cdot d\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq 2 \cdot 10^{+300}:\\
\;\;\;\;\frac{\frac{t_0}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\left(b + \frac{a}{\frac{d}{c}}\right) \cdot \frac{--1}{d}\\
\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))) < 2.0000000000000001e300Initial program 84.3%
*-un-lft-identity84.3%
associate-*r/84.3%
fma-def84.3%
add-sqr-sqrt84.3%
times-frac84.3%
fma-def84.3%
hypot-def84.3%
fma-def84.3%
fma-def84.3%
hypot-def98.6%
Applied egg-rr98.6%
associate-*l/98.8%
*-un-lft-identity98.8%
Applied egg-rr98.8%
fma-def98.8%
+-commutative98.8%
Applied egg-rr98.8%
if 2.0000000000000001e300 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 32.5%
*-un-lft-identity32.5%
associate-*r/32.5%
fma-def32.5%
add-sqr-sqrt32.5%
times-frac32.5%
fma-def32.5%
hypot-def32.5%
fma-def32.5%
fma-def32.5%
hypot-def59.4%
Applied egg-rr59.4%
Taylor expanded in d around -inf 39.0%
neg-mul-139.0%
+-commutative39.0%
unsub-neg39.0%
mul-1-neg39.0%
associate-/l*43.5%
distribute-neg-frac43.5%
Simplified43.5%
Taylor expanded in d around -inf 81.6%
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.6%
*-commutative1.6%
Simplified1.6%
add-sqr-sqrt1.6%
hypot-udef1.6%
hypot-udef1.6%
times-frac57.7%
Applied egg-rr57.7%
Final simplification90.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* a c) (* b d))))
(if (<= c -1.35e+78)
(/ (- (- a) (/ b (/ c d))) (hypot c d))
(if (<= c -9e-138)
(/ t_0 (+ (* c c) (* d d)))
(if (<= c 5e-152)
(* (+ b (/ a (/ d c))) (/ (- -1.0) d))
(if (<= c 2.3e+81)
(/ t_0 (fma c c (* d d)))
(/ (+ a (* d (/ b c))) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double tmp;
if (c <= -1.35e+78) {
tmp = (-a - (b / (c / d))) / hypot(c, d);
} else if (c <= -9e-138) {
tmp = t_0 / ((c * c) + (d * d));
} else if (c <= 5e-152) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} else if (c <= 2.3e+81) {
tmp = t_0 / fma(c, c, (d * d));
} else {
tmp = (a + (d * (b / c))) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) tmp = 0.0 if (c <= -1.35e+78) tmp = Float64(Float64(Float64(-a) - Float64(b / Float64(c / d))) / hypot(c, d)); elseif (c <= -9e-138) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 5e-152) tmp = Float64(Float64(b + Float64(a / Float64(d / c))) * Float64(Float64(-(-1.0)) / d)); elseif (c <= 2.3e+81) tmp = Float64(t_0 / fma(c, c, Float64(d * d))); else tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.35e+78], N[(N[((-a) - N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -9e-138], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5e-152], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((--1.0) / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.3e+81], N[(t$95$0 / N[(c * c + N[(d * d), $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}
t_0 := a \cdot c + b \cdot d\\
\mathbf{if}\;c \leq -1.35 \cdot 10^{+78}:\\
\;\;\;\;\frac{\left(-a\right) - \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -9 \cdot 10^{-138}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 5 \cdot 10^{-152}:\\
\;\;\;\;\left(b + \frac{a}{\frac{d}{c}}\right) \cdot \frac{--1}{d}\\
\mathbf{elif}\;c \leq 2.3 \cdot 10^{+81}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + d \cdot \frac{b}{c}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -1.35000000000000002e78Initial program 36.4%
*-un-lft-identity36.4%
associate-*r/36.4%
fma-def36.4%
add-sqr-sqrt36.4%
times-frac36.4%
fma-def36.4%
hypot-def36.4%
fma-def36.4%
fma-def36.4%
hypot-def46.4%
Applied egg-rr46.4%
associate-*l/46.4%
*-un-lft-identity46.4%
Applied egg-rr46.4%
Taylor expanded in c around -inf 85.3%
neg-mul-185.3%
mul-1-neg85.3%
unsub-neg85.3%
associate-/l*90.5%
Simplified90.5%
if -1.35000000000000002e78 < c < -9.00000000000000016e-138Initial program 90.0%
if -9.00000000000000016e-138 < c < 4.9999999999999997e-152Initial program 65.3%
*-un-lft-identity65.3%
associate-*r/65.3%
fma-def65.3%
add-sqr-sqrt65.3%
times-frac65.3%
fma-def65.3%
hypot-def65.3%
fma-def65.3%
fma-def65.3%
hypot-def84.4%
Applied egg-rr84.4%
Taylor expanded in d around -inf 55.9%
neg-mul-155.9%
+-commutative55.9%
unsub-neg55.9%
mul-1-neg55.9%
associate-/l*54.6%
distribute-neg-frac54.6%
Simplified54.6%
Taylor expanded in d around -inf 92.2%
if 4.9999999999999997e-152 < c < 2.2999999999999999e81Initial program 82.7%
fma-def82.7%
fma-def82.7%
Simplified82.7%
fma-def90.3%
+-commutative90.3%
Applied egg-rr82.7%
if 2.2999999999999999e81 < c Initial program 40.1%
*-un-lft-identity40.1%
associate-*r/40.1%
fma-def40.1%
add-sqr-sqrt40.1%
times-frac40.0%
fma-def40.0%
hypot-def40.0%
fma-def40.0%
fma-def40.0%
hypot-def59.4%
Applied egg-rr59.4%
associate-*l/59.5%
*-un-lft-identity59.5%
Applied egg-rr59.5%
Taylor expanded in c around inf 76.0%
associate-/l*88.0%
Simplified88.0%
associate-/r/88.1%
Applied egg-rr88.1%
Final simplification89.0%
(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 -2.1e+79)
t_1
(if (<= c -8.6e-138)
t_0
(if (<= c 3.9e-159)
(* (+ b (/ a (/ d c))) (/ (- -1.0) d))
(if (<= c 2.8e+81) 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 <= -2.1e+79) {
tmp = t_1;
} else if (c <= -8.6e-138) {
tmp = t_0;
} else if (c <= 3.9e-159) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} else if (c <= 2.8e+81) {
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 <= (-2.1d+79)) then
tmp = t_1
else if (c <= (-8.6d-138)) then
tmp = t_0
else if (c <= 3.9d-159) then
tmp = (b + (a / (d / c))) * (-(-1.0d0) / d)
else if (c <= 2.8d+81) 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 <= -2.1e+79) {
tmp = t_1;
} else if (c <= -8.6e-138) {
tmp = t_0;
} else if (c <= 3.9e-159) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} else if (c <= 2.8e+81) {
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 <= -2.1e+79: tmp = t_1 elif c <= -8.6e-138: tmp = t_0 elif c <= 3.9e-159: tmp = (b + (a / (d / c))) * (-(-1.0) / d) elif c <= 2.8e+81: 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 <= -2.1e+79) tmp = t_1; elseif (c <= -8.6e-138) tmp = t_0; elseif (c <= 3.9e-159) tmp = Float64(Float64(b + Float64(a / Float64(d / c))) * Float64(Float64(-(-1.0)) / d)); elseif (c <= 2.8e+81) 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 <= -2.1e+79) tmp = t_1; elseif (c <= -8.6e-138) tmp = t_0; elseif (c <= 3.9e-159) tmp = (b + (a / (d / c))) * (-(-1.0) / d); elseif (c <= 2.8e+81) 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, -2.1e+79], t$95$1, If[LessEqual[c, -8.6e-138], t$95$0, If[LessEqual[c, 3.9e-159], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((--1.0) / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.8e+81], 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 -2.1 \cdot 10^{+79}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -8.6 \cdot 10^{-138}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.9 \cdot 10^{-159}:\\
\;\;\;\;\left(b + \frac{a}{\frac{d}{c}}\right) \cdot \frac{--1}{d}\\
\mathbf{elif}\;c \leq 2.8 \cdot 10^{+81}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -2.10000000000000008e79 or 2.79999999999999995e81 < c Initial program 38.3%
Taylor expanded in c around inf 78.4%
associate-/l*80.1%
associate-/r/81.4%
Simplified81.4%
if -2.10000000000000008e79 < c < -8.6000000000000001e-138 or 3.89999999999999977e-159 < c < 2.79999999999999995e81Initial program 86.3%
if -8.6000000000000001e-138 < c < 3.89999999999999977e-159Initial program 65.3%
*-un-lft-identity65.3%
associate-*r/65.3%
fma-def65.3%
add-sqr-sqrt65.3%
times-frac65.3%
fma-def65.3%
hypot-def65.3%
fma-def65.3%
fma-def65.3%
hypot-def84.4%
Applied egg-rr84.4%
Taylor expanded in d around -inf 55.9%
neg-mul-155.9%
+-commutative55.9%
unsub-neg55.9%
mul-1-neg55.9%
associate-/l*54.6%
distribute-neg-frac54.6%
Simplified54.6%
Taylor expanded in d around -inf 92.2%
Final simplification86.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -6.4e+78)
(+ (/ a c) (* d (/ b (pow c 2.0))))
(if (<= c -8.2e-138)
t_0
(if (<= c 3.1e-158)
(* (+ b (/ a (/ d c))) (/ (- -1.0) d))
(if (<= c 1.2e+81) t_0 (/ (+ a (* d (/ b c))) (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 <= -6.4e+78) {
tmp = (a / c) + (d * (b / pow(c, 2.0)));
} else if (c <= -8.2e-138) {
tmp = t_0;
} else if (c <= 3.1e-158) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} else if (c <= 1.2e+81) {
tmp = t_0;
} else {
tmp = (a + (d * (b / c))) / 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 <= -6.4e+78) {
tmp = (a / c) + (d * (b / Math.pow(c, 2.0)));
} else if (c <= -8.2e-138) {
tmp = t_0;
} else if (c <= 3.1e-158) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} else if (c <= 1.2e+81) {
tmp = t_0;
} else {
tmp = (a + (d * (b / c))) / 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 <= -6.4e+78: tmp = (a / c) + (d * (b / math.pow(c, 2.0))) elif c <= -8.2e-138: tmp = t_0 elif c <= 3.1e-158: tmp = (b + (a / (d / c))) * (-(-1.0) / d) elif c <= 1.2e+81: tmp = t_0 else: tmp = (a + (d * (b / c))) / 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 <= -6.4e+78) tmp = Float64(Float64(a / c) + Float64(d * Float64(b / (c ^ 2.0)))); elseif (c <= -8.2e-138) tmp = t_0; elseif (c <= 3.1e-158) tmp = Float64(Float64(b + Float64(a / Float64(d / c))) * Float64(Float64(-(-1.0)) / d)); elseif (c <= 1.2e+81) tmp = t_0; 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) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -6.4e+78) tmp = (a / c) + (d * (b / (c ^ 2.0))); elseif (c <= -8.2e-138) tmp = t_0; elseif (c <= 3.1e-158) tmp = (b + (a / (d / c))) * (-(-1.0) / d); elseif (c <= 1.2e+81) tmp = t_0; else tmp = (a + (d * (b / c))) / 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, -6.4e+78], N[(N[(a / c), $MachinePrecision] + N[(d * N[(b / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -8.2e-138], t$95$0, If[LessEqual[c, 3.1e-158], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((--1.0) / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.2e+81], t$95$0, 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}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -6.4 \cdot 10^{+78}:\\
\;\;\;\;\frac{a}{c} + d \cdot \frac{b}{{c}^{2}}\\
\mathbf{elif}\;c \leq -8.2 \cdot 10^{-138}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.1 \cdot 10^{-158}:\\
\;\;\;\;\left(b + \frac{a}{\frac{d}{c}}\right) \cdot \frac{--1}{d}\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{+81}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a + d \cdot \frac{b}{c}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -6.39999999999999989e78Initial program 36.4%
Taylor expanded in c around inf 83.0%
associate-/l*83.4%
associate-/r/85.9%
Simplified85.9%
if -6.39999999999999989e78 < c < -8.19999999999999998e-138 or 3.10000000000000018e-158 < c < 1.19999999999999995e81Initial program 86.3%
if -8.19999999999999998e-138 < c < 3.10000000000000018e-158Initial program 65.3%
*-un-lft-identity65.3%
associate-*r/65.3%
fma-def65.3%
add-sqr-sqrt65.3%
times-frac65.3%
fma-def65.3%
hypot-def65.3%
fma-def65.3%
fma-def65.3%
hypot-def84.4%
Applied egg-rr84.4%
Taylor expanded in d around -inf 55.9%
neg-mul-155.9%
+-commutative55.9%
unsub-neg55.9%
mul-1-neg55.9%
associate-/l*54.6%
distribute-neg-frac54.6%
Simplified54.6%
Taylor expanded in d around -inf 92.2%
if 1.19999999999999995e81 < c Initial program 40.1%
*-un-lft-identity40.1%
associate-*r/40.1%
fma-def40.1%
add-sqr-sqrt40.1%
times-frac40.0%
fma-def40.0%
hypot-def40.0%
fma-def40.0%
fma-def40.0%
hypot-def59.4%
Applied egg-rr59.4%
associate-*l/59.5%
*-un-lft-identity59.5%
Applied egg-rr59.5%
Taylor expanded in c around inf 76.0%
associate-/l*88.0%
Simplified88.0%
associate-/r/88.1%
Applied egg-rr88.1%
Final simplification88.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -7.2e+78)
(/ (- (- a) (/ b (/ c d))) (hypot c d))
(if (<= c -8.5e-138)
t_0
(if (<= c 1.6e-158)
(* (+ b (/ a (/ d c))) (/ (- -1.0) d))
(if (<= c 1.6e+80) t_0 (/ (+ a (* d (/ b c))) (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 <= -7.2e+78) {
tmp = (-a - (b / (c / d))) / hypot(c, d);
} else if (c <= -8.5e-138) {
tmp = t_0;
} else if (c <= 1.6e-158) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} else if (c <= 1.6e+80) {
tmp = t_0;
} else {
tmp = (a + (d * (b / c))) / 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 <= -7.2e+78) {
tmp = (-a - (b / (c / d))) / Math.hypot(c, d);
} else if (c <= -8.5e-138) {
tmp = t_0;
} else if (c <= 1.6e-158) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} else if (c <= 1.6e+80) {
tmp = t_0;
} else {
tmp = (a + (d * (b / c))) / 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 <= -7.2e+78: tmp = (-a - (b / (c / d))) / math.hypot(c, d) elif c <= -8.5e-138: tmp = t_0 elif c <= 1.6e-158: tmp = (b + (a / (d / c))) * (-(-1.0) / d) elif c <= 1.6e+80: tmp = t_0 else: tmp = (a + (d * (b / c))) / 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 <= -7.2e+78) tmp = Float64(Float64(Float64(-a) - Float64(b / Float64(c / d))) / hypot(c, d)); elseif (c <= -8.5e-138) tmp = t_0; elseif (c <= 1.6e-158) tmp = Float64(Float64(b + Float64(a / Float64(d / c))) * Float64(Float64(-(-1.0)) / d)); elseif (c <= 1.6e+80) tmp = t_0; 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) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -7.2e+78) tmp = (-a - (b / (c / d))) / hypot(c, d); elseif (c <= -8.5e-138) tmp = t_0; elseif (c <= 1.6e-158) tmp = (b + (a / (d / c))) * (-(-1.0) / d); elseif (c <= 1.6e+80) tmp = t_0; else tmp = (a + (d * (b / c))) / 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, -7.2e+78], N[(N[((-a) - N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -8.5e-138], t$95$0, If[LessEqual[c, 1.6e-158], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((--1.0) / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.6e+80], t$95$0, 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}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -7.2 \cdot 10^{+78}:\\
\;\;\;\;\frac{\left(-a\right) - \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -8.5 \cdot 10^{-138}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.6 \cdot 10^{-158}:\\
\;\;\;\;\left(b + \frac{a}{\frac{d}{c}}\right) \cdot \frac{--1}{d}\\
\mathbf{elif}\;c \leq 1.6 \cdot 10^{+80}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a + d \cdot \frac{b}{c}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -7.20000000000000039e78Initial program 36.4%
*-un-lft-identity36.4%
associate-*r/36.4%
fma-def36.4%
add-sqr-sqrt36.4%
times-frac36.4%
fma-def36.4%
hypot-def36.4%
fma-def36.4%
fma-def36.4%
hypot-def46.4%
Applied egg-rr46.4%
associate-*l/46.4%
*-un-lft-identity46.4%
Applied egg-rr46.4%
Taylor expanded in c around -inf 85.3%
neg-mul-185.3%
mul-1-neg85.3%
unsub-neg85.3%
associate-/l*90.5%
Simplified90.5%
if -7.20000000000000039e78 < c < -8.50000000000000035e-138 or 1.59999999999999998e-158 < c < 1.59999999999999995e80Initial program 86.3%
if -8.50000000000000035e-138 < c < 1.59999999999999998e-158Initial program 65.3%
*-un-lft-identity65.3%
associate-*r/65.3%
fma-def65.3%
add-sqr-sqrt65.3%
times-frac65.3%
fma-def65.3%
hypot-def65.3%
fma-def65.3%
fma-def65.3%
hypot-def84.4%
Applied egg-rr84.4%
Taylor expanded in d around -inf 55.9%
neg-mul-155.9%
+-commutative55.9%
unsub-neg55.9%
mul-1-neg55.9%
associate-/l*54.6%
distribute-neg-frac54.6%
Simplified54.6%
Taylor expanded in d around -inf 92.2%
if 1.59999999999999995e80 < c Initial program 40.1%
*-un-lft-identity40.1%
associate-*r/40.1%
fma-def40.1%
add-sqr-sqrt40.1%
times-frac40.0%
fma-def40.0%
hypot-def40.0%
fma-def40.0%
fma-def40.0%
hypot-def59.4%
Applied egg-rr59.4%
associate-*l/59.5%
*-un-lft-identity59.5%
Applied egg-rr59.5%
Taylor expanded in c around inf 76.0%
associate-/l*88.0%
Simplified88.0%
associate-/r/88.1%
Applied egg-rr88.1%
Final simplification88.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -2.45e+129)
(/ (- a) (hypot c d))
(if (<= c -8.2e-138)
t_0
(if (<= c 3.7e-156)
(* (+ b (/ a (/ d c))) (/ (- -1.0) d))
(if (<= c 3e+81) 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.45e+129) {
tmp = -a / hypot(c, d);
} else if (c <= -8.2e-138) {
tmp = t_0;
} else if (c <= 3.7e-156) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} else if (c <= 3e+81) {
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.45e+129) {
tmp = -a / Math.hypot(c, d);
} else if (c <= -8.2e-138) {
tmp = t_0;
} else if (c <= 3.7e-156) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} else if (c <= 3e+81) {
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.45e+129: tmp = -a / math.hypot(c, d) elif c <= -8.2e-138: tmp = t_0 elif c <= 3.7e-156: tmp = (b + (a / (d / c))) * (-(-1.0) / d) elif c <= 3e+81: 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.45e+129) tmp = Float64(Float64(-a) / hypot(c, d)); elseif (c <= -8.2e-138) tmp = t_0; elseif (c <= 3.7e-156) tmp = Float64(Float64(b + Float64(a / Float64(d / c))) * Float64(Float64(-(-1.0)) / d)); elseif (c <= 3e+81) 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.45e+129) tmp = -a / hypot(c, d); elseif (c <= -8.2e-138) tmp = t_0; elseif (c <= 3.7e-156) tmp = (b + (a / (d / c))) * (-(-1.0) / d); elseif (c <= 3e+81) 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.45e+129], N[((-a) / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -8.2e-138], t$95$0, If[LessEqual[c, 3.7e-156], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((--1.0) / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3e+81], 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.45 \cdot 10^{+129}:\\
\;\;\;\;\frac{-a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -8.2 \cdot 10^{-138}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.7 \cdot 10^{-156}:\\
\;\;\;\;\left(b + \frac{a}{\frac{d}{c}}\right) \cdot \frac{--1}{d}\\
\mathbf{elif}\;c \leq 3 \cdot 10^{+81}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -2.45e129Initial program 33.9%
*-un-lft-identity33.9%
associate-*r/33.9%
fma-def33.9%
add-sqr-sqrt33.9%
times-frac33.9%
fma-def33.9%
hypot-def33.9%
fma-def33.9%
fma-def33.9%
hypot-def45.5%
Applied egg-rr45.5%
associate-*l/45.6%
*-un-lft-identity45.6%
Applied egg-rr45.6%
Taylor expanded in c around -inf 92.0%
neg-mul-192.0%
Simplified92.0%
if -2.45e129 < c < -8.19999999999999998e-138 or 3.7e-156 < c < 2.99999999999999997e81Initial program 84.2%
if -8.19999999999999998e-138 < c < 3.7e-156Initial program 65.3%
*-un-lft-identity65.3%
associate-*r/65.3%
fma-def65.3%
add-sqr-sqrt65.3%
times-frac65.3%
fma-def65.3%
hypot-def65.3%
fma-def65.3%
fma-def65.3%
hypot-def84.4%
Applied egg-rr84.4%
Taylor expanded in d around -inf 55.9%
neg-mul-155.9%
+-commutative55.9%
unsub-neg55.9%
mul-1-neg55.9%
associate-/l*54.6%
distribute-neg-frac54.6%
Simplified54.6%
Taylor expanded in d around -inf 92.2%
if 2.99999999999999997e81 < c Initial program 40.1%
Taylor expanded in c around inf 76.9%
Final simplification86.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -1.52e+129)
(/ a c)
(if (<= c -8.2e-138)
t_0
(if (<= c 1.45e-154)
(* (+ b (/ a (/ d c))) (/ (- -1.0) d))
(if (<= c 3e+81) 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 <= -1.52e+129) {
tmp = a / c;
} else if (c <= -8.2e-138) {
tmp = t_0;
} else if (c <= 1.45e-154) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} else if (c <= 3e+81) {
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 <= (-1.52d+129)) then
tmp = a / c
else if (c <= (-8.2d-138)) then
tmp = t_0
else if (c <= 1.45d-154) then
tmp = (b + (a / (d / c))) * (-(-1.0d0) / d)
else if (c <= 3d+81) 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 <= -1.52e+129) {
tmp = a / c;
} else if (c <= -8.2e-138) {
tmp = t_0;
} else if (c <= 1.45e-154) {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
} else if (c <= 3e+81) {
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 <= -1.52e+129: tmp = a / c elif c <= -8.2e-138: tmp = t_0 elif c <= 1.45e-154: tmp = (b + (a / (d / c))) * (-(-1.0) / d) elif c <= 3e+81: 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 <= -1.52e+129) tmp = Float64(a / c); elseif (c <= -8.2e-138) tmp = t_0; elseif (c <= 1.45e-154) tmp = Float64(Float64(b + Float64(a / Float64(d / c))) * Float64(Float64(-(-1.0)) / d)); elseif (c <= 3e+81) 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 <= -1.52e+129) tmp = a / c; elseif (c <= -8.2e-138) tmp = t_0; elseif (c <= 1.45e-154) tmp = (b + (a / (d / c))) * (-(-1.0) / d); elseif (c <= 3e+81) 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, -1.52e+129], N[(a / c), $MachinePrecision], If[LessEqual[c, -8.2e-138], t$95$0, If[LessEqual[c, 1.45e-154], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((--1.0) / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3e+81], 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 -1.52 \cdot 10^{+129}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq -8.2 \cdot 10^{-138}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-154}:\\
\;\;\;\;\left(b + \frac{a}{\frac{d}{c}}\right) \cdot \frac{--1}{d}\\
\mathbf{elif}\;c \leq 3 \cdot 10^{+81}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -1.51999999999999996e129 or 2.99999999999999997e81 < c Initial program 37.3%
Taylor expanded in c around inf 83.7%
if -1.51999999999999996e129 < c < -8.19999999999999998e-138 or 1.45e-154 < c < 2.99999999999999997e81Initial program 84.2%
if -8.19999999999999998e-138 < c < 1.45e-154Initial program 65.3%
*-un-lft-identity65.3%
associate-*r/65.3%
fma-def65.3%
add-sqr-sqrt65.3%
times-frac65.3%
fma-def65.3%
hypot-def65.3%
fma-def65.3%
fma-def65.3%
hypot-def84.4%
Applied egg-rr84.4%
Taylor expanded in d around -inf 55.9%
neg-mul-155.9%
+-commutative55.9%
unsub-neg55.9%
mul-1-neg55.9%
associate-/l*54.6%
distribute-neg-frac54.6%
Simplified54.6%
Taylor expanded in d around -inf 92.2%
Final simplification86.4%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.9e+51)
(/ a c)
(if (<= c 2.1e-78)
(/ b d)
(if (<= c 3e+81) (/ (* a c) (+ (* c c) (* d d))) (/ a c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.9e+51) {
tmp = a / c;
} else if (c <= 2.1e-78) {
tmp = b / d;
} else if (c <= 3e+81) {
tmp = (a * c) / ((c * c) + (d * 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 <= (-2.9d+51)) then
tmp = a / c
else if (c <= 2.1d-78) then
tmp = b / d
else if (c <= 3d+81) then
tmp = (a * c) / ((c * c) + (d * 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 <= -2.9e+51) {
tmp = a / c;
} else if (c <= 2.1e-78) {
tmp = b / d;
} else if (c <= 3e+81) {
tmp = (a * c) / ((c * c) + (d * d));
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.9e+51: tmp = a / c elif c <= 2.1e-78: tmp = b / d elif c <= 3e+81: tmp = (a * c) / ((c * c) + (d * d)) else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.9e+51) tmp = Float64(a / c); elseif (c <= 2.1e-78) tmp = Float64(b / d); elseif (c <= 3e+81) tmp = Float64(Float64(a * c) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.9e+51) tmp = a / c; elseif (c <= 2.1e-78) tmp = b / d; elseif (c <= 3e+81) tmp = (a * c) / ((c * c) + (d * d)); else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.9e+51], N[(a / c), $MachinePrecision], If[LessEqual[c, 2.1e-78], N[(b / d), $MachinePrecision], If[LessEqual[c, 3e+81], N[(N[(a * c), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.9 \cdot 10^{+51}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 2.1 \cdot 10^{-78}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 3 \cdot 10^{+81}:\\
\;\;\;\;\frac{a \cdot c}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -2.8999999999999998e51 or 2.99999999999999997e81 < c Initial program 43.8%
Taylor expanded in c around inf 78.7%
if -2.8999999999999998e51 < c < 2.1000000000000001e-78Initial program 75.2%
Taylor expanded in c around 0 66.6%
if 2.1000000000000001e-78 < c < 2.99999999999999997e81Initial program 80.1%
Taylor expanded in a around inf 61.6%
*-commutative61.6%
Simplified61.6%
Final simplification70.2%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.5e+51) (not (<= c 8.5e+79))) (/ a c) (* (+ b (/ a (/ d c))) (/ (- -1.0) d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.5e+51) || !(c <= 8.5e+79)) {
tmp = a / c;
} else {
tmp = (b + (a / (d / c))) * (-(-1.0) / 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 <= (-1.5d+51)) .or. (.not. (c <= 8.5d+79))) then
tmp = a / c
else
tmp = (b + (a / (d / c))) * (-(-1.0d0) / d)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.5e+51) || !(c <= 8.5e+79)) {
tmp = a / c;
} else {
tmp = (b + (a / (d / c))) * (-(-1.0) / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.5e+51) or not (c <= 8.5e+79): tmp = a / c else: tmp = (b + (a / (d / c))) * (-(-1.0) / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.5e+51) || !(c <= 8.5e+79)) tmp = Float64(a / c); else tmp = Float64(Float64(b + Float64(a / Float64(d / c))) * Float64(Float64(-(-1.0)) / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.5e+51) || ~((c <= 8.5e+79))) tmp = a / c; else tmp = (b + (a / (d / c))) * (-(-1.0) / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.5e+51], N[Not[LessEqual[c, 8.5e+79]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[((--1.0) / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.5 \cdot 10^{+51} \lor \neg \left(c \leq 8.5 \cdot 10^{+79}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\left(b + \frac{a}{\frac{d}{c}}\right) \cdot \frac{--1}{d}\\
\end{array}
\end{array}
if c < -1.5e51 or 8.4999999999999998e79 < c Initial program 43.8%
Taylor expanded in c around inf 78.7%
if -1.5e51 < c < 8.4999999999999998e79Initial program 76.2%
*-un-lft-identity76.2%
associate-*r/76.2%
fma-def76.2%
add-sqr-sqrt76.2%
times-frac76.1%
fma-def76.1%
hypot-def76.1%
fma-def76.1%
fma-def76.1%
hypot-def89.3%
Applied egg-rr89.3%
Taylor expanded in d around -inf 46.5%
neg-mul-146.5%
+-commutative46.5%
unsub-neg46.5%
mul-1-neg46.5%
associate-/l*46.4%
distribute-neg-frac46.4%
Simplified46.4%
Taylor expanded in d around -inf 76.5%
Final simplification77.3%
(FPCore (a b c d)
:precision binary64
(if (<= d -4.6e+77)
(/ b d)
(if (<= d -2.3e-153)
(/ (* b d) (+ (* c c) (* d d)))
(if (<= d 1.7e-33) (/ a c) (/ b d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.6e+77) {
tmp = b / d;
} else if (d <= -2.3e-153) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 1.7e-33) {
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 (d <= (-4.6d+77)) then
tmp = b / d
else if (d <= (-2.3d-153)) then
tmp = (b * d) / ((c * c) + (d * d))
else if (d <= 1.7d-33) 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 (d <= -4.6e+77) {
tmp = b / d;
} else if (d <= -2.3e-153) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 1.7e-33) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -4.6e+77: tmp = b / d elif d <= -2.3e-153: tmp = (b * d) / ((c * c) + (d * d)) elif d <= 1.7e-33: tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -4.6e+77) tmp = Float64(b / d); elseif (d <= -2.3e-153) tmp = Float64(Float64(b * d) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 1.7e-33) 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 (d <= -4.6e+77) tmp = b / d; elseif (d <= -2.3e-153) tmp = (b * d) / ((c * c) + (d * d)); elseif (d <= 1.7e-33) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.6e+77], N[(b / d), $MachinePrecision], If[LessEqual[d, -2.3e-153], N[(N[(b * d), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.7e-33], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -2.3 \cdot 10^{-153}:\\
\;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 1.7 \cdot 10^{-33}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -4.5999999999999999e77 or 1.7e-33 < d Initial program 55.4%
Taylor expanded in c around 0 70.5%
if -4.5999999999999999e77 < d < -2.29999999999999997e-153Initial program 89.2%
Taylor expanded in a around 0 60.3%
if -2.29999999999999997e-153 < d < 1.7e-33Initial program 65.3%
Taylor expanded in c around inf 73.9%
Final simplification69.9%
(FPCore (a b c d) :precision binary64 (if (or (<= c -4e+48) (not (<= c 1.75e+80))) (/ a c) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -4e+48) || !(c <= 1.75e+80)) {
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 <= (-4d+48)) .or. (.not. (c <= 1.75d+80))) 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 <= -4e+48) || !(c <= 1.75e+80)) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -4e+48) or not (c <= 1.75e+80): tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -4e+48) || !(c <= 1.75e+80)) 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 <= -4e+48) || ~((c <= 1.75e+80))) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -4e+48], N[Not[LessEqual[c, 1.75e+80]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4 \cdot 10^{+48} \lor \neg \left(c \leq 1.75 \cdot 10^{+80}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -4.00000000000000018e48 or 1.74999999999999997e80 < c Initial program 43.8%
Taylor expanded in c around inf 78.7%
if -4.00000000000000018e48 < c < 1.74999999999999997e80Initial program 76.2%
Taylor expanded in c around 0 62.7%
Final simplification68.2%
(FPCore (a b c d) :precision binary64 (if (<= d 3.6e+179) (/ a c) (/ a d)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= 3.6e+179) {
tmp = a / c;
} else {
tmp = a / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= 3.6d+179) then
tmp = a / c
else
tmp = a / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= 3.6e+179) {
tmp = a / c;
} else {
tmp = a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= 3.6e+179: tmp = a / c else: tmp = a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= 3.6e+179) tmp = Float64(a / c); else tmp = Float64(a / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= 3.6e+179) tmp = a / c; else tmp = a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, 3.6e+179], N[(a / c), $MachinePrecision], N[(a / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq 3.6 \cdot 10^{+179}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\end{array}
if d < 3.5999999999999998e179Initial program 66.3%
Taylor expanded in c around inf 45.7%
if 3.5999999999999998e179 < d Initial program 51.4%
*-un-lft-identity51.4%
associate-*r/51.4%
fma-def51.4%
add-sqr-sqrt51.4%
times-frac51.4%
fma-def51.4%
hypot-def51.4%
fma-def51.4%
fma-def51.4%
hypot-def67.5%
Applied egg-rr67.5%
Taylor expanded in d around -inf 51.9%
neg-mul-151.9%
+-commutative51.9%
unsub-neg51.9%
mul-1-neg51.9%
associate-/l*52.0%
distribute-neg-frac52.0%
Simplified52.0%
Taylor expanded in c around -inf 44.0%
Final simplification45.5%
(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 64.9%
Taylor expanded in c around inf 42.4%
Final simplification42.4%
(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 2024019
(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))))