
(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))) 1e+269) (* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d))) (/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= 1e+269) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
} else {
tmp = (a + (b * (d / 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))) <= 1e+269) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d))); else tmp = Float64(Float64(a + Float64(b * Float64(d / 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], 1e+269], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq 10^{+269}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1e269Initial program 75.6%
*-un-lft-identity75.6%
associate-*r/75.6%
fma-define75.6%
add-sqr-sqrt75.6%
times-frac75.5%
fma-define75.5%
hypot-define75.5%
fma-define75.5%
fma-define75.5%
hypot-define94.5%
Applied egg-rr94.5%
if 1e269 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 11.8%
Taylor expanded in c around inf 60.1%
associate-/l*70.3%
Simplified70.3%
Final simplification88.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* a c) (* b d))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 1e+269)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(/ (+ a (* b (/ d c))) c))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+269) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+269) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = (a * c) + (b * d) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 1e+269: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (a + (b * (d / c))) / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+269) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a * c) + (b * d); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= 1e+269) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (a + (b * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+269], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
\mathbf{if}\;\frac{t\_0}{c \cdot c + d \cdot d} \leq 10^{+269}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t\_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1e269Initial program 75.6%
*-un-lft-identity75.6%
associate-*r/75.6%
fma-define75.6%
add-sqr-sqrt75.6%
times-frac75.5%
fma-define75.5%
hypot-define75.5%
fma-define75.5%
fma-define75.5%
hypot-define94.5%
Applied egg-rr94.5%
fma-define94.5%
+-commutative94.5%
Applied egg-rr94.5%
if 1e269 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 11.8%
Taylor expanded in c around inf 60.1%
associate-/l*70.3%
Simplified70.3%
Final simplification88.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ b (* a (/ c d)))))
(if (<= d -1.18e-42)
(* t_0 (/ -1.0 (hypot c d)))
(if (<= d 7.8e-62)
(/ (+ a (/ d (/ c b))) c)
(if (<= d 9.5e+123)
(/ (fma a c (* b d)) (fma c c (* d d)))
(/ t_0 d))))))
double code(double a, double b, double c, double d) {
double t_0 = b + (a * (c / d));
double tmp;
if (d <= -1.18e-42) {
tmp = t_0 * (-1.0 / hypot(c, d));
} else if (d <= 7.8e-62) {
tmp = (a + (d / (c / b))) / c;
} else if (d <= 9.5e+123) {
tmp = fma(a, c, (b * d)) / fma(c, c, (d * d));
} else {
tmp = t_0 / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(b + Float64(a * Float64(c / d))) tmp = 0.0 if (d <= -1.18e-42) tmp = Float64(t_0 * Float64(-1.0 / hypot(c, d))); elseif (d <= 7.8e-62) tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / c); elseif (d <= 9.5e+123) tmp = Float64(fma(a, c, Float64(b * d)) / fma(c, c, Float64(d * d))); else tmp = Float64(t_0 / d); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.18e-42], N[(t$95$0 * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.8e-62], N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 9.5e+123], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / d), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b + a \cdot \frac{c}{d}\\
\mathbf{if}\;d \leq -1.18 \cdot 10^{-42}:\\
\;\;\;\;t\_0 \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq 7.8 \cdot 10^{-62}:\\
\;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{c}\\
\mathbf{elif}\;d \leq 9.5 \cdot 10^{+123}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{d}\\
\end{array}
\end{array}
if d < -1.17999999999999995e-42Initial program 51.4%
*-un-lft-identity51.4%
associate-*r/51.4%
fma-define51.4%
add-sqr-sqrt51.4%
times-frac51.3%
fma-define51.3%
hypot-define51.3%
fma-define51.3%
fma-define51.3%
hypot-define69.8%
Applied egg-rr69.8%
Taylor expanded in d around -inf 68.1%
distribute-lft-out68.1%
associate-/l*69.8%
Simplified69.8%
if -1.17999999999999995e-42 < d < 7.8000000000000007e-62Initial program 63.5%
Taylor expanded in c around inf 89.3%
*-commutative89.3%
associate-/l*89.5%
Applied egg-rr89.5%
clear-num89.5%
un-div-inv89.5%
Applied egg-rr89.5%
if 7.8000000000000007e-62 < d < 9.4999999999999996e123Initial program 77.7%
fma-define77.8%
fma-define77.8%
Simplified77.8%
if 9.4999999999999996e123 < d Initial program 36.2%
Taylor expanded in d around inf 84.1%
associate-/l*93.7%
Simplified93.7%
Final simplification83.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ b (* a (/ c d)))))
(if (<= d -5e-43)
(* t_0 (/ -1.0 (hypot c d)))
(if (<= d 7.5e-62)
(/ (+ a (/ d (/ c b))) c)
(if (<= d 2.2e+127)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(/ t_0 d))))))
double code(double a, double b, double c, double d) {
double t_0 = b + (a * (c / d));
double tmp;
if (d <= -5e-43) {
tmp = t_0 * (-1.0 / hypot(c, d));
} else if (d <= 7.5e-62) {
tmp = (a + (d / (c / b))) / c;
} else if (d <= 2.2e+127) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = t_0 / d;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = b + (a * (c / d));
double tmp;
if (d <= -5e-43) {
tmp = t_0 * (-1.0 / Math.hypot(c, d));
} else if (d <= 7.5e-62) {
tmp = (a + (d / (c / b))) / c;
} else if (d <= 2.2e+127) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = t_0 / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = b + (a * (c / d)) tmp = 0 if d <= -5e-43: tmp = t_0 * (-1.0 / math.hypot(c, d)) elif d <= 7.5e-62: tmp = (a + (d / (c / b))) / c elif d <= 2.2e+127: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = t_0 / d return tmp
function code(a, b, c, d) t_0 = Float64(b + Float64(a * Float64(c / d))) tmp = 0.0 if (d <= -5e-43) tmp = Float64(t_0 * Float64(-1.0 / hypot(c, d))); elseif (d <= 7.5e-62) tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / c); elseif (d <= 2.2e+127) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(t_0 / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = b + (a * (c / d)); tmp = 0.0; if (d <= -5e-43) tmp = t_0 * (-1.0 / hypot(c, d)); elseif (d <= 7.5e-62) tmp = (a + (d / (c / b))) / c; elseif (d <= 2.2e+127) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = t_0 / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5e-43], N[(t$95$0 * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.5e-62], N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.2e+127], 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 / d), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b + a \cdot \frac{c}{d}\\
\mathbf{if}\;d \leq -5 \cdot 10^{-43}:\\
\;\;\;\;t\_0 \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{-62}:\\
\;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{c}\\
\mathbf{elif}\;d \leq 2.2 \cdot 10^{+127}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{d}\\
\end{array}
\end{array}
if d < -5.00000000000000019e-43Initial program 51.4%
*-un-lft-identity51.4%
associate-*r/51.4%
fma-define51.4%
add-sqr-sqrt51.4%
times-frac51.3%
fma-define51.3%
hypot-define51.3%
fma-define51.3%
fma-define51.3%
hypot-define69.8%
Applied egg-rr69.8%
Taylor expanded in d around -inf 68.1%
distribute-lft-out68.1%
associate-/l*69.8%
Simplified69.8%
if -5.00000000000000019e-43 < d < 7.5000000000000003e-62Initial program 63.5%
Taylor expanded in c around inf 89.3%
*-commutative89.3%
associate-/l*89.5%
Applied egg-rr89.5%
clear-num89.5%
un-div-inv89.5%
Applied egg-rr89.5%
if 7.5000000000000003e-62 < d < 2.2000000000000002e127Initial program 77.7%
if 2.2000000000000002e127 < d Initial program 36.2%
Taylor expanded in d around inf 84.1%
associate-/l*93.7%
Simplified93.7%
Final simplification83.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (/ (+ b (* a (/ c d))) d)))
(if (<= d -3.45e+106)
t_1
(if (<= d -3.25e-52)
t_0
(if (<= d 9.5e-62)
(/ (+ a (/ d (/ c b))) c)
(if (<= d 4.6e+125) 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 + (a * (c / d))) / d;
double tmp;
if (d <= -3.45e+106) {
tmp = t_1;
} else if (d <= -3.25e-52) {
tmp = t_0;
} else if (d <= 9.5e-62) {
tmp = (a + (d / (c / b))) / c;
} else if (d <= 4.6e+125) {
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 + (a * (c / d))) / d
if (d <= (-3.45d+106)) then
tmp = t_1
else if (d <= (-3.25d-52)) then
tmp = t_0
else if (d <= 9.5d-62) then
tmp = (a + (d / (c / b))) / c
else if (d <= 4.6d+125) 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 + (a * (c / d))) / d;
double tmp;
if (d <= -3.45e+106) {
tmp = t_1;
} else if (d <= -3.25e-52) {
tmp = t_0;
} else if (d <= 9.5e-62) {
tmp = (a + (d / (c / b))) / c;
} else if (d <= 4.6e+125) {
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 + (a * (c / d))) / d tmp = 0 if d <= -3.45e+106: tmp = t_1 elif d <= -3.25e-52: tmp = t_0 elif d <= 9.5e-62: tmp = (a + (d / (c / b))) / c elif d <= 4.6e+125: 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 + Float64(a * Float64(c / d))) / d) tmp = 0.0 if (d <= -3.45e+106) tmp = t_1; elseif (d <= -3.25e-52) tmp = t_0; elseif (d <= 9.5e-62) tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / c); elseif (d <= 4.6e+125) 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 + (a * (c / d))) / d; tmp = 0.0; if (d <= -3.45e+106) tmp = t_1; elseif (d <= -3.25e-52) tmp = t_0; elseif (d <= 9.5e-62) tmp = (a + (d / (c / b))) / c; elseif (d <= 4.6e+125) 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 + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -3.45e+106], t$95$1, If[LessEqual[d, -3.25e-52], t$95$0, If[LessEqual[d, 9.5e-62], N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.6e+125], 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 + a \cdot \frac{c}{d}}{d}\\
\mathbf{if}\;d \leq -3.45 \cdot 10^{+106}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -3.25 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 9.5 \cdot 10^{-62}:\\
\;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{c}\\
\mathbf{elif}\;d \leq 4.6 \cdot 10^{+125}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -3.4499999999999999e106 or 4.60000000000000026e125 < d Initial program 34.8%
Taylor expanded in d around inf 78.6%
associate-/l*86.3%
Simplified86.3%
if -3.4499999999999999e106 < d < -3.25e-52 or 9.49999999999999951e-62 < d < 4.60000000000000026e125Initial program 74.8%
if -3.25e-52 < d < 9.49999999999999951e-62Initial program 63.5%
Taylor expanded in c around inf 89.3%
*-commutative89.3%
associate-/l*89.5%
Applied egg-rr89.5%
clear-num89.5%
un-div-inv89.5%
Applied egg-rr89.5%
Final simplification84.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3e+73) (not (<= d 2.7e+71))) (/ b d) (/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3e+73) || !(d <= 2.7e+71)) {
tmp = b / d;
} else {
tmp = (a + (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 <= (-3d+73)) .or. (.not. (d <= 2.7d+71))) then
tmp = b / d
else
tmp = (a + (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 <= -3e+73) || !(d <= 2.7e+71)) {
tmp = b / d;
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3e+73) or not (d <= 2.7e+71): tmp = b / d else: tmp = (a + (b * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3e+73) || !(d <= 2.7e+71)) tmp = Float64(b / d); else tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -3e+73) || ~((d <= 2.7e+71))) tmp = b / d; else tmp = (a + (b * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3e+73], N[Not[LessEqual[d, 2.7e+71]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3 \cdot 10^{+73} \lor \neg \left(d \leq 2.7 \cdot 10^{+71}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -3.00000000000000011e73 or 2.69999999999999997e71 < d Initial program 44.5%
Taylor expanded in c around 0 71.7%
if -3.00000000000000011e73 < d < 2.69999999999999997e71Initial program 66.9%
Taylor expanded in c around inf 75.4%
associate-/l*75.6%
Simplified75.6%
Final simplification74.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -8.8e+73) (not (<= d 3.7e+71))) (/ b d) (/ (+ a (* d (/ b c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8.8e+73) || !(d <= 3.7e+71)) {
tmp = b / d;
} else {
tmp = (a + (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) :: tmp
if ((d <= (-8.8d+73)) .or. (.not. (d <= 3.7d+71))) then
tmp = b / d
else
tmp = (a + (d * (b / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8.8e+73) || !(d <= 3.7e+71)) {
tmp = b / d;
} else {
tmp = (a + (d * (b / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -8.8e+73) or not (d <= 3.7e+71): tmp = b / d else: tmp = (a + (d * (b / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -8.8e+73) || !(d <= 3.7e+71)) tmp = Float64(b / d); else tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -8.8e+73) || ~((d <= 3.7e+71))) tmp = b / d; else tmp = (a + (d * (b / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8.8e+73], N[Not[LessEqual[d, 3.7e+71]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.8 \cdot 10^{+73} \lor \neg \left(d \leq 3.7 \cdot 10^{+71}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\
\end{array}
\end{array}
if d < -8.8e73 or 3.7e71 < d Initial program 44.5%
Taylor expanded in c around 0 71.7%
if -8.8e73 < d < 3.7e71Initial program 66.9%
Taylor expanded in c around inf 75.4%
*-commutative75.4%
associate-/l*76.1%
Applied egg-rr76.1%
Final simplification74.7%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.8e+73) (not (<= d 1.95e+71))) (/ b d) (/ (+ a (/ d (/ c b))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.8e+73) || !(d <= 1.95e+71)) {
tmp = b / d;
} else {
tmp = (a + (d / (c / b))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-5.8d+73)) .or. (.not. (d <= 1.95d+71))) then
tmp = b / d
else
tmp = (a + (d / (c / b))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.8e+73) || !(d <= 1.95e+71)) {
tmp = b / d;
} else {
tmp = (a + (d / (c / b))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.8e+73) or not (d <= 1.95e+71): tmp = b / d else: tmp = (a + (d / (c / b))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.8e+73) || !(d <= 1.95e+71)) tmp = Float64(b / d); else tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -5.8e+73) || ~((d <= 1.95e+71))) tmp = b / d; else tmp = (a + (d / (c / b))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.8e+73], N[Not[LessEqual[d, 1.95e+71]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.8 \cdot 10^{+73} \lor \neg \left(d \leq 1.95 \cdot 10^{+71}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{c}\\
\end{array}
\end{array}
if d < -5.8000000000000005e73 or 1.9500000000000001e71 < d Initial program 44.5%
Taylor expanded in c around 0 71.7%
if -5.8000000000000005e73 < d < 1.9500000000000001e71Initial program 66.9%
Taylor expanded in c around inf 75.4%
*-commutative75.4%
associate-/l*76.1%
Applied egg-rr76.1%
clear-num76.1%
un-div-inv76.1%
Applied egg-rr76.1%
Final simplification74.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -4.4e+40)
(/ (+ a (/ d (/ c b))) c)
(if (<= c 12000000000.0)
(/ (+ b (* a (/ c d))) d)
(/ (+ a (* d (/ b c))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.4e+40) {
tmp = (a + (d / (c / b))) / c;
} else if (c <= 12000000000.0) {
tmp = (b + (a * (c / d))) / d;
} else {
tmp = (a + (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) :: tmp
if (c <= (-4.4d+40)) then
tmp = (a + (d / (c / b))) / c
else if (c <= 12000000000.0d0) then
tmp = (b + (a * (c / d))) / d
else
tmp = (a + (d * (b / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.4e+40) {
tmp = (a + (d / (c / b))) / c;
} else if (c <= 12000000000.0) {
tmp = (b + (a * (c / d))) / d;
} else {
tmp = (a + (d * (b / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -4.4e+40: tmp = (a + (d / (c / b))) / c elif c <= 12000000000.0: tmp = (b + (a * (c / d))) / d else: tmp = (a + (d * (b / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -4.4e+40) tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / c); elseif (c <= 12000000000.0) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); else tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -4.4e+40) tmp = (a + (d / (c / b))) / c; elseif (c <= 12000000000.0) tmp = (b + (a * (c / d))) / d; else tmp = (a + (d * (b / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.4e+40], N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 12000000000.0], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.4 \cdot 10^{+40}:\\
\;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{c}\\
\mathbf{elif}\;c \leq 12000000000:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\
\end{array}
\end{array}
if c < -4.3999999999999998e40Initial program 45.8%
Taylor expanded in c around inf 69.2%
*-commutative69.2%
associate-/l*76.5%
Applied egg-rr76.5%
clear-num76.5%
un-div-inv76.5%
Applied egg-rr76.5%
if -4.3999999999999998e40 < c < 1.2e10Initial program 74.3%
Taylor expanded in d around inf 73.7%
associate-/l*73.8%
Simplified73.8%
if 1.2e10 < c Initial program 41.0%
Taylor expanded in c around inf 85.3%
*-commutative85.3%
associate-/l*90.8%
Applied egg-rr90.8%
Final simplification78.3%
(FPCore (a b c d)
:precision binary64
(if (<= c -330000000.0)
(/ (+ a (/ d (/ c b))) c)
(if (<= c 11500000000.0)
(/ (+ b (/ (* a c) d)) d)
(/ (+ a (* d (/ b c))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -330000000.0) {
tmp = (a + (d / (c / b))) / c;
} else if (c <= 11500000000.0) {
tmp = (b + ((a * c) / d)) / d;
} else {
tmp = (a + (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) :: tmp
if (c <= (-330000000.0d0)) then
tmp = (a + (d / (c / b))) / c
else if (c <= 11500000000.0d0) then
tmp = (b + ((a * c) / d)) / d
else
tmp = (a + (d * (b / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -330000000.0) {
tmp = (a + (d / (c / b))) / c;
} else if (c <= 11500000000.0) {
tmp = (b + ((a * c) / d)) / d;
} else {
tmp = (a + (d * (b / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -330000000.0: tmp = (a + (d / (c / b))) / c elif c <= 11500000000.0: tmp = (b + ((a * c) / d)) / d else: tmp = (a + (d * (b / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -330000000.0) tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / c); elseif (c <= 11500000000.0) tmp = Float64(Float64(b + Float64(Float64(a * c) / d)) / d); else tmp = Float64(Float64(a + Float64(d * Float64(b / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -330000000.0) tmp = (a + (d / (c / b))) / c; elseif (c <= 11500000000.0) tmp = (b + ((a * c) / d)) / d; else tmp = (a + (d * (b / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -330000000.0], N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 11500000000.0], N[(N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -330000000:\\
\;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{c}\\
\mathbf{elif}\;c \leq 11500000000:\\
\;\;\;\;\frac{b + \frac{a \cdot c}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + d \cdot \frac{b}{c}}{c}\\
\end{array}
\end{array}
if c < -3.3e8Initial program 45.2%
Taylor expanded in c around inf 67.2%
*-commutative67.2%
associate-/l*73.6%
Applied egg-rr73.6%
clear-num73.6%
un-div-inv73.6%
Applied egg-rr73.6%
if -3.3e8 < c < 1.15e10Initial program 76.4%
Taylor expanded in d around inf 75.8%
if 1.15e10 < c Initial program 41.0%
Taylor expanded in c around inf 85.3%
*-commutative85.3%
associate-/l*90.8%
Applied egg-rr90.8%
Final simplification78.7%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.9e+41) (not (<= d 1.7e+71))) (/ b d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.9e+41) || !(d <= 1.7e+71)) {
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 <= (-5.9d+41)) .or. (.not. (d <= 1.7d+71))) 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 <= -5.9e+41) || !(d <= 1.7e+71)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.9e+41) or not (d <= 1.7e+71): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.9e+41) || !(d <= 1.7e+71)) 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 <= -5.9e+41) || ~((d <= 1.7e+71))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.9e+41], N[Not[LessEqual[d, 1.7e+71]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.9 \cdot 10^{+41} \lor \neg \left(d \leq 1.7 \cdot 10^{+71}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -5.9000000000000001e41 or 1.6999999999999999e71 < d Initial program 45.0%
Taylor expanded in c around 0 69.3%
if -5.9000000000000001e41 < d < 1.6999999999999999e71Initial program 67.4%
Taylor expanded in c around inf 63.9%
Final simplification65.7%
(FPCore (a b c d) :precision binary64 (if (<= d -4.2e+211) (/ a d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.2e+211) {
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 <= (-4.2d+211)) 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 <= -4.2e+211) {
tmp = a / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -4.2e+211: tmp = a / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -4.2e+211) 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 <= -4.2e+211) tmp = a / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.2e+211], N[(a / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.2 \cdot 10^{+211}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -4.2e211Initial program 40.5%
*-un-lft-identity40.5%
associate-*r/40.5%
fma-define40.5%
add-sqr-sqrt40.5%
times-frac40.5%
fma-define40.5%
hypot-define40.5%
fma-define40.5%
fma-define40.5%
hypot-define69.3%
Applied egg-rr69.3%
Taylor expanded in c around 0 40.7%
Taylor expanded in c around inf 41.7%
if -4.2e211 < d Initial program 61.2%
Taylor expanded in c around inf 50.4%
Final simplification49.9%
(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 59.9%
Taylor expanded in c around inf 48.1%
Final simplification48.1%
(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 2024077
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
:alt
(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))))