
(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 (/ d c))) (t_1 (* (fma c a (* b d)) (pow (hypot c d) -2.0))))
(if (<= d -7.6e+128)
(/ (- (- b) t_0) (hypot c d))
(if (<= d -5e+75)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= d -2.05e+51)
(/ b d)
(if (<= d -1.9e-97)
t_1
(if (<= d 8e-88)
(/ (fma b (/ d c) a) c)
(if (<= d 2.1e+100) t_1 (/ (+ b t_0) (hypot c d))))))))))
double code(double a, double b, double c, double d) {
double t_0 = a / (d / c);
double t_1 = fma(c, a, (b * d)) * pow(hypot(c, d), -2.0);
double tmp;
if (d <= -7.6e+128) {
tmp = (-b - t_0) / hypot(c, d);
} else if (d <= -5e+75) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= -2.05e+51) {
tmp = b / d;
} else if (d <= -1.9e-97) {
tmp = t_1;
} else if (d <= 8e-88) {
tmp = fma(b, (d / c), a) / c;
} else if (d <= 2.1e+100) {
tmp = t_1;
} else {
tmp = (b + t_0) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(a / Float64(d / c)) t_1 = Float64(fma(c, a, Float64(b * d)) * (hypot(c, d) ^ -2.0)) tmp = 0.0 if (d <= -7.6e+128) tmp = Float64(Float64(Float64(-b) - t_0) / hypot(c, d)); elseif (d <= -5e+75) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (d <= -2.05e+51) tmp = Float64(b / d); elseif (d <= -1.9e-97) tmp = t_1; elseif (d <= 8e-88) tmp = Float64(fma(b, Float64(d / c), a) / c); elseif (d <= 2.1e+100) tmp = t_1; else tmp = Float64(Float64(b + t_0) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * a + N[(b * d), $MachinePrecision]), $MachinePrecision] * N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.6e+128], N[(N[((-b) - t$95$0), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e+75], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.05e+51], N[(b / d), $MachinePrecision], If[LessEqual[d, -1.9e-97], t$95$1, If[LessEqual[d, 8e-88], N[(N[(b * N[(d / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.1e+100], t$95$1, N[(N[(b + t$95$0), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{\frac{d}{c}}\\
t_1 := \mathsf{fma}\left(c, a, b \cdot d\right) \cdot {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\\
\mathbf{if}\;d \leq -7.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{+75}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq -2.05 \cdot 10^{+51}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -1.9 \cdot 10^{-97}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 8 \cdot 10^{-88}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\
\mathbf{elif}\;d \leq 2.1 \cdot 10^{+100}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{b + t_0}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -7.5999999999999998e128Initial program 25.4%
*-un-lft-identity25.4%
add-sqr-sqrt25.4%
times-frac25.4%
hypot-def25.4%
fma-def25.4%
hypot-def55.3%
Applied egg-rr55.3%
associate-*l/55.3%
*-un-lft-identity55.3%
Applied egg-rr55.3%
Taylor expanded in d around -inf 74.2%
mul-1-neg74.2%
unsub-neg74.2%
mul-1-neg74.2%
associate-/l*88.3%
Simplified88.3%
if -7.5999999999999998e128 < d < -5.0000000000000002e75Initial program 16.3%
*-un-lft-identity16.3%
add-sqr-sqrt16.3%
times-frac16.3%
hypot-def16.3%
fma-def16.3%
hypot-def30.8%
Applied egg-rr30.8%
Taylor expanded in c around inf 44.2%
associate-/l*44.4%
Simplified44.4%
Taylor expanded in c around inf 85.8%
distribute-rgt-in85.8%
un-div-inv86.3%
associate-/r/86.3%
associate-*l*86.3%
div-inv86.5%
Applied egg-rr86.5%
if -5.0000000000000002e75 < d < -2.05000000000000005e51Initial program 67.0%
Taylor expanded in c around 0 84.4%
if -2.05000000000000005e51 < d < -1.9e-97 or 7.99999999999999947e-88 < d < 2.0999999999999999e100Initial program 77.8%
*-un-lft-identity77.8%
add-sqr-sqrt77.7%
times-frac77.8%
hypot-def77.8%
fma-def77.8%
hypot-def84.4%
Applied egg-rr84.4%
expm1-log1p-u58.5%
expm1-udef29.5%
frac-times29.4%
*-un-lft-identity29.4%
pow229.4%
Applied egg-rr29.4%
expm1-def52.1%
expm1-log1p77.7%
*-rgt-identity77.7%
unpow277.7%
/-rgt-identity77.7%
times-frac84.4%
*-rgt-identity84.4%
associate-*r/84.3%
/-rgt-identity84.3%
associate-*l*78.9%
fma-udef78.9%
*-commutative78.9%
fma-def78.9%
unpow-178.9%
unpow-178.9%
pow-sqr79.0%
metadata-eval79.0%
Simplified79.0%
if -1.9e-97 < d < 7.99999999999999947e-88Initial program 73.5%
*-un-lft-identity73.5%
add-sqr-sqrt73.5%
times-frac73.6%
hypot-def73.6%
fma-def73.6%
hypot-def87.0%
Applied egg-rr87.0%
Taylor expanded in c around inf 53.0%
associate-/l*52.9%
Simplified52.9%
Taylor expanded in c around inf 95.1%
expm1-log1p-u64.3%
expm1-udef37.3%
associate-*l/37.3%
*-un-lft-identity37.3%
+-commutative37.3%
div-inv37.3%
clear-num37.3%
fma-def37.3%
Applied egg-rr37.3%
expm1-def64.4%
expm1-log1p95.4%
Simplified95.4%
if 2.0999999999999999e100 < d Initial program 35.4%
*-un-lft-identity35.4%
add-sqr-sqrt35.4%
times-frac35.3%
hypot-def35.3%
fma-def35.3%
hypot-def44.3%
Applied egg-rr44.3%
associate-*l/44.5%
*-un-lft-identity44.5%
Applied egg-rr44.5%
Taylor expanded in c around 0 86.2%
associate-/l*97.3%
Simplified97.3%
Final simplification89.1%
(FPCore (a b c d) :precision binary64 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) 5e+293) (/ (/ (fma a c (* b d)) (hypot c d)) (hypot c d)) (* (/ -1.0 d) (- (- b) (/ a (/ d c))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= 5e+293) {
tmp = (fma(a, c, (b * d)) / hypot(c, d)) / hypot(c, d);
} else {
tmp = (-1.0 / d) * (-b - (a / (d / c)));
}
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))) <= 5e+293) tmp = Float64(Float64(fma(a, c, Float64(b * d)) / hypot(c, d)) / hypot(c, d)); else tmp = Float64(Float64(-1.0 / d) * Float64(Float64(-b) - Float64(a / Float64(d / c)))); 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], 5e+293], N[(N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / d), $MachinePrecision] * N[((-b) - N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq 5 \cdot 10^{+293}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{d} \cdot \left(\left(-b\right) - \frac{a}{\frac{d}{c}}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5.00000000000000033e293Initial program 78.3%
*-un-lft-identity78.3%
add-sqr-sqrt78.3%
times-frac78.3%
hypot-def78.3%
fma-def78.3%
hypot-def95.4%
Applied egg-rr95.4%
associate-*l/95.7%
*-un-lft-identity95.7%
Applied egg-rr95.7%
if 5.00000000000000033e293 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 9.1%
*-un-lft-identity9.1%
add-sqr-sqrt9.1%
times-frac9.1%
hypot-def9.1%
fma-def9.1%
hypot-def13.8%
Applied egg-rr13.8%
Taylor expanded in d around -inf 25.1%
mul-1-neg25.2%
unsub-neg25.2%
mul-1-neg25.2%
associate-/l*33.4%
Simplified33.4%
Taylor expanded in d around -inf 64.0%
Final simplification86.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ a (/ d c)))
(t_1 (* (/ -1.0 d) (- (- b) t_0)))
(t_2 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -6.2e+143)
t_1
(if (<= d -1.55e+81)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= d -3.8e+29)
t_1
(if (<= d -1.72e-97)
t_2
(if (<= d 3.9e-82)
(/ (fma b (/ d c) a) c)
(if (<= d 4.1e+100) t_2 (/ (+ b t_0) (hypot c d))))))))))
double code(double a, double b, double c, double d) {
double t_0 = a / (d / c);
double t_1 = (-1.0 / d) * (-b - t_0);
double t_2 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -6.2e+143) {
tmp = t_1;
} else if (d <= -1.55e+81) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= -3.8e+29) {
tmp = t_1;
} else if (d <= -1.72e-97) {
tmp = t_2;
} else if (d <= 3.9e-82) {
tmp = fma(b, (d / c), a) / c;
} else if (d <= 4.1e+100) {
tmp = t_2;
} else {
tmp = (b + t_0) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(a / Float64(d / c)) t_1 = Float64(Float64(-1.0 / d) * Float64(Float64(-b) - t_0)) t_2 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -6.2e+143) tmp = t_1; elseif (d <= -1.55e+81) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (d <= -3.8e+29) tmp = t_1; elseif (d <= -1.72e-97) tmp = t_2; elseif (d <= 3.9e-82) tmp = Float64(fma(b, Float64(d / c), a) / c); elseif (d <= 4.1e+100) tmp = t_2; else tmp = Float64(Float64(b + t_0) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-1.0 / d), $MachinePrecision] * N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6.2e+143], t$95$1, If[LessEqual[d, -1.55e+81], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.8e+29], t$95$1, If[LessEqual[d, -1.72e-97], t$95$2, If[LessEqual[d, 3.9e-82], N[(N[(b * N[(d / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.1e+100], t$95$2, N[(N[(b + t$95$0), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{\frac{d}{c}}\\
t_1 := \frac{-1}{d} \cdot \left(\left(-b\right) - t_0\right)\\
t_2 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -6.2 \cdot 10^{+143}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -1.55 \cdot 10^{+81}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq -3.8 \cdot 10^{+29}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -1.72 \cdot 10^{-97}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d \leq 3.9 \cdot 10^{-82}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\
\mathbf{elif}\;d \leq 4.1 \cdot 10^{+100}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{b + t_0}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -6.1999999999999998e143 or -1.55e81 < d < -3.79999999999999971e29Initial program 31.9%
*-un-lft-identity31.9%
add-sqr-sqrt31.9%
times-frac32.0%
hypot-def32.0%
fma-def32.0%
hypot-def55.9%
Applied egg-rr55.9%
Taylor expanded in d around -inf 78.2%
mul-1-neg78.2%
unsub-neg78.2%
mul-1-neg78.2%
associate-/l*89.3%
Simplified89.3%
Taylor expanded in d around -inf 89.2%
if -6.1999999999999998e143 < d < -1.55e81Initial program 22.4%
*-un-lft-identity22.4%
add-sqr-sqrt22.4%
times-frac22.4%
hypot-def22.4%
fma-def22.4%
hypot-def46.9%
Applied egg-rr46.9%
Taylor expanded in c around inf 39.1%
associate-/l*39.3%
Simplified39.3%
Taylor expanded in c around inf 73.5%
distribute-rgt-in73.5%
un-div-inv74.1%
associate-/r/74.1%
associate-*l*74.1%
div-inv74.2%
Applied egg-rr74.2%
if -3.79999999999999971e29 < d < -1.71999999999999995e-97 or 3.89999999999999973e-82 < d < 4.1000000000000003e100Initial program 77.7%
if -1.71999999999999995e-97 < d < 3.89999999999999973e-82Initial program 74.1%
*-un-lft-identity74.1%
add-sqr-sqrt74.1%
times-frac74.1%
hypot-def74.2%
fma-def74.2%
hypot-def87.2%
Applied egg-rr87.2%
Taylor expanded in c around inf 54.0%
associate-/l*53.9%
Simplified53.9%
Taylor expanded in c around inf 95.2%
expm1-log1p-u65.1%
expm1-udef36.5%
associate-*l/36.5%
*-un-lft-identity36.5%
+-commutative36.5%
div-inv36.5%
clear-num36.5%
fma-def36.5%
Applied egg-rr36.5%
expm1-def65.2%
expm1-log1p95.5%
Simplified95.5%
if 4.1000000000000003e100 < d Initial program 35.4%
*-un-lft-identity35.4%
add-sqr-sqrt35.4%
times-frac35.3%
hypot-def35.3%
fma-def35.3%
hypot-def44.3%
Applied egg-rr44.3%
associate-*l/44.5%
*-un-lft-identity44.5%
Applied egg-rr44.5%
Taylor expanded in c around 0 86.2%
associate-/l*97.3%
Simplified97.3%
Final simplification88.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (/ a (/ d c)))
(t_2 (- (- b) t_1)))
(if (<= d -7.6e+128)
(/ t_2 (hypot c d))
(if (<= d -1.95e+81)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= d -3.8e+29)
(* (/ -1.0 d) t_2)
(if (<= d -1.7e-97)
t_0
(if (<= d 1.4e-80)
(/ (fma b (/ d c) a) c)
(if (<= d 2.7e+100) t_0 (/ (+ b 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 = a / (d / c);
double t_2 = -b - t_1;
double tmp;
if (d <= -7.6e+128) {
tmp = t_2 / hypot(c, d);
} else if (d <= -1.95e+81) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= -3.8e+29) {
tmp = (-1.0 / d) * t_2;
} else if (d <= -1.7e-97) {
tmp = t_0;
} else if (d <= 1.4e-80) {
tmp = fma(b, (d / c), a) / c;
} else if (d <= 2.7e+100) {
tmp = t_0;
} else {
tmp = (b + t_1) / 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(a / Float64(d / c)) t_2 = Float64(Float64(-b) - t_1) tmp = 0.0 if (d <= -7.6e+128) tmp = Float64(t_2 / hypot(c, d)); elseif (d <= -1.95e+81) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (d <= -3.8e+29) tmp = Float64(Float64(-1.0 / d) * t_2); elseif (d <= -1.7e-97) tmp = t_0; elseif (d <= 1.4e-80) tmp = Float64(fma(b, Float64(d / c), a) / c); elseif (d <= 2.7e+100) tmp = t_0; else tmp = Float64(Float64(b + t_1) / hypot(c, d)); end return 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[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[((-b) - t$95$1), $MachinePrecision]}, If[LessEqual[d, -7.6e+128], N[(t$95$2 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.95e+81], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.8e+29], N[(N[(-1.0 / d), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[d, -1.7e-97], t$95$0, If[LessEqual[d, 1.4e-80], N[(N[(b * N[(d / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.7e+100], t$95$0, N[(N[(b + 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{a}{\frac{d}{c}}\\
t_2 := \left(-b\right) - t_1\\
\mathbf{if}\;d \leq -7.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{t_2}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1.95 \cdot 10^{+81}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq -3.8 \cdot 10^{+29}:\\
\;\;\;\;\frac{-1}{d} \cdot t_2\\
\mathbf{elif}\;d \leq -1.7 \cdot 10^{-97}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.4 \cdot 10^{-80}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{+100}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b + t_1}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -7.5999999999999998e128Initial program 25.4%
*-un-lft-identity25.4%
add-sqr-sqrt25.4%
times-frac25.4%
hypot-def25.4%
fma-def25.4%
hypot-def55.3%
Applied egg-rr55.3%
associate-*l/55.3%
*-un-lft-identity55.3%
Applied egg-rr55.3%
Taylor expanded in d around -inf 74.2%
mul-1-neg74.2%
unsub-neg74.2%
mul-1-neg74.2%
associate-/l*88.3%
Simplified88.3%
if -7.5999999999999998e128 < d < -1.95e81Initial program 16.3%
*-un-lft-identity16.3%
add-sqr-sqrt16.3%
times-frac16.3%
hypot-def16.3%
fma-def16.3%
hypot-def30.8%
Applied egg-rr30.8%
Taylor expanded in c around inf 44.2%
associate-/l*44.4%
Simplified44.4%
Taylor expanded in c around inf 85.8%
distribute-rgt-in85.8%
un-div-inv86.3%
associate-/r/86.3%
associate-*l*86.3%
div-inv86.5%
Applied egg-rr86.5%
if -1.95e81 < d < -3.79999999999999971e29Initial program 66.7%
*-un-lft-identity66.7%
add-sqr-sqrt66.7%
times-frac67.3%
hypot-def67.3%
fma-def67.3%
hypot-def67.9%
Applied egg-rr67.9%
Taylor expanded in d around -inf 78.4%
mul-1-neg78.4%
unsub-neg78.4%
mul-1-neg78.4%
associate-/l*78.4%
Simplified78.4%
Taylor expanded in d around -inf 78.4%
if -3.79999999999999971e29 < d < -1.6999999999999999e-97 or 1.39999999999999995e-80 < d < 2.69999999999999998e100Initial program 77.7%
if -1.6999999999999999e-97 < d < 1.39999999999999995e-80Initial program 74.1%
*-un-lft-identity74.1%
add-sqr-sqrt74.1%
times-frac74.1%
hypot-def74.2%
fma-def74.2%
hypot-def87.2%
Applied egg-rr87.2%
Taylor expanded in c around inf 54.0%
associate-/l*53.9%
Simplified53.9%
Taylor expanded in c around inf 95.2%
expm1-log1p-u65.1%
expm1-udef36.5%
associate-*l/36.5%
*-un-lft-identity36.5%
+-commutative36.5%
div-inv36.5%
clear-num36.5%
fma-def36.5%
Applied egg-rr36.5%
expm1-def65.2%
expm1-log1p95.5%
Simplified95.5%
if 2.69999999999999998e100 < d Initial program 35.4%
*-un-lft-identity35.4%
add-sqr-sqrt35.4%
times-frac35.3%
hypot-def35.3%
fma-def35.3%
hypot-def44.3%
Applied egg-rr44.3%
associate-*l/44.5%
*-un-lft-identity44.5%
Applied egg-rr44.5%
Taylor expanded in c around 0 86.2%
associate-/l*97.3%
Simplified97.3%
Final simplification88.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ -1.0 d) (- (- b) (/ a (/ d c)))))
(t_1 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -5.2e+143)
t_0
(if (<= d -1.2e+81)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= d -2.95e+29)
t_0
(if (<= d -1.72e-97)
t_1
(if (<= d 1.4e-81)
(/ (fma b (/ d c) a) c)
(if (<= d 2.8e+101) t_1 t_0))))))))
double code(double a, double b, double c, double d) {
double t_0 = (-1.0 / d) * (-b - (a / (d / c)));
double t_1 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -5.2e+143) {
tmp = t_0;
} else if (d <= -1.2e+81) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= -2.95e+29) {
tmp = t_0;
} else if (d <= -1.72e-97) {
tmp = t_1;
} else if (d <= 1.4e-81) {
tmp = fma(b, (d / c), a) / c;
} else if (d <= 2.8e+101) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-1.0 / d) * Float64(Float64(-b) - Float64(a / Float64(d / c)))) t_1 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -5.2e+143) tmp = t_0; elseif (d <= -1.2e+81) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (d <= -2.95e+29) tmp = t_0; elseif (d <= -1.72e-97) tmp = t_1; elseif (d <= 1.4e-81) tmp = Float64(fma(b, Float64(d / c), a) / c); elseif (d <= 2.8e+101) tmp = t_1; else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(-1.0 / d), $MachinePrecision] * N[((-b) - N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.2e+143], t$95$0, If[LessEqual[d, -1.2e+81], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.95e+29], t$95$0, If[LessEqual[d, -1.72e-97], t$95$1, If[LessEqual[d, 1.4e-81], N[(N[(b * N[(d / c), $MachinePrecision] + a), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.8e+101], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-1}{d} \cdot \left(\left(-b\right) - \frac{a}{\frac{d}{c}}\right)\\
t_1 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -5.2 \cdot 10^{+143}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -1.2 \cdot 10^{+81}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq -2.95 \cdot 10^{+29}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -1.72 \cdot 10^{-97}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 1.4 \cdot 10^{-81}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{d}{c}, a\right)}{c}\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{+101}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -5.1999999999999998e143 or -1.19999999999999995e81 < d < -2.9499999999999999e29 or 2.79999999999999981e101 < d Initial program 33.3%
*-un-lft-identity33.3%
add-sqr-sqrt33.3%
times-frac33.3%
hypot-def33.3%
fma-def33.3%
hypot-def51.3%
Applied egg-rr51.3%
Taylor expanded in d around -inf 52.7%
mul-1-neg52.7%
unsub-neg52.7%
mul-1-neg52.7%
associate-/l*59.5%
Simplified59.4%
Taylor expanded in d around -inf 92.2%
if -5.1999999999999998e143 < d < -1.19999999999999995e81Initial program 22.4%
*-un-lft-identity22.4%
add-sqr-sqrt22.4%
times-frac22.4%
hypot-def22.4%
fma-def22.4%
hypot-def46.9%
Applied egg-rr46.9%
Taylor expanded in c around inf 39.1%
associate-/l*39.3%
Simplified39.3%
Taylor expanded in c around inf 73.5%
distribute-rgt-in73.5%
un-div-inv74.1%
associate-/r/74.1%
associate-*l*74.1%
div-inv74.2%
Applied egg-rr74.2%
if -2.9499999999999999e29 < d < -1.71999999999999995e-97 or 1.3999999999999999e-81 < d < 2.79999999999999981e101Initial program 77.7%
if -1.71999999999999995e-97 < d < 1.3999999999999999e-81Initial program 74.1%
*-un-lft-identity74.1%
add-sqr-sqrt74.1%
times-frac74.1%
hypot-def74.2%
fma-def74.2%
hypot-def87.2%
Applied egg-rr87.2%
Taylor expanded in c around inf 54.0%
associate-/l*53.9%
Simplified53.9%
Taylor expanded in c around inf 95.2%
expm1-log1p-u65.1%
expm1-udef36.5%
associate-*l/36.5%
*-un-lft-identity36.5%
+-commutative36.5%
div-inv36.5%
clear-num36.5%
fma-def36.5%
Applied egg-rr36.5%
expm1-def65.2%
expm1-log1p95.5%
Simplified95.5%
Final simplification88.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ -1.0 d) (- (- b) (/ a (/ d c)))))
(t_1 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -5.2e+143)
t_0
(if (<= d -1.95e+81)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= d -1e+29)
t_0
(if (<= d -1.9e-97)
t_1
(if (<= d 9.6e-88)
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (<= d 3.9e+100) t_1 t_0))))))))
double code(double a, double b, double c, double d) {
double t_0 = (-1.0 / d) * (-b - (a / (d / c)));
double t_1 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -5.2e+143) {
tmp = t_0;
} else if (d <= -1.95e+81) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= -1e+29) {
tmp = t_0;
} else if (d <= -1.9e-97) {
tmp = t_1;
} else if (d <= 9.6e-88) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (d <= 3.9e+100) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((-1.0d0) / d) * (-b - (a / (d / c)))
t_1 = ((a * c) + (b * d)) / ((c * c) + (d * d))
if (d <= (-5.2d+143)) then
tmp = t_0
else if (d <= (-1.95d+81)) then
tmp = (a / c) + ((d / c) * (b / c))
else if (d <= (-1d+29)) then
tmp = t_0
else if (d <= (-1.9d-97)) then
tmp = t_1
else if (d <= 9.6d-88) then
tmp = (1.0d0 / c) * (a + (b / (c / d)))
else if (d <= 3.9d+100) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (-1.0 / d) * (-b - (a / (d / c)));
double t_1 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -5.2e+143) {
tmp = t_0;
} else if (d <= -1.95e+81) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= -1e+29) {
tmp = t_0;
} else if (d <= -1.9e-97) {
tmp = t_1;
} else if (d <= 9.6e-88) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (d <= 3.9e+100) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (-1.0 / d) * (-b - (a / (d / c))) t_1 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -5.2e+143: tmp = t_0 elif d <= -1.95e+81: tmp = (a / c) + ((d / c) * (b / c)) elif d <= -1e+29: tmp = t_0 elif d <= -1.9e-97: tmp = t_1 elif d <= 9.6e-88: tmp = (1.0 / c) * (a + (b / (c / d))) elif d <= 3.9e+100: tmp = t_1 else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-1.0 / d) * Float64(Float64(-b) - Float64(a / Float64(d / c)))) t_1 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -5.2e+143) tmp = t_0; elseif (d <= -1.95e+81) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (d <= -1e+29) tmp = t_0; elseif (d <= -1.9e-97) tmp = t_1; elseif (d <= 9.6e-88) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif (d <= 3.9e+100) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (-1.0 / d) * (-b - (a / (d / c))); t_1 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -5.2e+143) tmp = t_0; elseif (d <= -1.95e+81) tmp = (a / c) + ((d / c) * (b / c)); elseif (d <= -1e+29) tmp = t_0; elseif (d <= -1.9e-97) tmp = t_1; elseif (d <= 9.6e-88) tmp = (1.0 / c) * (a + (b / (c / d))); elseif (d <= 3.9e+100) tmp = t_1; else tmp = t_0; 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[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.2e+143], t$95$0, If[LessEqual[d, -1.95e+81], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1e+29], t$95$0, If[LessEqual[d, -1.9e-97], t$95$1, If[LessEqual[d, 9.6e-88], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.9e+100], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-1}{d} \cdot \left(\left(-b\right) - \frac{a}{\frac{d}{c}}\right)\\
t_1 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -5.2 \cdot 10^{+143}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -1.95 \cdot 10^{+81}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq -1 \cdot 10^{+29}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -1.9 \cdot 10^{-97}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 9.6 \cdot 10^{-88}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 3.9 \cdot 10^{+100}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -5.1999999999999998e143 or -1.95e81 < d < -9.99999999999999914e28 or 3.9e100 < d Initial program 33.3%
*-un-lft-identity33.3%
add-sqr-sqrt33.3%
times-frac33.3%
hypot-def33.3%
fma-def33.3%
hypot-def51.3%
Applied egg-rr51.3%
Taylor expanded in d around -inf 52.7%
mul-1-neg52.7%
unsub-neg52.7%
mul-1-neg52.7%
associate-/l*59.5%
Simplified59.4%
Taylor expanded in d around -inf 92.2%
if -5.1999999999999998e143 < d < -1.95e81Initial program 22.4%
*-un-lft-identity22.4%
add-sqr-sqrt22.4%
times-frac22.4%
hypot-def22.4%
fma-def22.4%
hypot-def46.9%
Applied egg-rr46.9%
Taylor expanded in c around inf 39.1%
associate-/l*39.3%
Simplified39.3%
Taylor expanded in c around inf 73.5%
distribute-rgt-in73.5%
un-div-inv74.1%
associate-/r/74.1%
associate-*l*74.1%
div-inv74.2%
Applied egg-rr74.2%
if -9.99999999999999914e28 < d < -1.9e-97 or 9.5999999999999998e-88 < d < 3.9e100Initial program 78.3%
if -1.9e-97 < d < 9.5999999999999998e-88Initial program 73.5%
*-un-lft-identity73.5%
add-sqr-sqrt73.5%
times-frac73.6%
hypot-def73.6%
fma-def73.6%
hypot-def87.0%
Applied egg-rr87.0%
Taylor expanded in c around inf 53.0%
associate-/l*52.9%
Simplified52.9%
Taylor expanded in c around inf 95.1%
Final simplification88.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ -1.0 d) (- (- b) (/ a (/ d c))))))
(if (<= d -6.2e+143)
t_0
(if (<= d -1.95e+81)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= d -9e+29)
t_0
(if (<= d 9e-71)
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (<= d 2.8e-13)
(/ (* b d) (+ (* c c) (* d d)))
(if (<= d 1.7e+14) (* (/ 1.0 c) (+ a (* d (/ b c)))) t_0))))))))
double code(double a, double b, double c, double d) {
double t_0 = (-1.0 / d) * (-b - (a / (d / c)));
double tmp;
if (d <= -6.2e+143) {
tmp = t_0;
} else if (d <= -1.95e+81) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= -9e+29) {
tmp = t_0;
} else if (d <= 9e-71) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (d <= 2.8e-13) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 1.7e+14) {
tmp = (1.0 / c) * (a + (d * (b / c)));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = ((-1.0d0) / d) * (-b - (a / (d / c)))
if (d <= (-6.2d+143)) then
tmp = t_0
else if (d <= (-1.95d+81)) then
tmp = (a / c) + ((d / c) * (b / c))
else if (d <= (-9d+29)) then
tmp = t_0
else if (d <= 9d-71) then
tmp = (1.0d0 / c) * (a + (b / (c / d)))
else if (d <= 2.8d-13) then
tmp = (b * d) / ((c * c) + (d * d))
else if (d <= 1.7d+14) then
tmp = (1.0d0 / c) * (a + (d * (b / c)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (-1.0 / d) * (-b - (a / (d / c)));
double tmp;
if (d <= -6.2e+143) {
tmp = t_0;
} else if (d <= -1.95e+81) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= -9e+29) {
tmp = t_0;
} else if (d <= 9e-71) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (d <= 2.8e-13) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 1.7e+14) {
tmp = (1.0 / c) * (a + (d * (b / c)));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (-1.0 / d) * (-b - (a / (d / c))) tmp = 0 if d <= -6.2e+143: tmp = t_0 elif d <= -1.95e+81: tmp = (a / c) + ((d / c) * (b / c)) elif d <= -9e+29: tmp = t_0 elif d <= 9e-71: tmp = (1.0 / c) * (a + (b / (c / d))) elif d <= 2.8e-13: tmp = (b * d) / ((c * c) + (d * d)) elif d <= 1.7e+14: tmp = (1.0 / c) * (a + (d * (b / c))) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-1.0 / d) * Float64(Float64(-b) - Float64(a / Float64(d / c)))) tmp = 0.0 if (d <= -6.2e+143) tmp = t_0; elseif (d <= -1.95e+81) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (d <= -9e+29) tmp = t_0; elseif (d <= 9e-71) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif (d <= 2.8e-13) tmp = Float64(Float64(b * d) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 1.7e+14) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(d * Float64(b / c)))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (-1.0 / d) * (-b - (a / (d / c))); tmp = 0.0; if (d <= -6.2e+143) tmp = t_0; elseif (d <= -1.95e+81) tmp = (a / c) + ((d / c) * (b / c)); elseif (d <= -9e+29) tmp = t_0; elseif (d <= 9e-71) tmp = (1.0 / c) * (a + (b / (c / d))); elseif (d <= 2.8e-13) tmp = (b * d) / ((c * c) + (d * d)); elseif (d <= 1.7e+14) tmp = (1.0 / c) * (a + (d * (b / c))); else tmp = t_0; 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[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6.2e+143], t$95$0, If[LessEqual[d, -1.95e+81], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -9e+29], t$95$0, If[LessEqual[d, 9e-71], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.8e-13], N[(N[(b * d), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.7e+14], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-1}{d} \cdot \left(\left(-b\right) - \frac{a}{\frac{d}{c}}\right)\\
\mathbf{if}\;d \leq -6.2 \cdot 10^{+143}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -1.95 \cdot 10^{+81}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq -9 \cdot 10^{+29}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 9 \cdot 10^{-71}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{-13}:\\
\;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 1.7 \cdot 10^{+14}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -6.1999999999999998e143 or -1.95e81 < d < -9.0000000000000005e29 or 1.7e14 < d Initial program 39.8%
*-un-lft-identity39.8%
add-sqr-sqrt39.8%
times-frac39.9%
hypot-def39.9%
fma-def39.9%
hypot-def55.3%
Applied egg-rr55.3%
Taylor expanded in d around -inf 43.0%
mul-1-neg43.0%
unsub-neg43.0%
mul-1-neg43.0%
associate-/l*48.4%
Simplified48.4%
Taylor expanded in d around -inf 85.3%
if -6.1999999999999998e143 < d < -1.95e81Initial program 22.4%
*-un-lft-identity22.4%
add-sqr-sqrt22.4%
times-frac22.4%
hypot-def22.4%
fma-def22.4%
hypot-def46.9%
Applied egg-rr46.9%
Taylor expanded in c around inf 39.1%
associate-/l*39.3%
Simplified39.3%
Taylor expanded in c around inf 73.5%
distribute-rgt-in73.5%
un-div-inv74.1%
associate-/r/74.1%
associate-*l*74.1%
div-inv74.2%
Applied egg-rr74.2%
if -9.0000000000000005e29 < d < 9.0000000000000004e-71Initial program 75.9%
*-un-lft-identity75.9%
add-sqr-sqrt75.9%
times-frac76.0%
hypot-def76.0%
fma-def76.0%
hypot-def88.9%
Applied egg-rr88.9%
Taylor expanded in c around inf 49.2%
associate-/l*49.1%
Simplified49.1%
Taylor expanded in c around inf 88.2%
if 9.0000000000000004e-71 < d < 2.8000000000000002e-13Initial program 84.0%
Taylor expanded in a around 0 73.9%
if 2.8000000000000002e-13 < d < 1.7e14Initial program 76.7%
*-un-lft-identity76.7%
add-sqr-sqrt76.7%
times-frac76.5%
hypot-def76.5%
fma-def76.5%
hypot-def87.9%
Applied egg-rr87.9%
Taylor expanded in c around inf 52.6%
associate-/l*52.6%
Simplified52.6%
Taylor expanded in c around inf 76.0%
associate-/r/76.2%
Applied egg-rr76.2%
Final simplification85.0%
(FPCore (a b c d)
:precision binary64
(if (or (<= d -2.1e+144)
(and (not (<= d -1.55e+77))
(or (<= d -1.16e+38)
(and (not (<= d 7.9e-35))
(or (<= d 1.1e-13) (not (<= d 3.4e+34)))))))
(/ b d)
(* (/ 1.0 c) (+ a (* d (/ b c))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.1e+144) || (!(d <= -1.55e+77) && ((d <= -1.16e+38) || (!(d <= 7.9e-35) && ((d <= 1.1e-13) || !(d <= 3.4e+34)))))) {
tmp = b / d;
} else {
tmp = (1.0 / c) * (a + (d * (b / c)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-2.1d+144)) .or. (.not. (d <= (-1.55d+77))) .and. (d <= (-1.16d+38)) .or. (.not. (d <= 7.9d-35)) .and. (d <= 1.1d-13) .or. (.not. (d <= 3.4d+34))) then
tmp = b / d
else
tmp = (1.0d0 / c) * (a + (d * (b / c)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.1e+144) || (!(d <= -1.55e+77) && ((d <= -1.16e+38) || (!(d <= 7.9e-35) && ((d <= 1.1e-13) || !(d <= 3.4e+34)))))) {
tmp = b / d;
} else {
tmp = (1.0 / c) * (a + (d * (b / c)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.1e+144) or (not (d <= -1.55e+77) and ((d <= -1.16e+38) or (not (d <= 7.9e-35) and ((d <= 1.1e-13) or not (d <= 3.4e+34))))): tmp = b / d else: tmp = (1.0 / c) * (a + (d * (b / c))) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.1e+144) || (!(d <= -1.55e+77) && ((d <= -1.16e+38) || (!(d <= 7.9e-35) && ((d <= 1.1e-13) || !(d <= 3.4e+34)))))) tmp = Float64(b / d); else tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(d * Float64(b / c)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -2.1e+144) || (~((d <= -1.55e+77)) && ((d <= -1.16e+38) || (~((d <= 7.9e-35)) && ((d <= 1.1e-13) || ~((d <= 3.4e+34))))))) tmp = b / d; else tmp = (1.0 / c) * (a + (d * (b / c))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.1e+144], And[N[Not[LessEqual[d, -1.55e+77]], $MachinePrecision], Or[LessEqual[d, -1.16e+38], And[N[Not[LessEqual[d, 7.9e-35]], $MachinePrecision], Or[LessEqual[d, 1.1e-13], N[Not[LessEqual[d, 3.4e+34]], $MachinePrecision]]]]]], N[(b / d), $MachinePrecision], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.1 \cdot 10^{+144} \lor \neg \left(d \leq -1.55 \cdot 10^{+77}\right) \land \left(d \leq -1.16 \cdot 10^{+38} \lor \neg \left(d \leq 7.9 \cdot 10^{-35}\right) \land \left(d \leq 1.1 \cdot 10^{-13} \lor \neg \left(d \leq 3.4 \cdot 10^{+34}\right)\right)\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\end{array}
\end{array}
if d < -2.09999999999999996e144 or -1.54999999999999999e77 < d < -1.15999999999999991e38 or 7.89999999999999983e-35 < d < 1.09999999999999998e-13 or 3.3999999999999999e34 < d Initial program 42.2%
Taylor expanded in c around 0 71.8%
if -2.09999999999999996e144 < d < -1.54999999999999999e77 or -1.15999999999999991e38 < d < 7.89999999999999983e-35 or 1.09999999999999998e-13 < d < 3.3999999999999999e34Initial program 71.4%
*-un-lft-identity71.4%
add-sqr-sqrt71.3%
times-frac71.4%
hypot-def71.4%
fma-def71.4%
hypot-def83.8%
Applied egg-rr83.8%
Taylor expanded in c around inf 46.1%
associate-/l*46.0%
Simplified46.0%
Taylor expanded in c around inf 82.1%
associate-/r/78.9%
Applied egg-rr78.9%
Final simplification75.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 c) (+ a (* d (/ b c))))))
(if (<= d -5.2e+143)
(/ b d)
(if (<= d -4.8e+69)
t_0
(if (<= d -7.4e+38)
(/ b d)
(if (<= d 1.6e-34)
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (or (<= d 2.4e-13) (not (<= d 7.5e+34))) (/ b d) t_0)))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / c) * (a + (d * (b / c)));
double tmp;
if (d <= -5.2e+143) {
tmp = b / d;
} else if (d <= -4.8e+69) {
tmp = t_0;
} else if (d <= -7.4e+38) {
tmp = b / d;
} else if (d <= 1.6e-34) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if ((d <= 2.4e-13) || !(d <= 7.5e+34)) {
tmp = b / d;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / c) * (a + (d * (b / c)))
if (d <= (-5.2d+143)) then
tmp = b / d
else if (d <= (-4.8d+69)) then
tmp = t_0
else if (d <= (-7.4d+38)) then
tmp = b / d
else if (d <= 1.6d-34) then
tmp = (1.0d0 / c) * (a + (b / (c / d)))
else if ((d <= 2.4d-13) .or. (.not. (d <= 7.5d+34))) then
tmp = b / d
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (1.0 / c) * (a + (d * (b / c)));
double tmp;
if (d <= -5.2e+143) {
tmp = b / d;
} else if (d <= -4.8e+69) {
tmp = t_0;
} else if (d <= -7.4e+38) {
tmp = b / d;
} else if (d <= 1.6e-34) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if ((d <= 2.4e-13) || !(d <= 7.5e+34)) {
tmp = b / d;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / c) * (a + (d * (b / c))) tmp = 0 if d <= -5.2e+143: tmp = b / d elif d <= -4.8e+69: tmp = t_0 elif d <= -7.4e+38: tmp = b / d elif d <= 1.6e-34: tmp = (1.0 / c) * (a + (b / (c / d))) elif (d <= 2.4e-13) or not (d <= 7.5e+34): tmp = b / d else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / c) * Float64(a + Float64(d * Float64(b / c)))) tmp = 0.0 if (d <= -5.2e+143) tmp = Float64(b / d); elseif (d <= -4.8e+69) tmp = t_0; elseif (d <= -7.4e+38) tmp = Float64(b / d); elseif (d <= 1.6e-34) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif ((d <= 2.4e-13) || !(d <= 7.5e+34)) tmp = Float64(b / d); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / c) * (a + (d * (b / c))); tmp = 0.0; if (d <= -5.2e+143) tmp = b / d; elseif (d <= -4.8e+69) tmp = t_0; elseif (d <= -7.4e+38) tmp = b / d; elseif (d <= 1.6e-34) tmp = (1.0 / c) * (a + (b / (c / d))); elseif ((d <= 2.4e-13) || ~((d <= 7.5e+34))) tmp = b / d; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.2e+143], N[(b / d), $MachinePrecision], If[LessEqual[d, -4.8e+69], t$95$0, If[LessEqual[d, -7.4e+38], N[(b / d), $MachinePrecision], If[LessEqual[d, 1.6e-34], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d, 2.4e-13], N[Not[LessEqual[d, 7.5e+34]], $MachinePrecision]], N[(b / d), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\mathbf{if}\;d \leq -5.2 \cdot 10^{+143}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -4.8 \cdot 10^{+69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -7.4 \cdot 10^{+38}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 1.6 \cdot 10^{-34}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{-13} \lor \neg \left(d \leq 7.5 \cdot 10^{+34}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -5.1999999999999998e143 or -4.8000000000000003e69 < d < -7.4000000000000002e38 or 1.60000000000000001e-34 < d < 2.3999999999999999e-13 or 7.49999999999999976e34 < d Initial program 42.2%
Taylor expanded in c around 0 71.8%
if -5.1999999999999998e143 < d < -4.8000000000000003e69 or 2.3999999999999999e-13 < d < 7.49999999999999976e34Initial program 48.3%
*-un-lft-identity48.3%
add-sqr-sqrt48.3%
times-frac48.1%
hypot-def48.1%
fma-def48.1%
hypot-def63.4%
Applied egg-rr63.4%
Taylor expanded in c around inf 35.8%
associate-/l*35.9%
Simplified35.9%
Taylor expanded in c around inf 67.9%
associate-/r/67.9%
Applied egg-rr67.9%
if -7.4000000000000002e38 < d < 1.60000000000000001e-34Initial program 75.9%
*-un-lft-identity75.9%
add-sqr-sqrt75.9%
times-frac75.9%
hypot-def76.0%
fma-def76.0%
hypot-def87.8%
Applied egg-rr87.8%
Taylor expanded in c around inf 48.1%
associate-/l*48.0%
Simplified48.0%
Taylor expanded in c around inf 84.9%
Final simplification77.7%
(FPCore (a b c d)
:precision binary64
(if (<= d -5.2e+143)
(/ b d)
(if (<= d -2e+79)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= d -7.8e+38)
(/ b d)
(if (<= d 1.62e-34)
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (or (<= d 1.2e-13) (not (<= d 1.35e+35)))
(/ b d)
(* (/ 1.0 c) (+ a (* d (/ b c))))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.2e+143) {
tmp = b / d;
} else if (d <= -2e+79) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= -7.8e+38) {
tmp = b / d;
} else if (d <= 1.62e-34) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if ((d <= 1.2e-13) || !(d <= 1.35e+35)) {
tmp = b / d;
} else {
tmp = (1.0 / c) * (a + (d * (b / c)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-5.2d+143)) then
tmp = b / d
else if (d <= (-2d+79)) then
tmp = (a / c) + ((d / c) * (b / c))
else if (d <= (-7.8d+38)) then
tmp = b / d
else if (d <= 1.62d-34) then
tmp = (1.0d0 / c) * (a + (b / (c / d)))
else if ((d <= 1.2d-13) .or. (.not. (d <= 1.35d+35))) then
tmp = b / d
else
tmp = (1.0d0 / c) * (a + (d * (b / c)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.2e+143) {
tmp = b / d;
} else if (d <= -2e+79) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= -7.8e+38) {
tmp = b / d;
} else if (d <= 1.62e-34) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if ((d <= 1.2e-13) || !(d <= 1.35e+35)) {
tmp = b / d;
} else {
tmp = (1.0 / c) * (a + (d * (b / c)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -5.2e+143: tmp = b / d elif d <= -2e+79: tmp = (a / c) + ((d / c) * (b / c)) elif d <= -7.8e+38: tmp = b / d elif d <= 1.62e-34: tmp = (1.0 / c) * (a + (b / (c / d))) elif (d <= 1.2e-13) or not (d <= 1.35e+35): tmp = b / d else: tmp = (1.0 / c) * (a + (d * (b / c))) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -5.2e+143) tmp = Float64(b / d); elseif (d <= -2e+79) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (d <= -7.8e+38) tmp = Float64(b / d); elseif (d <= 1.62e-34) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif ((d <= 1.2e-13) || !(d <= 1.35e+35)) tmp = Float64(b / d); else tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(d * Float64(b / c)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -5.2e+143) tmp = b / d; elseif (d <= -2e+79) tmp = (a / c) + ((d / c) * (b / c)); elseif (d <= -7.8e+38) tmp = b / d; elseif (d <= 1.62e-34) tmp = (1.0 / c) * (a + (b / (c / d))); elseif ((d <= 1.2e-13) || ~((d <= 1.35e+35))) tmp = b / d; else tmp = (1.0 / c) * (a + (d * (b / c))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.2e+143], N[(b / d), $MachinePrecision], If[LessEqual[d, -2e+79], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.8e+38], N[(b / d), $MachinePrecision], If[LessEqual[d, 1.62e-34], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d, 1.2e-13], N[Not[LessEqual[d, 1.35e+35]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.2 \cdot 10^{+143}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -2 \cdot 10^{+79}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq -7.8 \cdot 10^{+38}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 1.62 \cdot 10^{-34}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 1.2 \cdot 10^{-13} \lor \neg \left(d \leq 1.35 \cdot 10^{+35}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\end{array}
\end{array}
if d < -5.1999999999999998e143 or -1.99999999999999993e79 < d < -7.80000000000000047e38 or 1.62000000000000006e-34 < d < 1.1999999999999999e-13 or 1.35000000000000001e35 < d Initial program 42.2%
Taylor expanded in c around 0 71.8%
if -5.1999999999999998e143 < d < -1.99999999999999993e79Initial program 22.4%
*-un-lft-identity22.4%
add-sqr-sqrt22.4%
times-frac22.4%
hypot-def22.4%
fma-def22.4%
hypot-def46.9%
Applied egg-rr46.9%
Taylor expanded in c around inf 39.1%
associate-/l*39.3%
Simplified39.3%
Taylor expanded in c around inf 73.5%
distribute-rgt-in73.5%
un-div-inv74.1%
associate-/r/74.1%
associate-*l*74.1%
div-inv74.2%
Applied egg-rr74.2%
if -7.80000000000000047e38 < d < 1.62000000000000006e-34Initial program 75.9%
*-un-lft-identity75.9%
add-sqr-sqrt75.9%
times-frac75.9%
hypot-def76.0%
fma-def76.0%
hypot-def87.8%
Applied egg-rr87.8%
Taylor expanded in c around inf 48.1%
associate-/l*48.0%
Simplified48.0%
Taylor expanded in c around inf 84.9%
if 1.1999999999999999e-13 < d < 1.35000000000000001e35Initial program 70.2%
*-un-lft-identity70.2%
add-sqr-sqrt70.2%
times-frac69.9%
hypot-def69.9%
fma-def69.9%
hypot-def77.3%
Applied egg-rr77.3%
Taylor expanded in c around inf 33.0%
associate-/l*33.0%
Simplified33.0%
Taylor expanded in c around inf 63.1%
associate-/r/63.2%
Applied egg-rr63.2%
Final simplification77.7%
(FPCore (a b c d)
:precision binary64
(if (<= d -5.8e+143)
(/ b d)
(if (<= d -1.9e+81)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= d -1.8e+42)
(/ b d)
(if (<= d 1.5e-72)
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (<= d 3.6e+78) (/ (* b d) (+ (* c c) (* d d))) (/ b d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.8e+143) {
tmp = b / d;
} else if (d <= -1.9e+81) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= -1.8e+42) {
tmp = b / d;
} else if (d <= 1.5e-72) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (d <= 3.6e+78) {
tmp = (b * d) / ((c * c) + (d * d));
} 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 <= (-5.8d+143)) then
tmp = b / d
else if (d <= (-1.9d+81)) then
tmp = (a / c) + ((d / c) * (b / c))
else if (d <= (-1.8d+42)) then
tmp = b / d
else if (d <= 1.5d-72) then
tmp = (1.0d0 / c) * (a + (b / (c / d)))
else if (d <= 3.6d+78) then
tmp = (b * d) / ((c * c) + (d * d))
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 <= -5.8e+143) {
tmp = b / d;
} else if (d <= -1.9e+81) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= -1.8e+42) {
tmp = b / d;
} else if (d <= 1.5e-72) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (d <= 3.6e+78) {
tmp = (b * d) / ((c * c) + (d * d));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -5.8e+143: tmp = b / d elif d <= -1.9e+81: tmp = (a / c) + ((d / c) * (b / c)) elif d <= -1.8e+42: tmp = b / d elif d <= 1.5e-72: tmp = (1.0 / c) * (a + (b / (c / d))) elif d <= 3.6e+78: tmp = (b * d) / ((c * c) + (d * d)) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -5.8e+143) tmp = Float64(b / d); elseif (d <= -1.9e+81) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (d <= -1.8e+42) tmp = Float64(b / d); elseif (d <= 1.5e-72) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif (d <= 3.6e+78) tmp = Float64(Float64(b * d) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -5.8e+143) tmp = b / d; elseif (d <= -1.9e+81) tmp = (a / c) + ((d / c) * (b / c)); elseif (d <= -1.8e+42) tmp = b / d; elseif (d <= 1.5e-72) tmp = (1.0 / c) * (a + (b / (c / d))); elseif (d <= 3.6e+78) tmp = (b * d) / ((c * c) + (d * d)); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.8e+143], N[(b / d), $MachinePrecision], If[LessEqual[d, -1.9e+81], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.8e+42], N[(b / d), $MachinePrecision], If[LessEqual[d, 1.5e-72], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.6e+78], N[(N[(b * d), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.8 \cdot 10^{+143}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -1.9 \cdot 10^{+81}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq -1.8 \cdot 10^{+42}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 1.5 \cdot 10^{-72}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 3.6 \cdot 10^{+78}:\\
\;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -5.7999999999999996e143 or -1.9e81 < d < -1.8e42 or 3.6000000000000002e78 < d Initial program 35.2%
Taylor expanded in c around 0 71.4%
if -5.7999999999999996e143 < d < -1.9e81Initial program 22.4%
*-un-lft-identity22.4%
add-sqr-sqrt22.4%
times-frac22.4%
hypot-def22.4%
fma-def22.4%
hypot-def46.9%
Applied egg-rr46.9%
Taylor expanded in c around inf 39.1%
associate-/l*39.3%
Simplified39.3%
Taylor expanded in c around inf 73.5%
distribute-rgt-in73.5%
un-div-inv74.1%
associate-/r/74.1%
associate-*l*74.1%
div-inv74.2%
Applied egg-rr74.2%
if -1.8e42 < d < 1.5e-72Initial program 76.1%
*-un-lft-identity76.1%
add-sqr-sqrt76.1%
times-frac76.2%
hypot-def76.2%
fma-def76.2%
hypot-def89.0%
Applied egg-rr89.0%
Taylor expanded in c around inf 48.8%
associate-/l*48.7%
Simplified48.7%
Taylor expanded in c around inf 87.5%
if 1.5e-72 < d < 3.6000000000000002e78Initial program 77.4%
Taylor expanded in a around 0 65.3%
Final simplification77.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.95e+35) (not (<= d 1.05e-72))) (/ b d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.95e+35) || !(d <= 1.05e-72)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-1.95d+35)) .or. (.not. (d <= 1.05d-72))) then
tmp = b / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.95e+35) || !(d <= 1.05e-72)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.95e+35) or not (d <= 1.05e-72): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.95e+35) || !(d <= 1.05e-72)) tmp = Float64(b / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.95e+35) || ~((d <= 1.05e-72))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.95e+35], N[Not[LessEqual[d, 1.05e-72]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.95 \cdot 10^{+35} \lor \neg \left(d \leq 1.05 \cdot 10^{-72}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -1.95e35 or 1.05e-72 < d Initial program 45.3%
Taylor expanded in c around 0 61.6%
if -1.95e35 < d < 1.05e-72Initial program 76.1%
Taylor expanded in c around inf 64.2%
Final simplification62.7%
(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 58.8%
Taylor expanded in c around inf 38.4%
Final simplification38.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 2023333
(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))))