
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) INFINITY) (* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d))) (+ (/ b d) (* (/ c d) (/ a d)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
} else {
tmp = (b / d) + ((c / d) * (a / d));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d))); else tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 74.6%
*-un-lft-identity74.6%
add-sqr-sqrt74.5%
times-frac74.6%
hypot-def74.6%
fma-def74.6%
hypot-def94.7%
Applied egg-rr94.7%
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 c around 0 43.1%
associate-/l*46.2%
Simplified46.2%
*-un-lft-identity46.2%
metadata-eval46.2%
unpow246.2%
associate-*l/59.4%
times-frac65.6%
metadata-eval65.6%
clear-num65.7%
Applied egg-rr65.7%
Final simplification89.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d))))
(if (<= d -1.6e+159)
(+ (/ b d) (* (/ c d) (/ a d)))
(if (<= d -3.9e-106)
(* (fma a c (* b d)) (/ 1.0 (pow (hypot c d) 2.0)))
(if (<= d 1.8e-89)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 3.8e+68)
(/ (+ (* a c) (* b d)) (/ (hypot c d) t_0))
(* t_0 (+ b (* c (/ a d))))))))))
double code(double a, double b, double c, double d) {
double t_0 = 1.0 / hypot(c, d);
double tmp;
if (d <= -1.6e+159) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (d <= -3.9e-106) {
tmp = fma(a, c, (b * d)) * (1.0 / pow(hypot(c, d), 2.0));
} else if (d <= 1.8e-89) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 3.8e+68) {
tmp = ((a * c) + (b * d)) / (hypot(c, d) / t_0);
} else {
tmp = t_0 * (b + (c * (a / d)));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(1.0 / hypot(c, d)) tmp = 0.0 if (d <= -1.6e+159) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); elseif (d <= -3.9e-106) tmp = Float64(fma(a, c, Float64(b * d)) * Float64(1.0 / (hypot(c, d) ^ 2.0))); elseif (d <= 1.8e-89) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 3.8e+68) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(hypot(c, d) / t_0)); else tmp = Float64(t_0 * Float64(b + Float64(c * Float64(a / d)))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.6e+159], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.9e-106], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.8e-89], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.8e+68], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;d \leq -3.9 \cdot 10^{-106}:\\
\;\;\;\;\mathsf{fma}\left(a, c, b \cdot d\right) \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{elif}\;d \leq 1.8 \cdot 10^{-89}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{+68}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{\frac{\mathsf{hypot}\left(c, d\right)}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(b + c \cdot \frac{a}{d}\right)\\
\end{array}
\end{array}
if d < -1.59999999999999992e159Initial program 34.1%
Taylor expanded in c around 0 81.2%
associate-/l*81.7%
Simplified81.7%
*-un-lft-identity81.7%
metadata-eval81.7%
unpow281.7%
associate-*l/86.9%
times-frac93.4%
metadata-eval93.4%
clear-num93.5%
Applied egg-rr93.5%
if -1.59999999999999992e159 < d < -3.9000000000000001e-106Initial program 77.3%
div-inv77.4%
fma-def77.4%
add-sqr-sqrt77.4%
pow277.4%
hypot-def77.4%
Applied egg-rr77.4%
if -3.9000000000000001e-106 < d < 1.80000000000000003e-89Initial program 66.9%
Taylor expanded in c around inf 81.7%
associate-/l*78.7%
associate-/r/77.6%
Simplified77.6%
associate-*l/81.7%
unpow281.7%
associate-/r*90.1%
Applied egg-rr90.1%
if 1.80000000000000003e-89 < d < 3.8000000000000001e68Initial program 81.2%
flip3-+60.5%
clear-num60.5%
*-un-lft-identity60.5%
associate-/l*60.6%
flip3-+81.1%
associate-/l*81.2%
*-un-lft-identity81.2%
add-sqr-sqrt81.1%
associate-/l*81.4%
hypot-def81.4%
Applied egg-rr81.4%
if 3.8000000000000001e68 < d Initial program 41.4%
*-un-lft-identity41.4%
add-sqr-sqrt41.4%
times-frac41.2%
hypot-def41.2%
fma-def41.2%
hypot-def60.0%
Applied egg-rr60.0%
Taylor expanded in c around 0 82.7%
associate-/l*86.5%
associate-/r/88.2%
Simplified88.2%
Final simplification86.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* a c) (* b d))) (t_1 (/ 1.0 (hypot c d))))
(if (<= d -1.6e+159)
(+ (/ b d) (* (/ c d) (/ a d)))
(if (<= d -6.2e-106)
(/ t_0 (+ (* c c) (* d d)))
(if (<= d 2.8e-91)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 5e+62)
(/ t_0 (/ (hypot c d) t_1))
(* t_1 (+ b (* c (/ a d))))))))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = 1.0 / hypot(c, d);
double tmp;
if (d <= -1.6e+159) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (d <= -6.2e-106) {
tmp = t_0 / ((c * c) + (d * d));
} else if (d <= 2.8e-91) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 5e+62) {
tmp = t_0 / (hypot(c, d) / t_1);
} else {
tmp = t_1 * (b + (c * (a / 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 = 1.0 / Math.hypot(c, d);
double tmp;
if (d <= -1.6e+159) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (d <= -6.2e-106) {
tmp = t_0 / ((c * c) + (d * d));
} else if (d <= 2.8e-91) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 5e+62) {
tmp = t_0 / (Math.hypot(c, d) / t_1);
} else {
tmp = t_1 * (b + (c * (a / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = (a * c) + (b * d) t_1 = 1.0 / math.hypot(c, d) tmp = 0 if d <= -1.6e+159: tmp = (b / d) + ((c / d) * (a / d)) elif d <= -6.2e-106: tmp = t_0 / ((c * c) + (d * d)) elif d <= 2.8e-91: tmp = (a / c) + (((b * d) / c) / c) elif d <= 5e+62: tmp = t_0 / (math.hypot(c, d) / t_1) else: tmp = t_1 * (b + (c * (a / d))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) t_1 = Float64(1.0 / hypot(c, d)) tmp = 0.0 if (d <= -1.6e+159) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); elseif (d <= -6.2e-106) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 2.8e-91) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 5e+62) tmp = Float64(t_0 / Float64(hypot(c, d) / t_1)); else tmp = Float64(t_1 * Float64(b + Float64(c * Float64(a / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a * c) + (b * d); t_1 = 1.0 / hypot(c, d); tmp = 0.0; if (d <= -1.6e+159) tmp = (b / d) + ((c / d) * (a / d)); elseif (d <= -6.2e-106) tmp = t_0 / ((c * c) + (d * d)); elseif (d <= 2.8e-91) tmp = (a / c) + (((b * d) / c) / c); elseif (d <= 5e+62) tmp = t_0 / (hypot(c, d) / t_1); else tmp = t_1 * (b + (c * (a / 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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.6e+159], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -6.2e-106], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.8e-91], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5e+62], N[(t$95$0 / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;d \leq -6.2 \cdot 10^{-106}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{-91}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 5 \cdot 10^{+62}:\\
\;\;\;\;\frac{t_0}{\frac{\mathsf{hypot}\left(c, d\right)}{t_1}}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(b + c \cdot \frac{a}{d}\right)\\
\end{array}
\end{array}
if d < -1.59999999999999992e159Initial program 34.1%
Taylor expanded in c around 0 81.2%
associate-/l*81.7%
Simplified81.7%
*-un-lft-identity81.7%
metadata-eval81.7%
unpow281.7%
associate-*l/86.9%
times-frac93.4%
metadata-eval93.4%
clear-num93.5%
Applied egg-rr93.5%
if -1.59999999999999992e159 < d < -6.19999999999999971e-106Initial program 77.3%
if -6.19999999999999971e-106 < d < 2.8e-91Initial program 66.9%
Taylor expanded in c around inf 81.7%
associate-/l*78.7%
associate-/r/77.6%
Simplified77.6%
associate-*l/81.7%
unpow281.7%
associate-/r*90.1%
Applied egg-rr90.1%
if 2.8e-91 < d < 5.00000000000000029e62Initial program 81.2%
flip3-+60.5%
clear-num60.5%
*-un-lft-identity60.5%
associate-/l*60.6%
flip3-+81.1%
associate-/l*81.2%
*-un-lft-identity81.2%
add-sqr-sqrt81.1%
associate-/l*81.4%
hypot-def81.4%
Applied egg-rr81.4%
if 5.00000000000000029e62 < d Initial program 41.4%
*-un-lft-identity41.4%
add-sqr-sqrt41.4%
times-frac41.2%
hypot-def41.2%
fma-def41.2%
hypot-def60.0%
Applied egg-rr60.0%
Taylor expanded in c around 0 82.7%
associate-/l*86.5%
associate-/r/88.2%
Simplified88.2%
Final simplification86.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -1.6e+159)
(+ (/ b d) (* (/ c d) (/ a d)))
(if (<= d -3.2e-108)
t_0
(if (<= d 2.05e-90)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 3.05e+69)
t_0
(* (/ 1.0 (hypot c d)) (+ b (* c (/ a d))))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.6e+159) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (d <= -3.2e-108) {
tmp = t_0;
} else if (d <= 2.05e-90) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 3.05e+69) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * (b + (c * (a / d)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.6e+159) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (d <= -3.2e-108) {
tmp = t_0;
} else if (d <= 2.05e-90) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 3.05e+69) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * (b + (c * (a / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.6e+159: tmp = (b / d) + ((c / d) * (a / d)) elif d <= -3.2e-108: tmp = t_0 elif d <= 2.05e-90: tmp = (a / c) + (((b * d) / c) / c) elif d <= 3.05e+69: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * (b + (c * (a / d))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -1.6e+159) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); elseif (d <= -3.2e-108) tmp = t_0; elseif (d <= 2.05e-90) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 3.05e+69) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b + Float64(c * Float64(a / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.6e+159) tmp = (b / d) + ((c / d) * (a / d)); elseif (d <= -3.2e-108) tmp = t_0; elseif (d <= 2.05e-90) tmp = (a / c) + (((b * d) / c) / c); elseif (d <= 3.05e+69) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * (b + (c * (a / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.6e+159], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.2e-108], t$95$0, If[LessEqual[d, 2.05e-90], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.05e+69], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;d \leq -3.2 \cdot 10^{-108}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.05 \cdot 10^{-90}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 3.05 \cdot 10^{+69}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + c \cdot \frac{a}{d}\right)\\
\end{array}
\end{array}
if d < -1.59999999999999992e159Initial program 34.1%
Taylor expanded in c around 0 81.2%
associate-/l*81.7%
Simplified81.7%
*-un-lft-identity81.7%
metadata-eval81.7%
unpow281.7%
associate-*l/86.9%
times-frac93.4%
metadata-eval93.4%
clear-num93.5%
Applied egg-rr93.5%
if -1.59999999999999992e159 < d < -3.2e-108 or 2.05000000000000017e-90 < d < 3.05e69Initial program 78.8%
if -3.2e-108 < d < 2.05000000000000017e-90Initial program 66.9%
Taylor expanded in c around inf 81.7%
associate-/l*78.7%
associate-/r/77.6%
Simplified77.6%
associate-*l/81.7%
unpow281.7%
associate-/r*90.1%
Applied egg-rr90.1%
if 3.05e69 < d Initial program 40.3%
*-un-lft-identity40.3%
add-sqr-sqrt40.3%
times-frac40.2%
hypot-def40.2%
fma-def40.2%
hypot-def59.3%
Applied egg-rr59.3%
Taylor expanded in c around 0 82.4%
associate-/l*86.3%
associate-/r/88.0%
Simplified88.0%
Final simplification86.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (+ (/ b d) (* (/ c d) (/ a d)))))
(if (<= d -1.6e+159)
t_1
(if (<= d -5.6e-100)
t_0
(if (<= d 8.5e-84)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 2e+71) 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 = (b / d) + ((c / d) * (a / d));
double tmp;
if (d <= -1.6e+159) {
tmp = t_1;
} else if (d <= -5.6e-100) {
tmp = t_0;
} else if (d <= 8.5e-84) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 2e+71) {
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 = (b / d) + ((c / d) * (a / d))
if (d <= (-1.6d+159)) then
tmp = t_1
else if (d <= (-5.6d-100)) then
tmp = t_0
else if (d <= 8.5d-84) then
tmp = (a / c) + (((b * d) / c) / c)
else if (d <= 2d+71) 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 = (b / d) + ((c / d) * (a / d));
double tmp;
if (d <= -1.6e+159) {
tmp = t_1;
} else if (d <= -5.6e-100) {
tmp = t_0;
} else if (d <= 8.5e-84) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 2e+71) {
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 = (b / d) + ((c / d) * (a / d)) tmp = 0 if d <= -1.6e+159: tmp = t_1 elif d <= -5.6e-100: tmp = t_0 elif d <= 8.5e-84: tmp = (a / c) + (((b * d) / c) / c) elif d <= 2e+71: 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(b / d) + Float64(Float64(c / d) * Float64(a / d))) tmp = 0.0 if (d <= -1.6e+159) tmp = t_1; elseif (d <= -5.6e-100) tmp = t_0; elseif (d <= 8.5e-84) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 2e+71) 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 = (b / d) + ((c / d) * (a / d)); tmp = 0.0; if (d <= -1.6e+159) tmp = t_1; elseif (d <= -5.6e-100) tmp = t_0; elseif (d <= 8.5e-84) tmp = (a / c) + (((b * d) / c) / c); elseif (d <= 2e+71) 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[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.6e+159], t$95$1, If[LessEqual[d, -5.6e-100], t$95$0, If[LessEqual[d, 8.5e-84], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2e+71], 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{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -5.6 \cdot 10^{-100}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 8.5 \cdot 10^{-84}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+71}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d < -1.59999999999999992e159 or 2.0000000000000001e71 < d Initial program 38.2%
Taylor expanded in c around 0 78.8%
associate-/l*78.1%
Simplified78.1%
*-un-lft-identity78.1%
metadata-eval78.1%
unpow278.1%
associate-*l/82.1%
times-frac88.8%
metadata-eval88.8%
clear-num88.8%
Applied egg-rr88.8%
if -1.59999999999999992e159 < d < -5.59999999999999991e-100 or 8.4999999999999994e-84 < d < 2.0000000000000001e71Initial program 78.8%
if -5.59999999999999991e-100 < d < 8.4999999999999994e-84Initial program 66.9%
Taylor expanded in c around inf 81.7%
associate-/l*78.7%
associate-/r/77.6%
Simplified77.6%
associate-*l/81.7%
unpow281.7%
associate-/r*90.1%
Applied egg-rr90.1%
Final simplification85.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (/ b d) (* (/ c d) (/ a d)))))
(if (<= d -2.75e-23)
t_0
(if (<= d 3.7e-22)
(+ (/ a c) (/ (/ (* b d) c) c))
(if (<= d 8.3e+46)
(/ (* b d) (+ (* c c) (* d d)))
(if (<= d 1.02e+65) (* (/ -1.0 c) (- (- a) (/ b (/ c d)))) t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = (b / d) + ((c / d) * (a / d));
double tmp;
if (d <= -2.75e-23) {
tmp = t_0;
} else if (d <= 3.7e-22) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 8.3e+46) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 1.02e+65) {
tmp = (-1.0 / c) * (-a - (b / (c / 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 = (b / d) + ((c / d) * (a / d))
if (d <= (-2.75d-23)) then
tmp = t_0
else if (d <= 3.7d-22) then
tmp = (a / c) + (((b * d) / c) / c)
else if (d <= 8.3d+46) then
tmp = (b * d) / ((c * c) + (d * d))
else if (d <= 1.02d+65) then
tmp = ((-1.0d0) / c) * (-a - (b / (c / 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 = (b / d) + ((c / d) * (a / d));
double tmp;
if (d <= -2.75e-23) {
tmp = t_0;
} else if (d <= 3.7e-22) {
tmp = (a / c) + (((b * d) / c) / c);
} else if (d <= 8.3e+46) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 1.02e+65) {
tmp = (-1.0 / c) * (-a - (b / (c / d)));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b / d) + ((c / d) * (a / d)) tmp = 0 if d <= -2.75e-23: tmp = t_0 elif d <= 3.7e-22: tmp = (a / c) + (((b * d) / c) / c) elif d <= 8.3e+46: tmp = (b * d) / ((c * c) + (d * d)) elif d <= 1.02e+65: tmp = (-1.0 / c) * (-a - (b / (c / d))) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))) tmp = 0.0 if (d <= -2.75e-23) tmp = t_0; elseif (d <= 3.7e-22) tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); elseif (d <= 8.3e+46) tmp = Float64(Float64(b * d) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 1.02e+65) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(-a) - Float64(b / Float64(c / d)))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b / d) + ((c / d) * (a / d)); tmp = 0.0; if (d <= -2.75e-23) tmp = t_0; elseif (d <= 3.7e-22) tmp = (a / c) + (((b * d) / c) / c); elseif (d <= 8.3e+46) tmp = (b * d) / ((c * c) + (d * d)); elseif (d <= 1.02e+65) tmp = (-1.0 / c) * (-a - (b / (c / d))); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.75e-23], t$95$0, If[LessEqual[d, 3.7e-22], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 8.3e+46], N[(N[(b * d), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.02e+65], N[(N[(-1.0 / c), $MachinePrecision] * N[((-a) - N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{if}\;d \leq -2.75 \cdot 10^{-23}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.7 \cdot 10^{-22}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 8.3 \cdot 10^{+46}:\\
\;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 1.02 \cdot 10^{+65}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\left(-a\right) - \frac{b}{\frac{c}{d}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -2.7500000000000001e-23 or 1.02000000000000005e65 < d Initial program 52.9%
Taylor expanded in c around 0 74.1%
associate-/l*72.9%
Simplified72.9%
*-un-lft-identity72.9%
metadata-eval72.9%
unpow272.9%
associate-*l/75.6%
times-frac80.7%
metadata-eval80.7%
clear-num80.7%
Applied egg-rr80.7%
if -2.7500000000000001e-23 < d < 3.7e-22Initial program 67.8%
Taylor expanded in c around inf 76.3%
associate-/l*73.9%
associate-/r/73.1%
Simplified73.1%
associate-*l/76.3%
unpow276.3%
associate-/r*83.7%
Applied egg-rr83.7%
if 3.7e-22 < d < 8.29999999999999951e46Initial program 92.9%
Taylor expanded in a around 0 80.5%
if 8.29999999999999951e46 < d < 1.02000000000000005e65Initial program 37.8%
*-un-lft-identity37.8%
add-sqr-sqrt37.8%
times-frac37.8%
hypot-def37.8%
fma-def37.8%
hypot-def99.5%
Applied egg-rr99.5%
Taylor expanded in c around -inf 99.5%
distribute-lft-out99.5%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in c around -inf 100.0%
Final simplification82.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (/ a c) (/ (/ (* b d) c) c)))
(t_1 (+ (/ b d) (* (/ c d) (/ a d)))))
(if (<= d -3.2e-23)
t_1
(if (<= d 5.8e-23)
t_0
(if (<= d 7.5e+49)
(/ (* b d) (+ (* c c) (* d d)))
(if (<= d 4.9e+61) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (a / c) + (((b * d) / c) / c);
double t_1 = (b / d) + ((c / d) * (a / d));
double tmp;
if (d <= -3.2e-23) {
tmp = t_1;
} else if (d <= 5.8e-23) {
tmp = t_0;
} else if (d <= 7.5e+49) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 4.9e+61) {
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)
t_1 = (b / d) + ((c / d) * (a / d))
if (d <= (-3.2d-23)) then
tmp = t_1
else if (d <= 5.8d-23) then
tmp = t_0
else if (d <= 7.5d+49) then
tmp = (b * d) / ((c * c) + (d * d))
else if (d <= 4.9d+61) 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);
double t_1 = (b / d) + ((c / d) * (a / d));
double tmp;
if (d <= -3.2e-23) {
tmp = t_1;
} else if (d <= 5.8e-23) {
tmp = t_0;
} else if (d <= 7.5e+49) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 4.9e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = (a / c) + (((b * d) / c) / c) t_1 = (b / d) + ((c / d) * (a / d)) tmp = 0 if d <= -3.2e-23: tmp = t_1 elif d <= 5.8e-23: tmp = t_0 elif d <= 7.5e+49: tmp = (b * d) / ((c * c) + (d * d)) elif d <= 4.9e+61: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)) t_1 = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))) tmp = 0.0 if (d <= -3.2e-23) tmp = t_1; elseif (d <= 5.8e-23) tmp = t_0; elseif (d <= 7.5e+49) tmp = Float64(Float64(b * d) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 4.9e+61) 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); t_1 = (b / d) + ((c / d) * (a / d)); tmp = 0.0; if (d <= -3.2e-23) tmp = t_1; elseif (d <= 5.8e-23) tmp = t_0; elseif (d <= 7.5e+49) tmp = (b * d) / ((c * c) + (d * d)); elseif (d <= 4.9e+61) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.2e-23], t$95$1, If[LessEqual[d, 5.8e-23], t$95$0, If[LessEqual[d, 7.5e+49], N[(N[(b * d), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.9e+61], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
t_1 := \frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{if}\;d \leq -3.2 \cdot 10^{-23}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{-23}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+49}:\\
\;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 4.9 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d < -3.19999999999999976e-23 or 4.90000000000000025e61 < d Initial program 52.9%
Taylor expanded in c around 0 74.1%
associate-/l*72.9%
Simplified72.9%
*-un-lft-identity72.9%
metadata-eval72.9%
unpow272.9%
associate-*l/75.6%
times-frac80.7%
metadata-eval80.7%
clear-num80.7%
Applied egg-rr80.7%
if -3.19999999999999976e-23 < d < 5.8000000000000003e-23 or 7.4999999999999995e49 < d < 4.90000000000000025e61Initial program 67.0%
Taylor expanded in c around inf 76.1%
associate-/l*73.8%
associate-/r/73.0%
Simplified73.0%
associate-*l/76.1%
unpow276.1%
associate-/r*84.1%
Applied egg-rr84.1%
if 5.8000000000000003e-23 < d < 7.4999999999999995e49Initial program 92.9%
Taylor expanded in a around 0 80.5%
Final simplification82.2%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.7e+39)
(/ a (+ c (/ d (/ c d))))
(if (<= c 6.4e+53)
(+ (/ b d) (* (/ 1.0 d) (/ a (/ d c))))
(+ (/ a c) (* d (* (/ 1.0 c) (/ b c)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.7e+39) {
tmp = a / (c + (d / (c / d)));
} else if (c <= 6.4e+53) {
tmp = (b / d) + ((1.0 / d) * (a / (d / c)));
} else {
tmp = (a / c) + (d * ((1.0 / c) * (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 (c <= (-2.7d+39)) then
tmp = a / (c + (d / (c / d)))
else if (c <= 6.4d+53) then
tmp = (b / d) + ((1.0d0 / d) * (a / (d / c)))
else
tmp = (a / c) + (d * ((1.0d0 / c) * (b / c)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.7e+39) {
tmp = a / (c + (d / (c / d)));
} else if (c <= 6.4e+53) {
tmp = (b / d) + ((1.0 / d) * (a / (d / c)));
} else {
tmp = (a / c) + (d * ((1.0 / c) * (b / c)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.7e+39: tmp = a / (c + (d / (c / d))) elif c <= 6.4e+53: tmp = (b / d) + ((1.0 / d) * (a / (d / c))) else: tmp = (a / c) + (d * ((1.0 / c) * (b / c))) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.7e+39) tmp = Float64(a / Float64(c + Float64(d / Float64(c / d)))); elseif (c <= 6.4e+53) tmp = Float64(Float64(b / d) + Float64(Float64(1.0 / d) * Float64(a / Float64(d / c)))); else tmp = Float64(Float64(a / c) + Float64(d * Float64(Float64(1.0 / c) * Float64(b / c)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.7e+39) tmp = a / (c + (d / (c / d))); elseif (c <= 6.4e+53) tmp = (b / d) + ((1.0 / d) * (a / (d / c))); else tmp = (a / c) + (d * ((1.0 / c) * (b / c))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.7e+39], N[(a / N[(c + N[(d / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.4e+53], N[(N[(b / d), $MachinePrecision] + N[(N[(1.0 / d), $MachinePrecision] * N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(d * N[(N[(1.0 / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.7 \cdot 10^{+39}:\\
\;\;\;\;\frac{a}{c + \frac{d}{\frac{c}{d}}}\\
\mathbf{elif}\;c \leq 6.4 \cdot 10^{+53}:\\
\;\;\;\;\frac{b}{d} + \frac{1}{d} \cdot \frac{a}{\frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + d \cdot \left(\frac{1}{c} \cdot \frac{b}{c}\right)\\
\end{array}
\end{array}
if c < -2.70000000000000003e39Initial program 46.8%
Taylor expanded in a around inf 42.2%
associate-/l*44.6%
+-commutative44.6%
unpow244.6%
fma-udef44.6%
Simplified44.6%
Taylor expanded in d around 0 65.3%
div-inv65.3%
unpow265.3%
associate-*l*74.6%
div-inv74.5%
Applied egg-rr74.5%
associate-*r/65.3%
associate-/l*74.6%
Applied egg-rr74.6%
if -2.70000000000000003e39 < c < 6.4e53Initial program 70.7%
Taylor expanded in c around 0 70.5%
associate-/l*68.7%
Simplified68.7%
*-un-lft-identity68.7%
metadata-eval68.7%
unpow268.7%
associate-*r/75.5%
times-frac78.1%
metadata-eval78.1%
Applied egg-rr78.1%
if 6.4e53 < c Initial program 52.4%
Taylor expanded in c around inf 79.0%
associate-/l*77.7%
associate-/r/82.7%
Simplified82.7%
*-un-lft-identity82.7%
unpow282.7%
times-frac87.1%
Applied egg-rr87.1%
Final simplification79.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -8.5e-13) (not (<= d 155000000000.0))) (/ b d) (+ (/ a c) (/ (/ (* b d) c) c))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8.5e-13) || !(d <= 155000000000.0)) {
tmp = b / d;
} else {
tmp = (a / c) + (((b * d) / c) / c);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-8.5d-13)) .or. (.not. (d <= 155000000000.0d0))) then
tmp = b / d
else
tmp = (a / c) + (((b * d) / c) / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8.5e-13) || !(d <= 155000000000.0)) {
tmp = b / d;
} else {
tmp = (a / c) + (((b * d) / c) / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -8.5e-13) or not (d <= 155000000000.0): tmp = b / d else: tmp = (a / c) + (((b * d) / c) / c) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -8.5e-13) || !(d <= 155000000000.0)) tmp = Float64(b / d); else tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -8.5e-13) || ~((d <= 155000000000.0))) tmp = b / d; else tmp = (a / c) + (((b * d) / c) / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8.5e-13], N[Not[LessEqual[d, 155000000000.0]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.5 \cdot 10^{-13} \lor \neg \left(d \leq 155000000000\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\end{array}
\end{array}
if d < -8.5000000000000001e-13 or 1.55e11 < d Initial program 53.3%
Taylor expanded in c around 0 68.6%
if -8.5000000000000001e-13 < d < 1.55e11Initial program 70.4%
Taylor expanded in c around inf 73.5%
associate-/l*71.4%
associate-/r/70.6%
Simplified70.6%
associate-*l/73.5%
unpow273.5%
associate-/r*80.6%
Applied egg-rr80.6%
Final simplification74.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -7.2e-24) (not (<= d 850.0))) (+ (/ b d) (* (/ c d) (/ a d))) (+ (/ a c) (/ (/ (* b d) c) c))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.2e-24) || !(d <= 850.0)) {
tmp = (b / d) + ((c / d) * (a / d));
} else {
tmp = (a / c) + (((b * d) / c) / c);
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-7.2d-24)) .or. (.not. (d <= 850.0d0))) then
tmp = (b / d) + ((c / d) * (a / d))
else
tmp = (a / c) + (((b * d) / c) / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.2e-24) || !(d <= 850.0)) {
tmp = (b / d) + ((c / d) * (a / d));
} else {
tmp = (a / c) + (((b * d) / c) / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -7.2e-24) or not (d <= 850.0): tmp = (b / d) + ((c / d) * (a / d)) else: tmp = (a / c) + (((b * d) / c) / c) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -7.2e-24) || !(d <= 850.0)) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); else tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -7.2e-24) || ~((d <= 850.0))) tmp = (b / d) + ((c / d) * (a / d)); else tmp = (a / c) + (((b * d) / c) / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7.2e-24], N[Not[LessEqual[d, 850.0]], $MachinePrecision]], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.2 \cdot 10^{-24} \lor \neg \left(d \leq 850\right):\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\
\end{array}
\end{array}
if d < -7.2000000000000002e-24 or 850 < d Initial program 55.2%
Taylor expanded in c around 0 72.4%
associate-/l*71.4%
Simplified71.4%
*-un-lft-identity71.4%
metadata-eval71.4%
unpow271.4%
associate-*l/73.8%
times-frac78.4%
metadata-eval78.4%
clear-num78.4%
Applied egg-rr78.4%
if -7.2000000000000002e-24 < d < 850Initial program 69.1%
Taylor expanded in c around inf 75.6%
associate-/l*73.4%
associate-/r/72.6%
Simplified72.6%
associate-*l/75.6%
unpow275.6%
associate-/r*82.7%
Applied egg-rr82.7%
Final simplification80.4%
(FPCore (a b c d) :precision binary64 (if (or (<= c -3e-8) (not (<= c 2.4e-171))) (/ a (+ c (* d (/ d c)))) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -3e-8) || !(c <= 2.4e-171)) {
tmp = a / (c + (d * (d / 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 <= (-3d-8)) .or. (.not. (c <= 2.4d-171))) then
tmp = a / (c + (d * (d / 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 <= -3e-8) || !(c <= 2.4e-171)) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -3e-8) or not (c <= 2.4e-171): tmp = a / (c + (d * (d / c))) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -3e-8) || !(c <= 2.4e-171)) tmp = Float64(a / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -3e-8) || ~((c <= 2.4e-171))) tmp = a / (c + (d * (d / c))); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -3e-8], N[Not[LessEqual[c, 2.4e-171]], $MachinePrecision]], N[(a / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3 \cdot 10^{-8} \lor \neg \left(c \leq 2.4 \cdot 10^{-171}\right):\\
\;\;\;\;\frac{a}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -2.99999999999999973e-8 or 2.39999999999999987e-171 < c Initial program 55.9%
Taylor expanded in a around inf 44.5%
associate-/l*46.2%
+-commutative46.2%
unpow246.2%
fma-udef46.2%
Simplified46.2%
Taylor expanded in d around 0 64.2%
div-inv64.2%
unpow264.2%
associate-*l*69.2%
div-inv69.2%
Applied egg-rr69.2%
if -2.99999999999999973e-8 < c < 2.39999999999999987e-171Initial program 71.0%
Taylor expanded in c around 0 75.3%
Final simplification71.4%
(FPCore (a b c d) :precision binary64 (if (<= c -1.45e-11) (/ a (+ c (/ d (/ c d)))) (if (<= c 1.25e-168) (/ b d) (/ a (+ c (* d (/ d c)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.45e-11) {
tmp = a / (c + (d / (c / d)));
} else if (c <= 1.25e-168) {
tmp = b / d;
} else {
tmp = a / (c + (d * (d / c)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-1.45d-11)) then
tmp = a / (c + (d / (c / d)))
else if (c <= 1.25d-168) then
tmp = b / d
else
tmp = a / (c + (d * (d / c)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.45e-11) {
tmp = a / (c + (d / (c / d)));
} else if (c <= 1.25e-168) {
tmp = b / d;
} else {
tmp = a / (c + (d * (d / c)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.45e-11: tmp = a / (c + (d / (c / d))) elif c <= 1.25e-168: tmp = b / d else: tmp = a / (c + (d * (d / c))) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.45e-11) tmp = Float64(a / Float64(c + Float64(d / Float64(c / d)))); elseif (c <= 1.25e-168) tmp = Float64(b / d); else tmp = Float64(a / Float64(c + Float64(d * Float64(d / c)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.45e-11) tmp = a / (c + (d / (c / d))); elseif (c <= 1.25e-168) tmp = b / d; else tmp = a / (c + (d * (d / c))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.45e-11], N[(a / N[(c + N[(d / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.25e-168], N[(b / d), $MachinePrecision], N[(a / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.45 \cdot 10^{-11}:\\
\;\;\;\;\frac{a}{c + \frac{d}{\frac{c}{d}}}\\
\mathbf{elif}\;c \leq 1.25 \cdot 10^{-168}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c + d \cdot \frac{d}{c}}\\
\end{array}
\end{array}
if c < -1.45e-11Initial program 53.0%
Taylor expanded in a around inf 44.0%
associate-/l*45.9%
+-commutative45.9%
unpow245.9%
fma-udef45.9%
Simplified45.9%
Taylor expanded in d around 0 62.3%
div-inv62.3%
unpow262.3%
associate-*l*70.9%
div-inv70.9%
Applied egg-rr70.9%
associate-*r/62.3%
associate-/l*70.9%
Applied egg-rr70.9%
if -1.45e-11 < c < 1.25e-168Initial program 71.0%
Taylor expanded in c around 0 75.3%
if 1.25e-168 < c Initial program 58.2%
Taylor expanded in a around inf 44.8%
associate-/l*46.5%
+-commutative46.5%
unpow246.5%
fma-udef46.5%
Simplified46.5%
Taylor expanded in d around 0 65.8%
div-inv65.7%
unpow265.7%
associate-*l*67.8%
div-inv67.9%
Applied egg-rr67.9%
Final simplification71.4%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.7e+39) (not (<= c 6e+53))) (/ a c) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.7e+39) || !(c <= 6e+53)) {
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 <= (-1.7d+39)) .or. (.not. (c <= 6d+53))) 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 <= -1.7e+39) || !(c <= 6e+53)) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.7e+39) or not (c <= 6e+53): tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.7e+39) || !(c <= 6e+53)) 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 <= -1.7e+39) || ~((c <= 6e+53))) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.7e+39], N[Not[LessEqual[c, 6e+53]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.7 \cdot 10^{+39} \lor \neg \left(c \leq 6 \cdot 10^{+53}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -1.6999999999999999e39 or 5.99999999999999996e53 < c Initial program 49.6%
Taylor expanded in c around inf 69.8%
if -1.6999999999999999e39 < c < 5.99999999999999996e53Initial program 70.7%
Taylor expanded in c around 0 64.5%
Final simplification66.8%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 61.5%
Taylor expanded in c around inf 41.8%
Final simplification41.8%
(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 2023301
(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))))