
(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) (/ (/ (fma a c (* b d)) (hypot c d)) (hypot c d)) (* (/ c c) (/ (+ a (* d (/ b c))) c))))
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 / c) * ((a + (d * (b / c))) / 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))) <= Inf) tmp = Float64(Float64(fma(a, c, Float64(b * d)) / hypot(c, d)) / hypot(c, d)); else tmp = Float64(Float64(c / c) * Float64(Float64(a + Float64(d * Float64(b / c))) / 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], 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 / c), $MachinePrecision] * N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $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}{c} \cdot \frac{a + d \cdot \frac{b}{c}}{c}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 78.1%
*-un-lft-identity78.1%
add-sqr-sqrt78.1%
times-frac78.0%
hypot-def78.0%
fma-def78.0%
hypot-def95.7%
Applied egg-rr95.7%
associate-*l/96.0%
*-un-lft-identity96.0%
Applied egg-rr96.0%
if +inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
*-un-lft-identity0.0%
add-sqr-sqrt0.0%
times-frac0.0%
hypot-def0.0%
fma-def0.0%
hypot-def2.8%
Applied egg-rr2.8%
associate-*l/2.8%
*-un-lft-identity2.8%
Applied egg-rr2.8%
Taylor expanded in c around inf 44.5%
unpow244.5%
times-frac54.7%
Simplified54.7%
+-commutative54.7%
associate-*r/54.7%
frac-add1.1%
Applied egg-rr1.1%
+-commutative1.1%
*-commutative1.1%
distribute-lft-out1.1%
times-frac54.8%
associate-*l/45.6%
associate-*r/54.8%
Simplified54.8%
Final simplification87.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -5.6e+94)
(/ (- (/ (- d) (/ c b)) a) (hypot c d))
(if (<= c -1e-33)
t_0
(if (<= c 7e-92)
(+ (/ b d) (* a (/ (/ c d) d)))
(if (<= c 3.6e+61) t_0 (/ (* a (/ c (hypot c d))) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -5.6e+94) {
tmp = ((-d / (c / b)) - a) / hypot(c, d);
} else if (c <= -1e-33) {
tmp = t_0;
} else if (c <= 7e-92) {
tmp = (b / d) + (a * ((c / d) / d));
} else if (c <= 3.6e+61) {
tmp = t_0;
} else {
tmp = (a * (c / hypot(c, d))) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -5.6e+94) {
tmp = ((-d / (c / b)) - a) / Math.hypot(c, d);
} else if (c <= -1e-33) {
tmp = t_0;
} else if (c <= 7e-92) {
tmp = (b / d) + (a * ((c / d) / d));
} else if (c <= 3.6e+61) {
tmp = t_0;
} else {
tmp = (a * (c / Math.hypot(c, d))) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -5.6e+94: tmp = ((-d / (c / b)) - a) / math.hypot(c, d) elif c <= -1e-33: tmp = t_0 elif c <= 7e-92: tmp = (b / d) + (a * ((c / d) / d)) elif c <= 3.6e+61: tmp = t_0 else: tmp = (a * (c / math.hypot(c, d))) / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -5.6e+94) tmp = Float64(Float64(Float64(Float64(-d) / Float64(c / b)) - a) / hypot(c, d)); elseif (c <= -1e-33) tmp = t_0; elseif (c <= 7e-92) tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) / d))); elseif (c <= 3.6e+61) tmp = t_0; else tmp = Float64(Float64(a * Float64(c / hypot(c, d))) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -5.6e+94) tmp = ((-d / (c / b)) - a) / hypot(c, d); elseif (c <= -1e-33) tmp = t_0; elseif (c <= 7e-92) tmp = (b / d) + (a * ((c / d) / d)); elseif (c <= 3.6e+61) tmp = t_0; else tmp = (a * (c / hypot(c, d))) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5.6e+94], N[(N[(N[((-d) / N[(c / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1e-33], t$95$0, If[LessEqual[c, 7e-92], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.6e+61], t$95$0, N[(N[(a * N[(c / N[Sqrt[c ^ 2 + d ^ 2], $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.6 \cdot 10^{+94}:\\
\;\;\;\;\frac{\frac{-d}{\frac{c}{b}} - a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 7 \cdot 10^{-92}:\\
\;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\
\mathbf{elif}\;c \leq 3.6 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -5.59999999999999997e94Initial program 30.6%
*-un-lft-identity30.6%
add-sqr-sqrt30.6%
times-frac30.6%
hypot-def30.6%
fma-def30.6%
hypot-def57.4%
Applied egg-rr57.4%
associate-*l/57.5%
*-un-lft-identity57.5%
Applied egg-rr57.5%
Taylor expanded in c around -inf 79.5%
neg-mul-179.5%
unsub-neg79.5%
mul-1-neg79.5%
associate-/l*87.0%
distribute-neg-frac87.0%
Simplified87.0%
if -5.59999999999999997e94 < c < -1.0000000000000001e-33 or 7e-92 < c < 3.6000000000000001e61Initial program 92.5%
if -1.0000000000000001e-33 < c < 7e-92Initial program 68.7%
Taylor expanded in c around 0 80.4%
associate-/l*77.9%
associate-/r/80.5%
unpow280.5%
Simplified80.5%
associate-*l/80.4%
frac-times80.8%
clear-num80.8%
un-div-inv81.4%
Applied egg-rr81.4%
associate-/r/83.4%
Applied egg-rr83.4%
if 3.6000000000000001e61 < c Initial program 36.9%
*-un-lft-identity36.9%
add-sqr-sqrt36.9%
times-frac36.8%
hypot-def36.8%
fma-def36.8%
hypot-def61.7%
Applied egg-rr61.7%
Taylor expanded in a around inf 58.0%
add-sqr-sqrt58.0%
times-frac88.2%
Applied egg-rr88.2%
associate-*l/88.2%
*-un-lft-identity88.2%
frac-times58.0%
add-sqr-sqrt58.1%
associate-/l*88.5%
associate-/r/88.6%
Applied egg-rr88.6%
Final simplification87.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -4e+93)
(+ (/ a c) (* (/ b c) (/ d c)))
(if (<= c -1e-33)
t_0
(if (<= c 2.4e-92)
(+ (/ b d) (* a (/ (/ c d) d)))
(if (<= c 1.22e+148) t_0 (/ (+ a (/ d (/ c b))) (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 <= -4e+93) {
tmp = (a / c) + ((b / c) * (d / c));
} else if (c <= -1e-33) {
tmp = t_0;
} else if (c <= 2.4e-92) {
tmp = (b / d) + (a * ((c / d) / d));
} else if (c <= 1.22e+148) {
tmp = t_0;
} else {
tmp = (a + (d / (c / b))) / 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 <= -4e+93) {
tmp = (a / c) + ((b / c) * (d / c));
} else if (c <= -1e-33) {
tmp = t_0;
} else if (c <= 2.4e-92) {
tmp = (b / d) + (a * ((c / d) / d));
} else if (c <= 1.22e+148) {
tmp = t_0;
} else {
tmp = (a + (d / (c / b))) / 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 <= -4e+93: tmp = (a / c) + ((b / c) * (d / c)) elif c <= -1e-33: tmp = t_0 elif c <= 2.4e-92: tmp = (b / d) + (a * ((c / d) / d)) elif c <= 1.22e+148: tmp = t_0 else: tmp = (a + (d / (c / b))) / 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 <= -4e+93) tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c))); elseif (c <= -1e-33) tmp = t_0; elseif (c <= 2.4e-92) tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) / d))); elseif (c <= 1.22e+148) tmp = t_0; else tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / 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 <= -4e+93) tmp = (a / c) + ((b / c) * (d / c)); elseif (c <= -1e-33) tmp = t_0; elseif (c <= 2.4e-92) tmp = (b / d) + (a * ((c / d) / d)); elseif (c <= 1.22e+148) tmp = t_0; else tmp = (a + (d / (c / b))) / 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, -4e+93], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1e-33], t$95$0, If[LessEqual[c, 2.4e-92], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.22e+148], t$95$0, N[(N[(a + N[(d / N[(c / b), $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 -4 \cdot 10^{+93}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.4 \cdot 10^{-92}:\\
\;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\
\mathbf{elif}\;c \leq 1.22 \cdot 10^{+148}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -4.00000000000000017e93Initial program 30.6%
*-un-lft-identity30.6%
add-sqr-sqrt30.6%
times-frac30.6%
hypot-def30.6%
fma-def30.6%
hypot-def57.4%
Applied egg-rr57.4%
Taylor expanded in c around inf 76.1%
unpow276.1%
*-commutative76.1%
times-frac86.1%
Simplified86.1%
if -4.00000000000000017e93 < c < -1.0000000000000001e-33 or 2.4000000000000001e-92 < c < 1.22000000000000007e148Initial program 88.1%
if -1.0000000000000001e-33 < c < 2.4000000000000001e-92Initial program 68.7%
Taylor expanded in c around 0 80.4%
associate-/l*77.9%
associate-/r/80.5%
unpow280.5%
Simplified80.5%
associate-*l/80.4%
frac-times80.8%
clear-num80.8%
un-div-inv81.4%
Applied egg-rr81.4%
associate-/r/83.4%
Applied egg-rr83.4%
if 1.22000000000000007e148 < c Initial program 29.1%
*-un-lft-identity29.1%
add-sqr-sqrt29.1%
times-frac29.1%
hypot-def29.1%
fma-def29.1%
hypot-def53.8%
Applied egg-rr53.8%
associate-*l/53.8%
*-un-lft-identity53.8%
Applied egg-rr53.8%
Taylor expanded in c around inf 83.6%
associate-/l*88.5%
Simplified88.5%
Final simplification85.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -4.1e+92)
(/ (- (/ (- d) (/ c b)) a) (hypot c d))
(if (<= c -1e-33)
t_0
(if (<= c 4.2e-92)
(+ (/ b d) (* a (/ (/ c d) d)))
(if (<= c 4.6e+139) t_0 (/ (+ a (/ d (/ c b))) (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 <= -4.1e+92) {
tmp = ((-d / (c / b)) - a) / hypot(c, d);
} else if (c <= -1e-33) {
tmp = t_0;
} else if (c <= 4.2e-92) {
tmp = (b / d) + (a * ((c / d) / d));
} else if (c <= 4.6e+139) {
tmp = t_0;
} else {
tmp = (a + (d / (c / b))) / 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 <= -4.1e+92) {
tmp = ((-d / (c / b)) - a) / Math.hypot(c, d);
} else if (c <= -1e-33) {
tmp = t_0;
} else if (c <= 4.2e-92) {
tmp = (b / d) + (a * ((c / d) / d));
} else if (c <= 4.6e+139) {
tmp = t_0;
} else {
tmp = (a + (d / (c / b))) / 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 <= -4.1e+92: tmp = ((-d / (c / b)) - a) / math.hypot(c, d) elif c <= -1e-33: tmp = t_0 elif c <= 4.2e-92: tmp = (b / d) + (a * ((c / d) / d)) elif c <= 4.6e+139: tmp = t_0 else: tmp = (a + (d / (c / b))) / 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 <= -4.1e+92) tmp = Float64(Float64(Float64(Float64(-d) / Float64(c / b)) - a) / hypot(c, d)); elseif (c <= -1e-33) tmp = t_0; elseif (c <= 4.2e-92) tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) / d))); elseif (c <= 4.6e+139) tmp = t_0; else tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / 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 <= -4.1e+92) tmp = ((-d / (c / b)) - a) / hypot(c, d); elseif (c <= -1e-33) tmp = t_0; elseif (c <= 4.2e-92) tmp = (b / d) + (a * ((c / d) / d)); elseif (c <= 4.6e+139) tmp = t_0; else tmp = (a + (d / (c / b))) / 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, -4.1e+92], N[(N[(N[((-d) / N[(c / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1e-33], t$95$0, If[LessEqual[c, 4.2e-92], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.6e+139], t$95$0, N[(N[(a + N[(d / N[(c / b), $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 -4.1 \cdot 10^{+92}:\\
\;\;\;\;\frac{\frac{-d}{\frac{c}{b}} - a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 4.2 \cdot 10^{-92}:\\
\;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\
\mathbf{elif}\;c \leq 4.6 \cdot 10^{+139}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -4.10000000000000024e92Initial program 30.6%
*-un-lft-identity30.6%
add-sqr-sqrt30.6%
times-frac30.6%
hypot-def30.6%
fma-def30.6%
hypot-def57.4%
Applied egg-rr57.4%
associate-*l/57.5%
*-un-lft-identity57.5%
Applied egg-rr57.5%
Taylor expanded in c around -inf 79.5%
neg-mul-179.5%
unsub-neg79.5%
mul-1-neg79.5%
associate-/l*87.0%
distribute-neg-frac87.0%
Simplified87.0%
if -4.10000000000000024e92 < c < -1.0000000000000001e-33 or 4.2e-92 < c < 4.6e139Initial program 88.1%
if -1.0000000000000001e-33 < c < 4.2e-92Initial program 68.7%
Taylor expanded in c around 0 80.4%
associate-/l*77.9%
associate-/r/80.5%
unpow280.5%
Simplified80.5%
associate-*l/80.4%
frac-times80.8%
clear-num80.8%
un-div-inv81.4%
Applied egg-rr81.4%
associate-/r/83.4%
Applied egg-rr83.4%
if 4.6e139 < c Initial program 29.1%
*-un-lft-identity29.1%
add-sqr-sqrt29.1%
times-frac29.1%
hypot-def29.1%
fma-def29.1%
hypot-def53.8%
Applied egg-rr53.8%
associate-*l/53.8%
*-un-lft-identity53.8%
Applied egg-rr53.8%
Taylor expanded in c around inf 83.6%
associate-/l*88.5%
Simplified88.5%
Final simplification86.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -9.2e+93)
(+ (/ a c) (* (/ b c) (/ d c)))
(if (<= c -1e-33)
t_0
(if (<= c 2.7e-92)
(+ (/ b d) (* a (/ (/ c d) d)))
(if (<= c 4.6e+139) t_0 (+ (/ a c) (/ (* d (/ b c)) c))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -9.2e+93) {
tmp = (a / c) + ((b / c) * (d / c));
} else if (c <= -1e-33) {
tmp = t_0;
} else if (c <= 2.7e-92) {
tmp = (b / d) + (a * ((c / d) / d));
} else if (c <= 4.6e+139) {
tmp = t_0;
} else {
tmp = (a / c) + ((d * (b / 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) :: t_0
real(8) :: tmp
t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
if (c <= (-9.2d+93)) then
tmp = (a / c) + ((b / c) * (d / c))
else if (c <= (-1d-33)) then
tmp = t_0
else if (c <= 2.7d-92) then
tmp = (b / d) + (a * ((c / d) / d))
else if (c <= 4.6d+139) then
tmp = t_0
else
tmp = (a / c) + ((d * (b / c)) / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -9.2e+93) {
tmp = (a / c) + ((b / c) * (d / c));
} else if (c <= -1e-33) {
tmp = t_0;
} else if (c <= 2.7e-92) {
tmp = (b / d) + (a * ((c / d) / d));
} else if (c <= 4.6e+139) {
tmp = t_0;
} else {
tmp = (a / c) + ((d * (b / c)) / c);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -9.2e+93: tmp = (a / c) + ((b / c) * (d / c)) elif c <= -1e-33: tmp = t_0 elif c <= 2.7e-92: tmp = (b / d) + (a * ((c / d) / d)) elif c <= 4.6e+139: tmp = t_0 else: tmp = (a / c) + ((d * (b / c)) / c) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -9.2e+93) tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c))); elseif (c <= -1e-33) tmp = t_0; elseif (c <= 2.7e-92) tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) / d))); elseif (c <= 4.6e+139) tmp = t_0; else tmp = Float64(Float64(a / c) + Float64(Float64(d * Float64(b / c)) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -9.2e+93) tmp = (a / c) + ((b / c) * (d / c)); elseif (c <= -1e-33) tmp = t_0; elseif (c <= 2.7e-92) tmp = (b / d) + (a * ((c / d) / d)); elseif (c <= 4.6e+139) tmp = t_0; else tmp = (a / c) + ((d * (b / c)) / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -9.2e+93], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1e-33], t$95$0, If[LessEqual[c, 2.7e-92], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.6e+139], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision] / c), $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 -9.2 \cdot 10^{+93}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.7 \cdot 10^{-92}:\\
\;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\
\mathbf{elif}\;c \leq 4.6 \cdot 10^{+139}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\end{array}
\end{array}
if c < -9.2000000000000006e93Initial program 30.6%
*-un-lft-identity30.6%
add-sqr-sqrt30.6%
times-frac30.6%
hypot-def30.6%
fma-def30.6%
hypot-def57.4%
Applied egg-rr57.4%
Taylor expanded in c around inf 76.1%
unpow276.1%
*-commutative76.1%
times-frac86.1%
Simplified86.1%
if -9.2000000000000006e93 < c < -1.0000000000000001e-33 or 2.69999999999999995e-92 < c < 4.6e139Initial program 88.1%
if -1.0000000000000001e-33 < c < 2.69999999999999995e-92Initial program 68.7%
Taylor expanded in c around 0 80.4%
associate-/l*77.9%
associate-/r/80.5%
unpow280.5%
Simplified80.5%
associate-*l/80.4%
frac-times80.8%
clear-num80.8%
un-div-inv81.4%
Applied egg-rr81.4%
associate-/r/83.4%
Applied egg-rr83.4%
if 4.6e139 < c Initial program 29.1%
*-un-lft-identity29.1%
add-sqr-sqrt29.1%
times-frac29.1%
hypot-def29.1%
fma-def29.1%
hypot-def53.8%
Applied egg-rr53.8%
associate-*l/53.8%
*-un-lft-identity53.8%
Applied egg-rr53.8%
Taylor expanded in c around inf 78.4%
unpow278.4%
times-frac88.3%
Simplified88.3%
associate-*l/88.3%
Applied egg-rr88.3%
Final simplification85.9%
(FPCore (a b c d)
:precision binary64
(if (<= d -6.6e+20)
(+ (/ b d) (/ (/ c d) (/ d a)))
(if (<= d 2.5e-31)
(* (/ c c) (/ (+ a (* d (/ b c))) c))
(+ (/ b d) (* (/ c d) (/ a d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -6.6e+20) {
tmp = (b / d) + ((c / d) / (d / a));
} else if (d <= 2.5e-31) {
tmp = (c / c) * ((a + (d * (b / c))) / c);
} else {
tmp = (b / d) + ((c / d) * (a / d));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-6.6d+20)) then
tmp = (b / d) + ((c / d) / (d / a))
else if (d <= 2.5d-31) then
tmp = (c / c) * ((a + (d * (b / c))) / c)
else
tmp = (b / d) + ((c / d) * (a / d))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -6.6e+20) {
tmp = (b / d) + ((c / d) / (d / a));
} else if (d <= 2.5e-31) {
tmp = (c / c) * ((a + (d * (b / c))) / c);
} else {
tmp = (b / d) + ((c / d) * (a / d));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -6.6e+20: tmp = (b / d) + ((c / d) / (d / a)) elif d <= 2.5e-31: tmp = (c / c) * ((a + (d * (b / c))) / c) else: tmp = (b / d) + ((c / d) * (a / d)) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -6.6e+20) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) / Float64(d / a))); elseif (d <= 2.5e-31) tmp = Float64(Float64(c / c) * Float64(Float64(a + Float64(d * Float64(b / c))) / c)); else tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -6.6e+20) tmp = (b / d) + ((c / d) / (d / a)); elseif (d <= 2.5e-31) tmp = (c / c) * ((a + (d * (b / c))) / c); else tmp = (b / d) + ((c / d) * (a / d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -6.6e+20], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] / N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.5e-31], N[(N[(c / c), $MachinePrecision] * N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $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}\;d \leq -6.6 \cdot 10^{+20}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{c}{d}}{\frac{d}{a}}\\
\mathbf{elif}\;d \leq 2.5 \cdot 10^{-31}:\\
\;\;\;\;\frac{c}{c} \cdot \frac{a + d \cdot \frac{b}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\end{array}
\end{array}
if d < -6.6e20Initial program 46.0%
Taylor expanded in c around 0 70.3%
associate-/l*70.7%
associate-/r/70.6%
unpow270.6%
Simplified70.6%
associate-*l/70.3%
frac-times81.4%
clear-num81.4%
un-div-inv81.4%
Applied egg-rr81.4%
if -6.6e20 < d < 2.5e-31Initial program 70.9%
*-un-lft-identity70.9%
add-sqr-sqrt70.9%
times-frac70.8%
hypot-def70.8%
fma-def70.8%
hypot-def86.7%
Applied egg-rr86.7%
associate-*l/86.9%
*-un-lft-identity86.9%
Applied egg-rr86.9%
Taylor expanded in c around inf 72.8%
unpow272.8%
times-frac78.3%
Simplified78.3%
+-commutative78.3%
associate-*r/79.8%
frac-add55.9%
Applied egg-rr55.9%
+-commutative55.9%
*-commutative55.9%
distribute-lft-out55.9%
times-frac82.2%
associate-*l/81.4%
associate-*r/79.9%
Simplified79.9%
if 2.5e-31 < d Initial program 58.7%
*-un-lft-identity58.7%
add-sqr-sqrt58.7%
times-frac58.7%
hypot-def58.7%
fma-def58.7%
hypot-def69.2%
Applied egg-rr69.2%
associate-*l/69.3%
*-un-lft-identity69.3%
Applied egg-rr69.3%
Taylor expanded in c around 0 72.2%
*-commutative72.2%
unpow272.2%
times-frac76.9%
Simplified76.9%
Final simplification79.4%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.7e-30) (not (<= c 2.3e-68))) (+ (/ a c) (* (/ b c) (/ d c))) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.7e-30) || !(c <= 2.3e-68)) {
tmp = (a / c) + ((b / c) * (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 <= (-2.7d-30)) .or. (.not. (c <= 2.3d-68))) then
tmp = (a / c) + ((b / c) * (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 <= -2.7e-30) || !(c <= 2.3e-68)) {
tmp = (a / c) + ((b / c) * (d / c));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.7e-30) or not (c <= 2.3e-68): tmp = (a / c) + ((b / c) * (d / c)) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.7e-30) || !(c <= 2.3e-68)) tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * 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 <= -2.7e-30) || ~((c <= 2.3e-68))) tmp = (a / c) + ((b / c) * (d / c)); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.7e-30], N[Not[LessEqual[c, 2.3e-68]], $MachinePrecision]], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.7 \cdot 10^{-30} \lor \neg \left(c \leq 2.3 \cdot 10^{-68}\right):\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -2.69999999999999987e-30 or 2.29999999999999997e-68 < c Initial program 55.2%
*-un-lft-identity55.2%
add-sqr-sqrt55.2%
times-frac55.2%
hypot-def55.2%
fma-def55.2%
hypot-def73.0%
Applied egg-rr73.0%
Taylor expanded in c around inf 70.1%
unpow270.1%
*-commutative70.1%
times-frac75.0%
Simplified75.0%
if -2.69999999999999987e-30 < c < 2.29999999999999997e-68Initial program 70.3%
Taylor expanded in c around 0 69.5%
Final simplification72.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -6.6e+20) (not (<= d 2.2e-31))) (+ (/ b d) (* c (/ a (* d d)))) (+ (/ a c) (/ (* b (/ d c)) c))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -6.6e+20) || !(d <= 2.2e-31)) {
tmp = (b / d) + (c * (a / (d * 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 <= (-6.6d+20)) .or. (.not. (d <= 2.2d-31))) then
tmp = (b / d) + (c * (a / (d * 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 <= -6.6e+20) || !(d <= 2.2e-31)) {
tmp = (b / d) + (c * (a / (d * d)));
} else {
tmp = (a / c) + ((b * (d / c)) / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -6.6e+20) or not (d <= 2.2e-31): tmp = (b / d) + (c * (a / (d * d))) else: tmp = (a / c) + ((b * (d / c)) / c) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -6.6e+20) || !(d <= 2.2e-31)) tmp = Float64(Float64(b / d) + Float64(c * Float64(a / Float64(d * d)))); else tmp = Float64(Float64(a / c) + Float64(Float64(b * Float64(d / c)) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -6.6e+20) || ~((d <= 2.2e-31))) tmp = (b / d) + (c * (a / (d * d))); else tmp = (a / c) + ((b * (d / c)) / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -6.6e+20], N[Not[LessEqual[d, 2.2e-31]], $MachinePrecision]], N[(N[(b / d), $MachinePrecision] + N[(c * N[(a / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -6.6 \cdot 10^{+20} \lor \neg \left(d \leq 2.2 \cdot 10^{-31}\right):\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -6.6e20 or 2.2000000000000001e-31 < d Initial program 52.9%
Taylor expanded in c around 0 71.3%
associate-/l*71.7%
associate-/r/70.9%
unpow270.9%
Simplified70.9%
Taylor expanded in c around 0 71.3%
unpow271.3%
*-lft-identity71.3%
times-frac71.7%
/-rgt-identity71.7%
Simplified71.7%
if -6.6e20 < d < 2.2000000000000001e-31Initial program 70.9%
*-un-lft-identity70.9%
add-sqr-sqrt70.9%
times-frac70.8%
hypot-def70.8%
fma-def70.8%
hypot-def86.7%
Applied egg-rr86.7%
associate-*l/86.9%
*-un-lft-identity86.9%
Applied egg-rr86.9%
Taylor expanded in c around inf 72.8%
unpow272.8%
times-frac78.3%
Simplified78.3%
associate-*r/79.8%
Applied egg-rr79.8%
Final simplification75.7%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3.2e+21) (not (<= d 2e-34))) (+ (/ 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 <= -3.2e+21) || !(d <= 2e-34)) {
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 <= (-3.2d+21)) .or. (.not. (d <= 2d-34))) 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 <= -3.2e+21) || !(d <= 2e-34)) {
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 <= -3.2e+21) or not (d <= 2e-34): 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 <= -3.2e+21) || !(d <= 2e-34)) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); else tmp = Float64(Float64(a / c) + Float64(Float64(b * Float64(d / c)) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -3.2e+21) || ~((d <= 2e-34))) 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, -3.2e+21], N[Not[LessEqual[d, 2e-34]], $MachinePrecision]], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.2 \cdot 10^{+21} \lor \neg \left(d \leq 2 \cdot 10^{-34}\right):\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -3.2e21 or 1.99999999999999986e-34 < d Initial program 52.9%
*-un-lft-identity52.9%
add-sqr-sqrt52.9%
times-frac53.0%
hypot-def53.0%
fma-def53.0%
hypot-def66.4%
Applied egg-rr66.4%
associate-*l/66.4%
*-un-lft-identity66.4%
Applied egg-rr66.4%
Taylor expanded in c around 0 71.3%
*-commutative71.3%
unpow271.3%
times-frac78.9%
Simplified78.9%
if -3.2e21 < d < 1.99999999999999986e-34Initial program 70.9%
*-un-lft-identity70.9%
add-sqr-sqrt70.9%
times-frac70.8%
hypot-def70.8%
fma-def70.8%
hypot-def86.7%
Applied egg-rr86.7%
associate-*l/86.9%
*-un-lft-identity86.9%
Applied egg-rr86.9%
Taylor expanded in c around inf 72.8%
unpow272.8%
times-frac78.3%
Simplified78.3%
associate-*r/79.8%
Applied egg-rr79.8%
Final simplification79.4%
(FPCore (a b c d) :precision binary64 (if (<= c -1.68e-31) (+ (/ a c) (/ (* d (/ b c)) c)) (if (<= c 2.3e-68) (/ b d) (+ (/ a c) (* (/ b c) (/ d c))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.68e-31) {
tmp = (a / c) + ((d * (b / c)) / c);
} else if (c <= 2.3e-68) {
tmp = b / d;
} else {
tmp = (a / c) + ((b / c) * (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.68d-31)) then
tmp = (a / c) + ((d * (b / c)) / c)
else if (c <= 2.3d-68) then
tmp = b / d
else
tmp = (a / c) + ((b / c) * (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.68e-31) {
tmp = (a / c) + ((d * (b / c)) / c);
} else if (c <= 2.3e-68) {
tmp = b / d;
} else {
tmp = (a / c) + ((b / c) * (d / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.68e-31: tmp = (a / c) + ((d * (b / c)) / c) elif c <= 2.3e-68: tmp = b / d else: tmp = (a / c) + ((b / c) * (d / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.68e-31) tmp = Float64(Float64(a / c) + Float64(Float64(d * Float64(b / c)) / c)); elseif (c <= 2.3e-68) tmp = Float64(b / d); else tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.68e-31) tmp = (a / c) + ((d * (b / c)) / c); elseif (c <= 2.3e-68) tmp = b / d; else tmp = (a / c) + ((b / c) * (d / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.68e-31], N[(N[(a / c), $MachinePrecision] + N[(N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.3e-68], N[(b / d), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.68 \cdot 10^{-31}:\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\mathbf{elif}\;c \leq 2.3 \cdot 10^{-68}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\end{array}
if c < -1.6799999999999999e-31Initial program 56.6%
*-un-lft-identity56.6%
add-sqr-sqrt56.6%
times-frac56.6%
hypot-def56.6%
fma-def56.6%
hypot-def74.1%
Applied egg-rr74.1%
associate-*l/74.2%
*-un-lft-identity74.2%
Applied egg-rr74.2%
Taylor expanded in c around inf 68.3%
unpow268.3%
times-frac73.8%
Simplified73.8%
associate-*l/73.8%
Applied egg-rr73.8%
if -1.6799999999999999e-31 < c < 2.29999999999999997e-68Initial program 70.3%
Taylor expanded in c around 0 69.5%
if 2.29999999999999997e-68 < c Initial program 53.9%
*-un-lft-identity53.9%
add-sqr-sqrt53.9%
times-frac53.7%
hypot-def53.7%
fma-def53.7%
hypot-def71.9%
Applied egg-rr71.9%
Taylor expanded in c around inf 72.0%
unpow272.0%
*-commutative72.0%
times-frac76.3%
Simplified76.3%
Final simplification72.6%
(FPCore (a b c d) :precision binary64 (if (<= c -1.05e-32) (+ (/ a c) (/ (* d (/ b c)) c)) (if (<= c 2.1e-68) (/ b d) (+ (/ a c) (/ (* b (/ d c)) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.05e-32) {
tmp = (a / c) + ((d * (b / c)) / c);
} else if (c <= 2.1e-68) {
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 (c <= (-1.05d-32)) then
tmp = (a / c) + ((d * (b / c)) / c)
else if (c <= 2.1d-68) 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 (c <= -1.05e-32) {
tmp = (a / c) + ((d * (b / c)) / c);
} else if (c <= 2.1e-68) {
tmp = b / d;
} else {
tmp = (a / c) + ((b * (d / c)) / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.05e-32: tmp = (a / c) + ((d * (b / c)) / c) elif c <= 2.1e-68: tmp = b / d else: tmp = (a / c) + ((b * (d / c)) / c) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.05e-32) tmp = Float64(Float64(a / c) + Float64(Float64(d * Float64(b / c)) / c)); elseif (c <= 2.1e-68) tmp = Float64(b / d); else tmp = Float64(Float64(a / c) + Float64(Float64(b * Float64(d / c)) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.05e-32) tmp = (a / c) + ((d * (b / c)) / c); elseif (c <= 2.1e-68) tmp = b / d; else tmp = (a / c) + ((b * (d / c)) / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.05e-32], N[(N[(a / c), $MachinePrecision] + N[(N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.1e-68], N[(b / d), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.05 \cdot 10^{-32}:\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\mathbf{elif}\;c \leq 2.1 \cdot 10^{-68}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if c < -1.05e-32Initial program 56.6%
*-un-lft-identity56.6%
add-sqr-sqrt56.6%
times-frac56.6%
hypot-def56.6%
fma-def56.6%
hypot-def74.1%
Applied egg-rr74.1%
associate-*l/74.2%
*-un-lft-identity74.2%
Applied egg-rr74.2%
Taylor expanded in c around inf 68.3%
unpow268.3%
times-frac73.8%
Simplified73.8%
associate-*l/73.8%
Applied egg-rr73.8%
if -1.05e-32 < c < 2.10000000000000008e-68Initial program 70.3%
Taylor expanded in c around 0 69.5%
if 2.10000000000000008e-68 < c Initial program 53.9%
*-un-lft-identity53.9%
add-sqr-sqrt53.9%
times-frac53.7%
hypot-def53.7%
fma-def53.7%
hypot-def71.9%
Applied egg-rr71.9%
associate-*l/72.1%
*-un-lft-identity72.1%
Applied egg-rr72.1%
Taylor expanded in c around inf 72.0%
unpow272.0%
times-frac76.3%
Simplified76.3%
associate-*r/77.7%
Applied egg-rr77.7%
Final simplification73.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -8e+20)
(+ (/ b d) (/ (/ c d) (/ d a)))
(if (<= d 4e-34)
(+ (/ a c) (/ (* b (/ d c)) c))
(+ (/ b d) (* (/ c d) (/ a d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8e+20) {
tmp = (b / d) + ((c / d) / (d / a));
} else if (d <= 4e-34) {
tmp = (a / c) + ((b * (d / c)) / c);
} else {
tmp = (b / d) + ((c / d) * (a / d));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-8d+20)) then
tmp = (b / d) + ((c / d) / (d / a))
else if (d <= 4d-34) then
tmp = (a / c) + ((b * (d / c)) / c)
else
tmp = (b / d) + ((c / d) * (a / d))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8e+20) {
tmp = (b / d) + ((c / d) / (d / a));
} else if (d <= 4e-34) {
tmp = (a / c) + ((b * (d / c)) / c);
} else {
tmp = (b / d) + ((c / d) * (a / d));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -8e+20: tmp = (b / d) + ((c / d) / (d / a)) elif d <= 4e-34: tmp = (a / c) + ((b * (d / c)) / c) else: tmp = (b / d) + ((c / d) * (a / d)) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -8e+20) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) / Float64(d / a))); elseif (d <= 4e-34) tmp = Float64(Float64(a / c) + Float64(Float64(b * Float64(d / c)) / c)); else tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -8e+20) tmp = (b / d) + ((c / d) / (d / a)); elseif (d <= 4e-34) tmp = (a / c) + ((b * (d / c)) / c); else tmp = (b / d) + ((c / d) * (a / d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -8e+20], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] / N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4e-34], N[(N[(a / c), $MachinePrecision] + N[(N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision] / c), $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}\;d \leq -8 \cdot 10^{+20}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{c}{d}}{\frac{d}{a}}\\
\mathbf{elif}\;d \leq 4 \cdot 10^{-34}:\\
\;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\end{array}
\end{array}
if d < -8e20Initial program 46.0%
Taylor expanded in c around 0 70.3%
associate-/l*70.7%
associate-/r/70.6%
unpow270.6%
Simplified70.6%
associate-*l/70.3%
frac-times81.4%
clear-num81.4%
un-div-inv81.4%
Applied egg-rr81.4%
if -8e20 < d < 3.99999999999999971e-34Initial program 70.9%
*-un-lft-identity70.9%
add-sqr-sqrt70.9%
times-frac70.8%
hypot-def70.8%
fma-def70.8%
hypot-def86.7%
Applied egg-rr86.7%
associate-*l/86.9%
*-un-lft-identity86.9%
Applied egg-rr86.9%
Taylor expanded in c around inf 72.8%
unpow272.8%
times-frac78.3%
Simplified78.3%
associate-*r/79.8%
Applied egg-rr79.8%
if 3.99999999999999971e-34 < d Initial program 58.7%
*-un-lft-identity58.7%
add-sqr-sqrt58.7%
times-frac58.7%
hypot-def58.7%
fma-def58.7%
hypot-def69.2%
Applied egg-rr69.2%
associate-*l/69.3%
*-un-lft-identity69.3%
Applied egg-rr69.3%
Taylor expanded in c around 0 72.2%
*-commutative72.2%
unpow272.2%
times-frac76.9%
Simplified76.9%
Final simplification79.4%
(FPCore (a b c d)
:precision binary64
(if (<= c -2.8e+113)
(/ a c)
(if (or (<= c -4e+45) (and (not (<= c -5e-31)) (<= c 1.62e-68)))
(/ b d)
(/ a c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2.8e+113) {
tmp = a / c;
} else if ((c <= -4e+45) || (!(c <= -5e-31) && (c <= 1.62e-68))) {
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.8d+113)) then
tmp = a / c
else if ((c <= (-4d+45)) .or. (.not. (c <= (-5d-31))) .and. (c <= 1.62d-68)) 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.8e+113) {
tmp = a / c;
} else if ((c <= -4e+45) || (!(c <= -5e-31) && (c <= 1.62e-68))) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2.8e+113: tmp = a / c elif (c <= -4e+45) or (not (c <= -5e-31) and (c <= 1.62e-68)): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2.8e+113) tmp = Float64(a / c); elseif ((c <= -4e+45) || (!(c <= -5e-31) && (c <= 1.62e-68))) 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.8e+113) tmp = a / c; elseif ((c <= -4e+45) || (~((c <= -5e-31)) && (c <= 1.62e-68))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.8e+113], N[(a / c), $MachinePrecision], If[Or[LessEqual[c, -4e+45], And[N[Not[LessEqual[c, -5e-31]], $MachinePrecision], LessEqual[c, 1.62e-68]]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.8 \cdot 10^{+113}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq -4 \cdot 10^{+45} \lor \neg \left(c \leq -5 \cdot 10^{-31}\right) \land c \leq 1.62 \cdot 10^{-68}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -2.79999999999999998e113 or -3.9999999999999997e45 < c < -5e-31 or 1.62000000000000005e-68 < c Initial program 54.8%
Taylor expanded in c around inf 68.4%
if -2.79999999999999998e113 < c < -3.9999999999999997e45 or -5e-31 < c < 1.62000000000000005e-68Initial program 69.0%
Taylor expanded in c around 0 67.7%
Final simplification68.1%
(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.9%
Taylor expanded in c around inf 43.7%
Final simplification43.7%
(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 2023200
(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))))