
(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 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) INFINITY) (/ (/ (fma a c (* b d)) (hypot c d)) (hypot c d)) (* (/ c (hypot c d)) (/ a (hypot c d)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (fma(a, c, (b * d)) / hypot(c, d)) / hypot(c, d);
} else {
tmp = (c / hypot(c, d)) * (a / hypot(c, d));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(Float64(fma(a, c, Float64(b * d)) / hypot(c, d)) / hypot(c, d)); else tmp = Float64(Float64(c / hypot(c, d)) * Float64(a / hypot(c, d))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(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[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 83.5%
*-un-lft-identity83.5%
add-sqr-sqrt83.5%
times-frac83.5%
hypot-define83.5%
fma-define83.5%
hypot-define95.5%
Applied egg-rr95.5%
associate-*l/95.7%
*-un-lft-identity95.7%
Applied egg-rr95.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 a around inf 2.0%
*-commutative2.0%
Simplified2.0%
add-sqr-sqrt2.0%
hypot-undefine2.0%
hypot-undefine2.0%
times-frac52.0%
Applied egg-rr52.0%
Final simplification87.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ a (* b (/ d c)))))
(if (<= c -2e+26)
(/ t_0 (- (hypot c d)))
(if (<= c -1.06e-108)
(* (fma a c (* b d)) (/ 1.0 (pow (hypot c d) 2.0)))
(if (<= c -9.5e-226)
(+ (/ b d) (* a (/ c (pow d 2.0))))
(if (<= c 1.05e+65)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(/ t_0 (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = a + (b * (d / c));
double tmp;
if (c <= -2e+26) {
tmp = t_0 / -hypot(c, d);
} else if (c <= -1.06e-108) {
tmp = fma(a, c, (b * d)) * (1.0 / pow(hypot(c, d), 2.0));
} else if (c <= -9.5e-226) {
tmp = (b / d) + (a * (c / pow(d, 2.0)));
} else if (c <= 1.05e+65) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = t_0 / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(a + Float64(b * Float64(d / c))) tmp = 0.0 if (c <= -2e+26) tmp = Float64(t_0 / Float64(-hypot(c, d))); elseif (c <= -1.06e-108) tmp = Float64(fma(a, c, Float64(b * d)) * Float64(1.0 / (hypot(c, d) ^ 2.0))); elseif (c <= -9.5e-226) tmp = Float64(Float64(b / d) + Float64(a * Float64(c / (d ^ 2.0)))); elseif (c <= 1.05e+65) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(t_0 / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2e+26], N[(t$95$0 / (-N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision])), $MachinePrecision], If[LessEqual[c, -1.06e-108], 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[c, -9.5e-226], N[(N[(b / d), $MachinePrecision] + N[(a * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.05e+65], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a + b \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -2 \cdot 10^{+26}:\\
\;\;\;\;\frac{t\_0}{-\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -1.06 \cdot 10^{-108}:\\
\;\;\;\;\mathsf{fma}\left(a, c, b \cdot d\right) \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{elif}\;c \leq -9.5 \cdot 10^{-226}:\\
\;\;\;\;\frac{b}{d} + a \cdot \frac{c}{{d}^{2}}\\
\mathbf{elif}\;c \leq 1.05 \cdot 10^{+65}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -2.0000000000000001e26Initial program 49.6%
*-un-lft-identity49.6%
add-sqr-sqrt49.6%
times-frac49.7%
hypot-define49.7%
fma-define49.7%
hypot-define62.7%
Applied egg-rr62.7%
associate-*l/62.8%
*-un-lft-identity62.8%
Applied egg-rr62.8%
Taylor expanded in c around -inf 80.7%
distribute-lft-out80.7%
associate-/l*84.2%
Simplified84.2%
if -2.0000000000000001e26 < c < -1.06e-108Initial program 88.9%
div-inv89.0%
fma-define89.0%
add-sqr-sqrt89.0%
pow289.0%
hypot-define89.0%
Applied egg-rr89.0%
if -1.06e-108 < c < -9.5000000000000007e-226Initial program 69.7%
Taylor expanded in c around 0 96.7%
associate-/l*93.4%
Simplified93.4%
if -9.5000000000000007e-226 < c < 1.04999999999999996e65Initial program 84.7%
if 1.04999999999999996e65 < c Initial program 41.6%
*-un-lft-identity41.6%
add-sqr-sqrt41.6%
times-frac41.5%
hypot-define41.5%
fma-define41.5%
hypot-define55.5%
Applied egg-rr55.5%
associate-*l/55.6%
*-un-lft-identity55.6%
Applied egg-rr55.6%
Taylor expanded in c around inf 75.6%
associate-/l*86.9%
Simplified87.0%
Final simplification86.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -5.2e+77)
(+ (/ a c) (* b (/ d (pow c 2.0))))
(if (<= c -1.5e-112)
t_0
(if (<= c -1.35e-225)
(+ (/ b d) (* a (/ c (pow d 2.0))))
(if (<= c 1.76e+65) t_0 (/ (+ a (* b (/ d c))) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -5.2e+77) {
tmp = (a / c) + (b * (d / pow(c, 2.0)));
} else if (c <= -1.5e-112) {
tmp = t_0;
} else if (c <= -1.35e-225) {
tmp = (b / d) + (a * (c / pow(d, 2.0)));
} else if (c <= 1.76e+65) {
tmp = t_0;
} else {
tmp = (a + (b * (d / c))) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -5.2e+77) {
tmp = (a / c) + (b * (d / Math.pow(c, 2.0)));
} else if (c <= -1.5e-112) {
tmp = t_0;
} else if (c <= -1.35e-225) {
tmp = (b / d) + (a * (c / Math.pow(d, 2.0)));
} else if (c <= 1.76e+65) {
tmp = t_0;
} else {
tmp = (a + (b * (d / c))) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -5.2e+77: tmp = (a / c) + (b * (d / math.pow(c, 2.0))) elif c <= -1.5e-112: tmp = t_0 elif c <= -1.35e-225: tmp = (b / d) + (a * (c / math.pow(d, 2.0))) elif c <= 1.76e+65: tmp = t_0 else: tmp = (a + (b * (d / c))) / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -5.2e+77) tmp = Float64(Float64(a / c) + Float64(b * Float64(d / (c ^ 2.0)))); elseif (c <= -1.5e-112) tmp = t_0; elseif (c <= -1.35e-225) tmp = Float64(Float64(b / d) + Float64(a * Float64(c / (d ^ 2.0)))); elseif (c <= 1.76e+65) tmp = t_0; else tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -5.2e+77) tmp = (a / c) + (b * (d / (c ^ 2.0))); elseif (c <= -1.5e-112) tmp = t_0; elseif (c <= -1.35e-225) tmp = (b / d) + (a * (c / (d ^ 2.0))); elseif (c <= 1.76e+65) tmp = t_0; else tmp = (a + (b * (d / c))) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5.2e+77], N[(N[(a / c), $MachinePrecision] + N[(b * N[(d / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.5e-112], t$95$0, If[LessEqual[c, -1.35e-225], N[(N[(b / d), $MachinePrecision] + N[(a * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.76e+65], t$95$0, N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -5.2 \cdot 10^{+77}:\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{d}{{c}^{2}}\\
\mathbf{elif}\;c \leq -1.5 \cdot 10^{-112}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -1.35 \cdot 10^{-225}:\\
\;\;\;\;\frac{b}{d} + a \cdot \frac{c}{{d}^{2}}\\
\mathbf{elif}\;c \leq 1.76 \cdot 10^{+65}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -5.2000000000000004e77Initial program 42.5%
Taylor expanded in c around inf 74.4%
associate-/l*74.9%
Simplified74.9%
if -5.2000000000000004e77 < c < -1.5e-112 or -1.34999999999999996e-225 < c < 1.76000000000000001e65Initial program 85.3%
if -1.5e-112 < c < -1.34999999999999996e-225Initial program 69.7%
Taylor expanded in c around 0 96.7%
associate-/l*93.4%
Simplified93.4%
if 1.76000000000000001e65 < c Initial program 41.6%
*-un-lft-identity41.6%
add-sqr-sqrt41.6%
times-frac41.5%
hypot-define41.5%
fma-define41.5%
hypot-define55.5%
Applied egg-rr55.5%
associate-*l/55.6%
*-un-lft-identity55.6%
Applied egg-rr55.6%
Taylor expanded in c around inf 75.6%
associate-/l*86.9%
Simplified87.0%
Final simplification84.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (+ a (* b (/ d c)))))
(if (<= c -3.4e+25)
(/ t_1 (- (hypot c d)))
(if (<= c -8.4e-105)
t_0
(if (<= c -8.6e-226)
(+ (/ b d) (* a (/ c (pow d 2.0))))
(if (<= c 1e+65) t_0 (/ 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 + (b * (d / c));
double tmp;
if (c <= -3.4e+25) {
tmp = t_1 / -hypot(c, d);
} else if (c <= -8.4e-105) {
tmp = t_0;
} else if (c <= -8.6e-226) {
tmp = (b / d) + (a * (c / pow(d, 2.0)));
} else if (c <= 1e+65) {
tmp = t_0;
} else {
tmp = t_1 / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = a + (b * (d / c));
double tmp;
if (c <= -3.4e+25) {
tmp = t_1 / -Math.hypot(c, d);
} else if (c <= -8.4e-105) {
tmp = t_0;
} else if (c <= -8.6e-226) {
tmp = (b / d) + (a * (c / Math.pow(d, 2.0)));
} else if (c <= 1e+65) {
tmp = t_0;
} else {
tmp = t_1 / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = a + (b * (d / c)) tmp = 0 if c <= -3.4e+25: tmp = t_1 / -math.hypot(c, d) elif c <= -8.4e-105: tmp = t_0 elif c <= -8.6e-226: tmp = (b / d) + (a * (c / math.pow(d, 2.0))) elif c <= 1e+65: tmp = t_0 else: tmp = t_1 / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(a + Float64(b * Float64(d / c))) tmp = 0.0 if (c <= -3.4e+25) tmp = Float64(t_1 / Float64(-hypot(c, d))); elseif (c <= -8.4e-105) tmp = t_0; elseif (c <= -8.6e-226) tmp = Float64(Float64(b / d) + Float64(a * Float64(c / (d ^ 2.0)))); elseif (c <= 1e+65) tmp = t_0; else tmp = Float64(t_1 / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); t_1 = a + (b * (d / c)); tmp = 0.0; if (c <= -3.4e+25) tmp = t_1 / -hypot(c, d); elseif (c <= -8.4e-105) tmp = t_0; elseif (c <= -8.6e-226) tmp = (b / d) + (a * (c / (d ^ 2.0))); elseif (c <= 1e+65) tmp = t_0; else tmp = t_1 / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.4e+25], N[(t$95$1 / (-N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision])), $MachinePrecision], If[LessEqual[c, -8.4e-105], t$95$0, If[LessEqual[c, -8.6e-226], N[(N[(b / d), $MachinePrecision] + N[(a * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1e+65], t$95$0, N[(t$95$1 / 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 := a + b \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -3.4 \cdot 10^{+25}:\\
\;\;\;\;\frac{t\_1}{-\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -8.4 \cdot 10^{-105}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -8.6 \cdot 10^{-226}:\\
\;\;\;\;\frac{b}{d} + a \cdot \frac{c}{{d}^{2}}\\
\mathbf{elif}\;c \leq 10^{+65}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -3.39999999999999984e25Initial program 49.6%
*-un-lft-identity49.6%
add-sqr-sqrt49.6%
times-frac49.7%
hypot-define49.7%
fma-define49.7%
hypot-define62.7%
Applied egg-rr62.7%
associate-*l/62.8%
*-un-lft-identity62.8%
Applied egg-rr62.8%
Taylor expanded in c around -inf 80.7%
distribute-lft-out80.7%
associate-/l*84.2%
Simplified84.2%
if -3.39999999999999984e25 < c < -8.3999999999999999e-105 or -8.60000000000000049e-226 < c < 9.9999999999999999e64Initial program 85.7%
if -8.3999999999999999e-105 < c < -8.60000000000000049e-226Initial program 69.7%
Taylor expanded in c around 0 96.7%
associate-/l*93.4%
Simplified93.4%
if 9.9999999999999999e64 < c Initial program 41.6%
*-un-lft-identity41.6%
add-sqr-sqrt41.6%
times-frac41.5%
hypot-define41.5%
fma-define41.5%
hypot-define55.5%
Applied egg-rr55.5%
associate-*l/55.6%
*-un-lft-identity55.6%
Applied egg-rr55.6%
Taylor expanded in c around inf 75.6%
associate-/l*86.9%
Simplified87.0%
Final simplification86.4%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.02e+79)
(+ (/ b d) (* a (/ c (pow d 2.0))))
(if (<= d 2.3e+43)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(/ (+ b (* a (/ c d))) (hypot c d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.02e+79) {
tmp = (b / d) + (a * (c / pow(d, 2.0)));
} else if (d <= 2.3e+43) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (b + (a * (c / d))) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.02e+79) {
tmp = (b / d) + (a * (c / Math.pow(d, 2.0)));
} else if (d <= 2.3e+43) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (b + (a * (c / d))) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.02e+79: tmp = (b / d) + (a * (c / math.pow(d, 2.0))) elif d <= 2.3e+43: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = (b + (a * (c / d))) / math.hypot(c, d) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.02e+79) tmp = Float64(Float64(b / d) + Float64(a * Float64(c / (d ^ 2.0)))); elseif (d <= 2.3e+43) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.02e+79) tmp = (b / d) + (a * (c / (d ^ 2.0))); elseif (d <= 2.3e+43) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = (b + (a * (c / d))) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.02e+79], N[(N[(b / d), $MachinePrecision] + N[(a * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.3e+43], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.02 \cdot 10^{+79}:\\
\;\;\;\;\frac{b}{d} + a \cdot \frac{c}{{d}^{2}}\\
\mathbf{elif}\;d \leq 2.3 \cdot 10^{+43}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -1.02000000000000006e79Initial program 60.9%
Taylor expanded in c around 0 93.3%
associate-/l*93.3%
Simplified93.3%
if -1.02000000000000006e79 < d < 2.3000000000000002e43Initial program 81.9%
if 2.3000000000000002e43 < d Initial program 31.5%
*-un-lft-identity31.5%
add-sqr-sqrt31.5%
times-frac31.5%
hypot-define31.5%
fma-define31.5%
hypot-define49.5%
Applied egg-rr49.5%
associate-*l/49.5%
*-un-lft-identity49.5%
Applied egg-rr49.5%
Taylor expanded in c around 0 72.6%
associate-/l*75.0%
Simplified75.0%
Final simplification82.1%
(FPCore (a b c d)
:precision binary64
(if (<= d -2.35e+139)
(/ b d)
(if (<= d 2e+133)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(* b (/ 1.0 (hypot c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.35e+139) {
tmp = b / d;
} else if (d <= 2e+133) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = b * (1.0 / hypot(c, d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.35e+139) {
tmp = b / d;
} else if (d <= 2e+133) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = b * (1.0 / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2.35e+139: tmp = b / d elif d <= 2e+133: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = b * (1.0 / math.hypot(c, d)) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2.35e+139) tmp = Float64(b / d); elseif (d <= 2e+133) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(b * Float64(1.0 / hypot(c, d))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2.35e+139) tmp = b / d; elseif (d <= 2e+133) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = b * (1.0 / hypot(c, d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.35e+139], N[(b / d), $MachinePrecision], If[LessEqual[d, 2e+133], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.35 \cdot 10^{+139}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+133}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -2.35e139Initial program 53.5%
Taylor expanded in c around 0 91.6%
if -2.35e139 < d < 2e133Initial program 80.8%
if 2e133 < d Initial program 22.2%
*-un-lft-identity22.2%
add-sqr-sqrt22.2%
times-frac22.3%
hypot-define22.3%
fma-define22.3%
hypot-define43.3%
Applied egg-rr43.3%
Taylor expanded in c around 0 73.7%
Final simplification80.8%
(FPCore (a b c d)
:precision binary64
(if (<= d -8e+141)
(* b (/ -1.0 (hypot c d)))
(if (<= d 5.8e+117)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(* b (/ 1.0 (hypot c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8e+141) {
tmp = b * (-1.0 / hypot(c, d));
} else if (d <= 5.8e+117) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = b * (1.0 / hypot(c, d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8e+141) {
tmp = b * (-1.0 / Math.hypot(c, d));
} else if (d <= 5.8e+117) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = b * (1.0 / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -8e+141: tmp = b * (-1.0 / math.hypot(c, d)) elif d <= 5.8e+117: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = b * (1.0 / math.hypot(c, d)) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -8e+141) tmp = Float64(b * Float64(-1.0 / hypot(c, d))); elseif (d <= 5.8e+117) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(b * Float64(1.0 / hypot(c, d))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -8e+141) tmp = b * (-1.0 / hypot(c, d)); elseif (d <= 5.8e+117) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = b * (1.0 / hypot(c, d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -8e+141], N[(b * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.8e+117], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8 \cdot 10^{+141}:\\
\;\;\;\;b \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{+117}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -8.00000000000000014e141Initial program 53.5%
*-un-lft-identity53.5%
add-sqr-sqrt53.5%
times-frac53.5%
hypot-define53.5%
fma-define53.5%
hypot-define76.2%
Applied egg-rr76.2%
Taylor expanded in d around -inf 93.4%
mul-1-neg93.4%
Simplified93.4%
if -8.00000000000000014e141 < d < 5.80000000000000055e117Initial program 80.8%
if 5.80000000000000055e117 < d Initial program 22.2%
*-un-lft-identity22.2%
add-sqr-sqrt22.2%
times-frac22.3%
hypot-define22.3%
fma-define22.3%
hypot-define43.3%
Applied egg-rr43.3%
Taylor expanded in c around 0 73.7%
Final simplification81.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -6.8e+72)
(+ (/ b d) (* a (/ c (pow d 2.0))))
(if (<= d 1.55e+129)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(* b (/ 1.0 (hypot c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -6.8e+72) {
tmp = (b / d) + (a * (c / pow(d, 2.0)));
} else if (d <= 1.55e+129) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = b * (1.0 / hypot(c, d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -6.8e+72) {
tmp = (b / d) + (a * (c / Math.pow(d, 2.0)));
} else if (d <= 1.55e+129) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = b * (1.0 / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -6.8e+72: tmp = (b / d) + (a * (c / math.pow(d, 2.0))) elif d <= 1.55e+129: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = b * (1.0 / math.hypot(c, d)) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -6.8e+72) tmp = Float64(Float64(b / d) + Float64(a * Float64(c / (d ^ 2.0)))); elseif (d <= 1.55e+129) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(b * Float64(1.0 / hypot(c, d))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -6.8e+72) tmp = (b / d) + (a * (c / (d ^ 2.0))); elseif (d <= 1.55e+129) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = b * (1.0 / hypot(c, d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -6.8e+72], N[(N[(b / d), $MachinePrecision] + N[(a * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.55e+129], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -6.8 \cdot 10^{+72}:\\
\;\;\;\;\frac{b}{d} + a \cdot \frac{c}{{d}^{2}}\\
\mathbf{elif}\;d \leq 1.55 \cdot 10^{+129}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -6.7999999999999997e72Initial program 60.9%
Taylor expanded in c around 0 93.3%
associate-/l*93.3%
Simplified93.3%
if -6.7999999999999997e72 < d < 1.55e129Initial program 80.5%
if 1.55e129 < d Initial program 22.2%
*-un-lft-identity22.2%
add-sqr-sqrt22.2%
times-frac22.3%
hypot-define22.3%
fma-define22.3%
hypot-define43.3%
Applied egg-rr43.3%
Taylor expanded in c around 0 73.7%
Final simplification81.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -7.8e+139) (not (<= d 4.5e+135))) (/ b d) (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.8e+139) || !(d <= 4.5e+135)) {
tmp = b / d;
} else {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * 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 <= (-7.8d+139)) .or. (.not. (d <= 4.5d+135))) then
tmp = b / d
else
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.8e+139) || !(d <= 4.5e+135)) {
tmp = b / d;
} else {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -7.8e+139) or not (d <= 4.5e+135): tmp = b / d else: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -7.8e+139) || !(d <= 4.5e+135)) tmp = Float64(b / d); else tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -7.8e+139) || ~((d <= 4.5e+135))) tmp = b / d; else tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7.8e+139], N[Not[LessEqual[d, 4.5e+135]], $MachinePrecision]], N[(b / d), $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.8 \cdot 10^{+139} \lor \neg \left(d \leq 4.5 \cdot 10^{+135}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\end{array}
\end{array}
if d < -7.80000000000000012e139 or 4.50000000000000007e135 < d Initial program 34.8%
Taylor expanded in c around 0 80.9%
if -7.80000000000000012e139 < d < 4.50000000000000007e135Initial program 80.8%
Final simplification80.8%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.35e+75)
(/ a c)
(if (<= c -2.5e-98)
(/ (* a c) (+ (* c c) (* d d)))
(if (<= c 9.5e-43) (/ b d) (/ a c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.35e+75) {
tmp = a / c;
} else if (c <= -2.5e-98) {
tmp = (a * c) / ((c * c) + (d * d));
} else if (c <= 9.5e-43) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (c <= (-2.35d+75)) then
tmp = a / c
else if (c <= (-2.5d-98)) then
tmp = (a * c) / ((c * c) + (d * d))
else if (c <= 9.5d-43) then
tmp = b / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.35e+75) {
tmp = a / c;
} else if (c <= -2.5e-98) {
tmp = (a * c) / ((c * c) + (d * d));
} else if (c <= 9.5e-43) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.35e+75: tmp = a / c elif c <= -2.5e-98: tmp = (a * c) / ((c * c) + (d * d)) elif c <= 9.5e-43: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.35e+75) tmp = Float64(a / c); elseif (c <= -2.5e-98) tmp = Float64(Float64(a * c) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 9.5e-43) tmp = Float64(b / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -2.35e+75) tmp = a / c; elseif (c <= -2.5e-98) tmp = (a * c) / ((c * c) + (d * d)); elseif (c <= 9.5e-43) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.35e+75], N[(a / c), $MachinePrecision], If[LessEqual[c, -2.5e-98], N[(N[(a * c), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 9.5e-43], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.35 \cdot 10^{+75}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq -2.5 \cdot 10^{-98}:\\
\;\;\;\;\frac{a \cdot c}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 9.5 \cdot 10^{-43}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -2.34999999999999992e75 or 9.50000000000000044e-43 < c Initial program 50.1%
Taylor expanded in c around inf 67.5%
if -2.34999999999999992e75 < c < -2.50000000000000009e-98Initial program 86.1%
Taylor expanded in a around inf 68.2%
*-commutative68.2%
Simplified68.2%
if -2.50000000000000009e-98 < c < 9.50000000000000044e-43Initial program 80.6%
Taylor expanded in c around 0 74.0%
Final simplification70.3%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.75e-93) (not (<= c 9.2e-36))) (/ a c) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.75e-93) || !(c <= 9.2e-36)) {
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.75d-93)) .or. (.not. (c <= 9.2d-36))) 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.75e-93) || !(c <= 9.2e-36)) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.75e-93) or not (c <= 9.2e-36): tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.75e-93) || !(c <= 9.2e-36)) 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.75e-93) || ~((c <= 9.2e-36))) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.75e-93], N[Not[LessEqual[c, 9.2e-36]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.75 \cdot 10^{-93} \lor \neg \left(c \leq 9.2 \cdot 10^{-36}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -1.75e-93 or 9.19999999999999986e-36 < c Initial program 59.0%
Taylor expanded in c around inf 63.5%
if -1.75e-93 < c < 9.19999999999999986e-36Initial program 80.6%
Taylor expanded in c around 0 74.0%
Final simplification67.8%
(FPCore (a b c d) :precision binary64 (if (<= d -9.8e+222) (/ a d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -9.8e+222) {
tmp = a / 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 <= (-9.8d+222)) then
tmp = a / 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 <= -9.8e+222) {
tmp = a / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -9.8e+222: tmp = a / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -9.8e+222) tmp = Float64(a / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -9.8e+222) tmp = a / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -9.8e+222], N[(a / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.8 \cdot 10^{+222}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -9.79999999999999981e222Initial program 60.8%
*-un-lft-identity60.8%
add-sqr-sqrt60.8%
times-frac60.8%
hypot-define60.8%
fma-define60.8%
hypot-define67.3%
Applied egg-rr67.3%
Taylor expanded in c around inf 21.9%
associate-/l*22.2%
Simplified22.2%
Taylor expanded in c around 0 22.7%
+-commutative22.7%
Simplified22.7%
Taylor expanded in b around 0 41.7%
if -9.79999999999999981e222 < d Initial program 68.3%
Taylor expanded in c around inf 44.5%
Final simplification44.4%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 67.8%
Taylor expanded in c around inf 42.5%
Final simplification42.5%
(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 2024046
(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))))