
(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 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -1.7e+93)
(/ (- (/ (- b) (/ c d)) a) (hypot c d))
(if (<= c -7.6e-142)
t_0
(if (<= c 5.6e-160)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 7.2e-43)
t_0
(if (<= c 2.7e+147)
(+ (/ b d) (* (/ c d) (/ a d)))
(if (<= c 2e+166)
(/ (+ a (/ b (/ c d))) (hypot c d))
(* (/ c (hypot c d)) (/ a (hypot c d)))))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -1.7e+93) {
tmp = ((-b / (c / d)) - a) / hypot(c, d);
} else if (c <= -7.6e-142) {
tmp = t_0;
} else if (c <= 5.6e-160) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 7.2e-43) {
tmp = t_0;
} else if (c <= 2.7e+147) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (c <= 2e+166) {
tmp = (a + (b / (c / d))) / hypot(c, d);
} else {
tmp = (c / hypot(c, d)) * (a / hypot(c, d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -1.7e+93) {
tmp = ((-b / (c / d)) - a) / Math.hypot(c, d);
} else if (c <= -7.6e-142) {
tmp = t_0;
} else if (c <= 5.6e-160) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 7.2e-43) {
tmp = t_0;
} else if (c <= 2.7e+147) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (c <= 2e+166) {
tmp = (a + (b / (c / d))) / Math.hypot(c, d);
} else {
tmp = (c / Math.hypot(c, d)) * (a / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -1.7e+93: tmp = ((-b / (c / d)) - a) / math.hypot(c, d) elif c <= -7.6e-142: tmp = t_0 elif c <= 5.6e-160: tmp = (b / d) + (a / (d * (d / c))) elif c <= 7.2e-43: tmp = t_0 elif c <= 2.7e+147: tmp = (b / d) + ((c / d) * (a / d)) elif c <= 2e+166: tmp = (a + (b / (c / d))) / math.hypot(c, d) else: tmp = (c / math.hypot(c, d)) * (a / math.hypot(c, d)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -1.7e+93) tmp = Float64(Float64(Float64(Float64(-b) / Float64(c / d)) - a) / hypot(c, d)); elseif (c <= -7.6e-142) tmp = t_0; elseif (c <= 5.6e-160) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 7.2e-43) tmp = t_0; elseif (c <= 2.7e+147) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); elseif (c <= 2e+166) tmp = Float64(Float64(a + Float64(b / Float64(c / d))) / hypot(c, d)); else tmp = Float64(Float64(c / hypot(c, d)) * Float64(a / hypot(c, d))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -1.7e+93) tmp = ((-b / (c / d)) - a) / hypot(c, d); elseif (c <= -7.6e-142) tmp = t_0; elseif (c <= 5.6e-160) tmp = (b / d) + (a / (d * (d / c))); elseif (c <= 7.2e-43) tmp = t_0; elseif (c <= 2.7e+147) tmp = (b / d) + ((c / d) * (a / d)); elseif (c <= 2e+166) tmp = (a + (b / (c / d))) / hypot(c, d); else tmp = (c / hypot(c, d)) * (a / hypot(c, d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.7e+93], N[(N[(N[((-b) / N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -7.6e-142], t$95$0, If[LessEqual[c, 5.6e-160], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.2e-43], t$95$0, If[LessEqual[c, 2.7e+147], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2e+166], N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $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}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -1.7 \cdot 10^{+93}:\\
\;\;\;\;\frac{\frac{-b}{\frac{c}{d}} - a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -7.6 \cdot 10^{-142}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 5.6 \cdot 10^{-160}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 7.2 \cdot 10^{-43}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.7 \cdot 10^{+147}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;c \leq 2 \cdot 10^{+166}:\\
\;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{\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 c < -1.7e93Initial program 29.6%
*-un-lft-identity29.6%
add-sqr-sqrt29.6%
times-frac29.6%
hypot-def29.6%
fma-def29.6%
hypot-def50.4%
Applied egg-rr50.4%
associate-*l/50.5%
*-un-lft-identity50.5%
Applied egg-rr50.5%
Taylor expanded in c around -inf 80.8%
neg-mul-180.8%
+-commutative80.8%
unsub-neg80.8%
mul-1-neg80.8%
associate-/l*86.2%
distribute-neg-frac86.2%
Simplified86.2%
if -1.7e93 < c < -7.59999999999999944e-142 or 5.60000000000000032e-160 < c < 7.1999999999999998e-43Initial program 85.5%
if -7.59999999999999944e-142 < c < 5.60000000000000032e-160Initial program 66.7%
Taylor expanded in c around 0 85.5%
associate-/l*81.5%
Simplified81.5%
pow281.5%
*-un-lft-identity81.5%
times-frac93.1%
Applied egg-rr93.1%
/-rgt-identity93.1%
clear-num93.1%
un-div-inv93.1%
Applied egg-rr93.1%
associate-/r/93.1%
Simplified93.1%
if 7.1999999999999998e-43 < c < 2.69999999999999998e147Initial program 52.5%
Taylor expanded in c around 0 64.0%
associate-/l*64.0%
Simplified64.0%
pow264.0%
*-un-lft-identity64.0%
times-frac67.6%
Applied egg-rr67.6%
/-rgt-identity67.6%
*-un-lft-identity67.6%
*-commutative67.6%
times-frac67.7%
clear-num67.7%
Applied egg-rr67.7%
if 2.69999999999999998e147 < c < 1.99999999999999988e166Initial program 26.1%
*-un-lft-identity26.1%
add-sqr-sqrt26.1%
times-frac26.1%
hypot-def26.1%
fma-def26.1%
hypot-def51.7%
Applied egg-rr51.7%
associate-*l/51.7%
*-un-lft-identity51.7%
Applied egg-rr51.7%
Taylor expanded in c around inf 75.8%
associate-/l*100.0%
Simplified100.0%
if 1.99999999999999988e166 < c Initial program 27.6%
Taylor expanded in a around inf 27.9%
*-commutative27.9%
Simplified27.9%
add-sqr-sqrt27.9%
hypot-udef27.9%
hypot-udef27.9%
times-frac93.5%
Applied egg-rr93.5%
Final simplification87.0%
(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 77.5%
*-un-lft-identity77.5%
add-sqr-sqrt77.5%
times-frac77.6%
hypot-def77.6%
fma-def77.6%
hypot-def95.0%
Applied egg-rr95.0%
associate-*l/95.2%
*-un-lft-identity95.2%
Applied egg-rr95.2%
if +inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
Taylor expanded in a around inf 1.7%
*-commutative1.7%
Simplified1.7%
add-sqr-sqrt1.7%
hypot-udef1.7%
hypot-udef1.7%
times-frac55.5%
Applied egg-rr55.5%
Final simplification84.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -2.55e+94)
(+ (/ a c) (/ b (* c (/ c d))))
(if (<= c -1.25e-142)
t_0
(if (<= c 1.52e-158)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 8.6e+23) t_0 (/ (+ a (/ b (/ 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 <= -2.55e+94) {
tmp = (a / c) + (b / (c * (c / d)));
} else if (c <= -1.25e-142) {
tmp = t_0;
} else if (c <= 1.52e-158) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 8.6e+23) {
tmp = t_0;
} else {
tmp = (a + (b / (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 <= -2.55e+94) {
tmp = (a / c) + (b / (c * (c / d)));
} else if (c <= -1.25e-142) {
tmp = t_0;
} else if (c <= 1.52e-158) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 8.6e+23) {
tmp = t_0;
} else {
tmp = (a + (b / (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 <= -2.55e+94: tmp = (a / c) + (b / (c * (c / d))) elif c <= -1.25e-142: tmp = t_0 elif c <= 1.52e-158: tmp = (b / d) + (a / (d * (d / c))) elif c <= 8.6e+23: tmp = t_0 else: tmp = (a + (b / (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 <= -2.55e+94) tmp = Float64(Float64(a / c) + Float64(b / Float64(c * Float64(c / d)))); elseif (c <= -1.25e-142) tmp = t_0; elseif (c <= 1.52e-158) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 8.6e+23) tmp = t_0; else tmp = Float64(Float64(a + Float64(b / Float64(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 <= -2.55e+94) tmp = (a / c) + (b / (c * (c / d))); elseif (c <= -1.25e-142) tmp = t_0; elseif (c <= 1.52e-158) tmp = (b / d) + (a / (d * (d / c))); elseif (c <= 8.6e+23) tmp = t_0; else tmp = (a + (b / (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, -2.55e+94], N[(N[(a / c), $MachinePrecision] + N[(b / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.25e-142], t$95$0, If[LessEqual[c, 1.52e-158], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 8.6e+23], t$95$0, N[(N[(a + N[(b / N[(c / d), $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 -2.55 \cdot 10^{+94}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;c \leq -1.25 \cdot 10^{-142}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.52 \cdot 10^{-158}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 8.6 \cdot 10^{+23}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -2.5500000000000002e94Initial program 29.6%
Taylor expanded in c around inf 78.4%
associate-/l*80.6%
Simplified80.6%
div-inv80.6%
unpow280.6%
associate-*l*82.6%
div-inv82.6%
Applied egg-rr82.6%
if -2.5500000000000002e94 < c < -1.2500000000000001e-142 or 1.52e-158 < c < 8.5999999999999997e23Initial program 82.2%
if -1.2500000000000001e-142 < c < 1.52e-158Initial program 66.7%
Taylor expanded in c around 0 85.5%
associate-/l*81.5%
Simplified81.5%
pow281.5%
*-un-lft-identity81.5%
times-frac93.1%
Applied egg-rr93.1%
/-rgt-identity93.1%
clear-num93.1%
un-div-inv93.1%
Applied egg-rr93.1%
associate-/r/93.1%
Simplified93.1%
if 8.5999999999999997e23 < c Initial program 35.5%
*-un-lft-identity35.5%
add-sqr-sqrt35.5%
times-frac35.5%
hypot-def35.5%
fma-def35.5%
hypot-def51.1%
Applied egg-rr51.1%
associate-*l/51.3%
*-un-lft-identity51.3%
Applied egg-rr51.3%
Taylor expanded in c around inf 72.5%
associate-/l*74.7%
Simplified74.7%
Final simplification83.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -1.9e+93)
(/ (- (/ (- b) (/ c d)) a) (hypot c d))
(if (<= c -7.5e-140)
t_0
(if (<= c 3.5e-158)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 8.8e+23) t_0 (/ (+ a (/ b (/ 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 <= -1.9e+93) {
tmp = ((-b / (c / d)) - a) / hypot(c, d);
} else if (c <= -7.5e-140) {
tmp = t_0;
} else if (c <= 3.5e-158) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 8.8e+23) {
tmp = t_0;
} else {
tmp = (a + (b / (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 <= -1.9e+93) {
tmp = ((-b / (c / d)) - a) / Math.hypot(c, d);
} else if (c <= -7.5e-140) {
tmp = t_0;
} else if (c <= 3.5e-158) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 8.8e+23) {
tmp = t_0;
} else {
tmp = (a + (b / (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 <= -1.9e+93: tmp = ((-b / (c / d)) - a) / math.hypot(c, d) elif c <= -7.5e-140: tmp = t_0 elif c <= 3.5e-158: tmp = (b / d) + (a / (d * (d / c))) elif c <= 8.8e+23: tmp = t_0 else: tmp = (a + (b / (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 <= -1.9e+93) tmp = Float64(Float64(Float64(Float64(-b) / Float64(c / d)) - a) / hypot(c, d)); elseif (c <= -7.5e-140) tmp = t_0; elseif (c <= 3.5e-158) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 8.8e+23) tmp = t_0; else tmp = Float64(Float64(a + Float64(b / Float64(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 <= -1.9e+93) tmp = ((-b / (c / d)) - a) / hypot(c, d); elseif (c <= -7.5e-140) tmp = t_0; elseif (c <= 3.5e-158) tmp = (b / d) + (a / (d * (d / c))); elseif (c <= 8.8e+23) tmp = t_0; else tmp = (a + (b / (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, -1.9e+93], N[(N[(N[((-b) / N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -7.5e-140], t$95$0, If[LessEqual[c, 3.5e-158], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 8.8e+23], t$95$0, N[(N[(a + N[(b / N[(c / d), $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 -1.9 \cdot 10^{+93}:\\
\;\;\;\;\frac{\frac{-b}{\frac{c}{d}} - a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -7.5 \cdot 10^{-140}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.5 \cdot 10^{-158}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 8.8 \cdot 10^{+23}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -1.8999999999999999e93Initial program 29.6%
*-un-lft-identity29.6%
add-sqr-sqrt29.6%
times-frac29.6%
hypot-def29.6%
fma-def29.6%
hypot-def50.4%
Applied egg-rr50.4%
associate-*l/50.5%
*-un-lft-identity50.5%
Applied egg-rr50.5%
Taylor expanded in c around -inf 80.8%
neg-mul-180.8%
+-commutative80.8%
unsub-neg80.8%
mul-1-neg80.8%
associate-/l*86.2%
distribute-neg-frac86.2%
Simplified86.2%
if -1.8999999999999999e93 < c < -7.4999999999999998e-140 or 3.50000000000000012e-158 < c < 8.80000000000000034e23Initial program 82.2%
if -7.4999999999999998e-140 < c < 3.50000000000000012e-158Initial program 66.7%
Taylor expanded in c around 0 85.5%
associate-/l*81.5%
Simplified81.5%
pow281.5%
*-un-lft-identity81.5%
times-frac93.1%
Applied egg-rr93.1%
/-rgt-identity93.1%
clear-num93.1%
un-div-inv93.1%
Applied egg-rr93.1%
associate-/r/93.1%
Simplified93.1%
if 8.80000000000000034e23 < c Initial program 35.5%
*-un-lft-identity35.5%
add-sqr-sqrt35.5%
times-frac35.5%
hypot-def35.5%
fma-def35.5%
hypot-def51.1%
Applied egg-rr51.1%
associate-*l/51.3%
*-un-lft-identity51.3%
Applied egg-rr51.3%
Taylor expanded in c around inf 72.5%
associate-/l*74.7%
Simplified74.7%
Final simplification84.5%
(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 -5.5e+64)
t_1
(if (<= d -2.5e-128)
t_0
(if (<= d 3.9e-106)
(+ (/ a c) (/ b (* c (/ c d))))
(if (<= d 4.2e+110) 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 <= -5.5e+64) {
tmp = t_1;
} else if (d <= -2.5e-128) {
tmp = t_0;
} else if (d <= 3.9e-106) {
tmp = (a / c) + (b / (c * (c / d)));
} else if (d <= 4.2e+110) {
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 <= (-5.5d+64)) then
tmp = t_1
else if (d <= (-2.5d-128)) then
tmp = t_0
else if (d <= 3.9d-106) then
tmp = (a / c) + (b / (c * (c / d)))
else if (d <= 4.2d+110) 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 <= -5.5e+64) {
tmp = t_1;
} else if (d <= -2.5e-128) {
tmp = t_0;
} else if (d <= 3.9e-106) {
tmp = (a / c) + (b / (c * (c / d)));
} else if (d <= 4.2e+110) {
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 <= -5.5e+64: tmp = t_1 elif d <= -2.5e-128: tmp = t_0 elif d <= 3.9e-106: tmp = (a / c) + (b / (c * (c / d))) elif d <= 4.2e+110: 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 <= -5.5e+64) tmp = t_1; elseif (d <= -2.5e-128) tmp = t_0; elseif (d <= 3.9e-106) tmp = Float64(Float64(a / c) + Float64(b / Float64(c * Float64(c / d)))); elseif (d <= 4.2e+110) 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 <= -5.5e+64) tmp = t_1; elseif (d <= -2.5e-128) tmp = t_0; elseif (d <= 3.9e-106) tmp = (a / c) + (b / (c * (c / d))); elseif (d <= 4.2e+110) 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, -5.5e+64], t$95$1, If[LessEqual[d, -2.5e-128], t$95$0, If[LessEqual[d, 3.9e-106], N[(N[(a / c), $MachinePrecision] + N[(b / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.2e+110], 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 -5.5 \cdot 10^{+64}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-128}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.9 \cdot 10^{-106}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;d \leq 4.2 \cdot 10^{+110}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d < -5.4999999999999996e64 or 4.2000000000000003e110 < d Initial program 28.5%
Taylor expanded in c around 0 68.9%
associate-/l*71.7%
Simplified71.7%
pow271.7%
*-un-lft-identity71.7%
times-frac74.5%
Applied egg-rr74.5%
/-rgt-identity74.5%
*-un-lft-identity74.5%
*-commutative74.5%
times-frac78.6%
clear-num78.6%
Applied egg-rr78.6%
if -5.4999999999999996e64 < d < -2.5000000000000001e-128 or 3.9000000000000001e-106 < d < 4.2000000000000003e110Initial program 82.2%
if -2.5000000000000001e-128 < d < 3.9000000000000001e-106Initial program 66.5%
Taylor expanded in c around inf 84.1%
associate-/l*84.3%
Simplified84.3%
div-inv84.3%
unpow284.3%
associate-*l*87.7%
div-inv87.7%
Applied egg-rr87.7%
Final simplification82.7%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.65e-19) (not (<= d 1.05e-9))) (/ b d) (+ (/ a c) (/ b (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.65e-19) || !(d <= 1.05e-9)) {
tmp = b / d;
} else {
tmp = (a / c) + (b / (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 ((d <= (-1.65d-19)) .or. (.not. (d <= 1.05d-9))) then
tmp = b / d
else
tmp = (a / c) + (b / (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.65e-19) || !(d <= 1.05e-9)) {
tmp = b / d;
} else {
tmp = (a / c) + (b / (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.65e-19) or not (d <= 1.05e-9): tmp = b / d else: tmp = (a / c) + (b / (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.65e-19) || !(d <= 1.05e-9)) tmp = Float64(b / d); else tmp = Float64(Float64(a / c) + Float64(b / Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.65e-19) || ~((d <= 1.05e-9))) tmp = b / d; else tmp = (a / c) + (b / (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.65e-19], N[Not[LessEqual[d, 1.05e-9]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(b / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.65 \cdot 10^{-19} \lor \neg \left(d \leq 1.05 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if d < -1.6499999999999999e-19 or 1.0500000000000001e-9 < d Initial program 42.5%
Taylor expanded in c around 0 65.3%
if -1.6499999999999999e-19 < d < 1.0500000000000001e-9Initial program 72.2%
Taylor expanded in c around inf 76.2%
associate-/l*76.4%
Simplified76.4%
div-inv76.4%
unpow276.4%
associate-*l*78.7%
div-inv78.7%
Applied egg-rr78.7%
Final simplification71.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3.5e-19) (not (<= d 6e-10))) (+ (/ b d) (* (/ c d) (/ a d))) (+ (/ a c) (/ b (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.5e-19) || !(d <= 6e-10)) {
tmp = (b / d) + ((c / d) * (a / d));
} else {
tmp = (a / c) + (b / (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 ((d <= (-3.5d-19)) .or. (.not. (d <= 6d-10))) then
tmp = (b / d) + ((c / d) * (a / d))
else
tmp = (a / c) + (b / (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.5e-19) || !(d <= 6e-10)) {
tmp = (b / d) + ((c / d) * (a / d));
} else {
tmp = (a / c) + (b / (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3.5e-19) or not (d <= 6e-10): tmp = (b / d) + ((c / d) * (a / d)) else: tmp = (a / c) + (b / (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3.5e-19) || !(d <= 6e-10)) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); else tmp = Float64(Float64(a / c) + Float64(b / Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -3.5e-19) || ~((d <= 6e-10))) tmp = (b / d) + ((c / d) * (a / d)); else tmp = (a / c) + (b / (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.5e-19], N[Not[LessEqual[d, 6e-10]], $MachinePrecision]], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(b / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.5 \cdot 10^{-19} \lor \neg \left(d \leq 6 \cdot 10^{-10}\right):\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if d < -3.50000000000000015e-19 or 6e-10 < d Initial program 42.5%
Taylor expanded in c around 0 69.1%
associate-/l*69.0%
Simplified69.0%
pow269.0%
*-un-lft-identity69.0%
times-frac71.1%
Applied egg-rr71.1%
/-rgt-identity71.1%
*-un-lft-identity71.1%
*-commutative71.1%
times-frac74.8%
clear-num75.3%
Applied egg-rr75.3%
if -3.50000000000000015e-19 < d < 6e-10Initial program 72.2%
Taylor expanded in c around inf 76.2%
associate-/l*76.4%
Simplified76.4%
div-inv76.4%
unpow276.4%
associate-*l*78.7%
div-inv78.7%
Applied egg-rr78.7%
Final simplification77.0%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.6e-30) (not (<= d 2.1e-75))) (/ b d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.6e-30) || !(d <= 2.1e-75)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-1.6d-30)) .or. (.not. (d <= 2.1d-75))) then
tmp = b / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.6e-30) || !(d <= 2.1e-75)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.6e-30) or not (d <= 2.1e-75): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.6e-30) || !(d <= 2.1e-75)) tmp = Float64(b / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.6e-30) || ~((d <= 2.1e-75))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.6e-30], N[Not[LessEqual[d, 2.1e-75]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.6 \cdot 10^{-30} \lor \neg \left(d \leq 2.1 \cdot 10^{-75}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -1.6e-30 or 2.1000000000000001e-75 < d Initial program 47.0%
Taylor expanded in c around 0 63.2%
if -1.6e-30 < d < 2.1000000000000001e-75Initial program 69.6%
Taylor expanded in c around inf 67.3%
Final simplification65.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 57.2%
Taylor expanded in c around inf 44.6%
Final simplification44.6%
(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 2024020
(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))))