
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
code = ((x_46re * y_46re) + (x_46im * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
code = ((x_46re * y_46re) + (x_46im * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\end{array}
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))
(t_1 (* (/ y.im (hypot y.re y.im)) (/ x.im (hypot y.re y.im)))))
(if (<= y.im -1.2e+84)
t_1
(if (<= y.im -2.1e-35)
t_0
(if (<= y.im 4.8e-86)
(/ (+ x.re (/ (* x.im y.im) y.re)) y.re)
(if (<= y.im 1.8e+75)
t_0
(if (<= y.im 5.8e+136)
(/ (+ x.im (* x.re (/ y.re y.im))) y.im)
t_1)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
double t_1 = (y_46_im / hypot(y_46_re, y_46_im)) * (x_46_im / hypot(y_46_re, y_46_im));
double tmp;
if (y_46_im <= -1.2e+84) {
tmp = t_1;
} else if (y_46_im <= -2.1e-35) {
tmp = t_0;
} else if (y_46_im <= 4.8e-86) {
tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
} else if (y_46_im <= 1.8e+75) {
tmp = t_0;
} else if (y_46_im <= 5.8e+136) {
tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
double t_1 = (y_46_im / Math.hypot(y_46_re, y_46_im)) * (x_46_im / Math.hypot(y_46_re, y_46_im));
double tmp;
if (y_46_im <= -1.2e+84) {
tmp = t_1;
} else if (y_46_im <= -2.1e-35) {
tmp = t_0;
} else if (y_46_im <= 4.8e-86) {
tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
} else if (y_46_im <= 1.8e+75) {
tmp = t_0;
} else if (y_46_im <= 5.8e+136) {
tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im;
} else {
tmp = t_1;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)) t_1 = (y_46_im / math.hypot(y_46_re, y_46_im)) * (x_46_im / math.hypot(y_46_re, y_46_im)) tmp = 0 if y_46_im <= -1.2e+84: tmp = t_1 elif y_46_im <= -2.1e-35: tmp = t_0 elif y_46_im <= 4.8e-86: tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re elif y_46_im <= 1.8e+75: tmp = t_0 elif y_46_im <= 5.8e+136: tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im else: tmp = t_1 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) t_1 = Float64(Float64(y_46_im / hypot(y_46_re, y_46_im)) * Float64(x_46_im / hypot(y_46_re, y_46_im))) tmp = 0.0 if (y_46_im <= -1.2e+84) tmp = t_1; elseif (y_46_im <= -2.1e-35) tmp = t_0; elseif (y_46_im <= 4.8e-86) tmp = Float64(Float64(x_46_re + Float64(Float64(x_46_im * y_46_im) / y_46_re)) / y_46_re); elseif (y_46_im <= 1.8e+75) tmp = t_0; elseif (y_46_im <= 5.8e+136) tmp = Float64(Float64(x_46_im + Float64(x_46_re * Float64(y_46_re / y_46_im))) / y_46_im); else tmp = t_1; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); t_1 = (y_46_im / hypot(y_46_re, y_46_im)) * (x_46_im / hypot(y_46_re, y_46_im)); tmp = 0.0; if (y_46_im <= -1.2e+84) tmp = t_1; elseif (y_46_im <= -2.1e-35) tmp = t_0; elseif (y_46_im <= 4.8e-86) tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re; elseif (y_46_im <= 1.8e+75) tmp = t_0; elseif (y_46_im <= 5.8e+136) tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im; else tmp = t_1; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y$46$im / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] * N[(x$46$im / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -1.2e+84], t$95$1, If[LessEqual[y$46$im, -2.1e-35], t$95$0, If[LessEqual[y$46$im, 4.8e-86], N[(N[(x$46$re + N[(N[(x$46$im * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 1.8e+75], t$95$0, If[LessEqual[y$46$im, 5.8e+136], N[(N[(x$46$im + N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
t_1 := \frac{y.im}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im}{\mathsf{hypot}\left(y.re, y.im\right)}\\
\mathbf{if}\;y.im \leq -1.2 \cdot 10^{+84}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq -2.1 \cdot 10^{-35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 4.8 \cdot 10^{-86}:\\
\;\;\;\;\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}\\
\mathbf{elif}\;y.im \leq 1.8 \cdot 10^{+75}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 5.8 \cdot 10^{+136}:\\
\;\;\;\;\frac{x.im + x.re \cdot \frac{y.re}{y.im}}{y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.im < -1.2e84 or 5.79999999999999949e136 < y.im Initial program 36.4%
Taylor expanded in x.re around 0 34.2%
*-commutative34.2%
add-sqr-sqrt34.2%
hypot-undefine34.2%
hypot-undefine34.2%
times-frac84.9%
Applied egg-rr84.9%
if -1.2e84 < y.im < -2.1e-35 or 4.80000000000000026e-86 < y.im < 1.8e75Initial program 87.5%
if -2.1e-35 < y.im < 4.80000000000000026e-86Initial program 68.5%
Taylor expanded in y.re around inf 93.3%
if 1.8e75 < y.im < 5.79999999999999949e136Initial program 51.5%
Taylor expanded in y.im around inf 79.3%
associate-/l*86.1%
*-commutative86.1%
Applied egg-rr86.1%
Final simplification89.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<=
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))
INFINITY)
(/ (/ (fma x.re y.re (* x.im y.im)) (hypot y.re y.im)) (hypot y.re y.im))
(/ (+ x.re (* x.im (/ y.im y.re))) y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= ((double) INFINITY)) {
tmp = (fma(x_46_re, y_46_re, (x_46_im * y_46_im)) / hypot(y_46_re, y_46_im)) / hypot(y_46_re, y_46_im);
} else {
tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) <= Inf) tmp = Float64(Float64(fma(x_46_re, y_46_re, Float64(x_46_im * y_46_im)) / hypot(y_46_re, y_46_im)) / hypot(y_46_re, y_46_im)); else tmp = Float64(Float64(x_46_re + Float64(x_46_im * Float64(y_46_im / y_46_re))) / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(x$46$re * y$46$re + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re + N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \leq \infty:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x.re, y.re, x.im \cdot y.im\right)}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re + x.im \cdot \frac{y.im}{y.re}}{y.re}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 x.re y.re) (*.f64 x.im y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) < +inf.0Initial program 74.9%
add-sqr-sqrt74.9%
associate-/r*75.0%
fma-define75.0%
hypot-define75.0%
hypot-define94.2%
Applied egg-rr94.2%
if +inf.0 < (/.f64 (+.f64 (*.f64 x.re y.re) (*.f64 x.im y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) Initial program 0.0%
Taylor expanded in y.re around inf 44.4%
+-commutative44.4%
associate-/l*56.4%
fma-define56.4%
Simplified56.4%
fma-undefine56.4%
Applied egg-rr56.4%
Final simplification88.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (+ x.im (* x.re (/ y.re y.im))) y.im))
(t_1
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))))
(if (<= y.im -3.1e+108)
t_0
(if (<= y.im -1.5e+84)
(/ (+ x.re (* x.im (/ y.im y.re))) y.re)
(if (<= y.im -9.5e-36)
t_1
(if (<= y.im 1.56e-86)
(/ (+ x.re (/ (* x.im y.im) y.re)) y.re)
(if (<= y.im 3.6e+79) t_1 t_0)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im;
double t_1 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
double tmp;
if (y_46_im <= -3.1e+108) {
tmp = t_0;
} else if (y_46_im <= -1.5e+84) {
tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re;
} else if (y_46_im <= -9.5e-36) {
tmp = t_1;
} else if (y_46_im <= 1.56e-86) {
tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
} else if (y_46_im <= 3.6e+79) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x_46im + (x_46re * (y_46re / y_46im))) / y_46im
t_1 = ((x_46re * y_46re) + (x_46im * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
if (y_46im <= (-3.1d+108)) then
tmp = t_0
else if (y_46im <= (-1.5d+84)) then
tmp = (x_46re + (x_46im * (y_46im / y_46re))) / y_46re
else if (y_46im <= (-9.5d-36)) then
tmp = t_1
else if (y_46im <= 1.56d-86) then
tmp = (x_46re + ((x_46im * y_46im) / y_46re)) / y_46re
else if (y_46im <= 3.6d+79) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im;
double t_1 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
double tmp;
if (y_46_im <= -3.1e+108) {
tmp = t_0;
} else if (y_46_im <= -1.5e+84) {
tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re;
} else if (y_46_im <= -9.5e-36) {
tmp = t_1;
} else if (y_46_im <= 1.56e-86) {
tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
} else if (y_46_im <= 3.6e+79) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im t_1 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)) tmp = 0 if y_46_im <= -3.1e+108: tmp = t_0 elif y_46_im <= -1.5e+84: tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re elif y_46_im <= -9.5e-36: tmp = t_1 elif y_46_im <= 1.56e-86: tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re elif y_46_im <= 3.6e+79: tmp = t_1 else: tmp = t_0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(x_46_im + Float64(x_46_re * Float64(y_46_re / y_46_im))) / y_46_im) t_1 = Float64(Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) tmp = 0.0 if (y_46_im <= -3.1e+108) tmp = t_0; elseif (y_46_im <= -1.5e+84) tmp = Float64(Float64(x_46_re + Float64(x_46_im * Float64(y_46_im / y_46_re))) / y_46_re); elseif (y_46_im <= -9.5e-36) tmp = t_1; elseif (y_46_im <= 1.56e-86) tmp = Float64(Float64(x_46_re + Float64(Float64(x_46_im * y_46_im) / y_46_re)) / y_46_re); elseif (y_46_im <= 3.6e+79) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im; t_1 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); tmp = 0.0; if (y_46_im <= -3.1e+108) tmp = t_0; elseif (y_46_im <= -1.5e+84) tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re; elseif (y_46_im <= -9.5e-36) tmp = t_1; elseif (y_46_im <= 1.56e-86) tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re; elseif (y_46_im <= 3.6e+79) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im + N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -3.1e+108], t$95$0, If[LessEqual[y$46$im, -1.5e+84], N[(N[(x$46$re + N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, -9.5e-36], t$95$1, If[LessEqual[y$46$im, 1.56e-86], N[(N[(x$46$re + N[(N[(x$46$im * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 3.6e+79], t$95$1, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x.im + x.re \cdot \frac{y.re}{y.im}}{y.im}\\
t_1 := \frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{if}\;y.im \leq -3.1 \cdot 10^{+108}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq -1.5 \cdot 10^{+84}:\\
\;\;\;\;\frac{x.re + x.im \cdot \frac{y.im}{y.re}}{y.re}\\
\mathbf{elif}\;y.im \leq -9.5 \cdot 10^{-36}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq 1.56 \cdot 10^{-86}:\\
\;\;\;\;\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}\\
\mathbf{elif}\;y.im \leq 3.6 \cdot 10^{+79}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -3.1000000000000001e108 or 3.5999999999999999e79 < y.im Initial program 40.0%
Taylor expanded in y.im around inf 77.9%
associate-/l*82.8%
*-commutative82.8%
Applied egg-rr82.8%
if -3.1000000000000001e108 < y.im < -1.49999999999999998e84Initial program 23.7%
Taylor expanded in y.re around inf 67.6%
+-commutative67.6%
associate-/l*100.0%
fma-define100.0%
Simplified100.0%
fma-undefine100.0%
Applied egg-rr100.0%
if -1.49999999999999998e84 < y.im < -9.5000000000000003e-36 or 1.5599999999999999e-86 < y.im < 3.5999999999999999e79Initial program 87.5%
if -9.5000000000000003e-36 < y.im < 1.5599999999999999e-86Initial program 68.5%
Taylor expanded in y.re around inf 93.3%
Final simplification88.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -6.2e-51) (not (<= y.re 1.1e-46))) (/ (+ x.re (* x.im (/ y.im y.re))) y.re) (/ (+ x.im (/ (* x.re y.re) y.im)) y.im)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -6.2e-51) || !(y_46_re <= 1.1e-46)) {
tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re;
} else {
tmp = (x_46_im + ((x_46_re * y_46_re) / y_46_im)) / y_46_im;
}
return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: tmp
if ((y_46re <= (-6.2d-51)) .or. (.not. (y_46re <= 1.1d-46))) then
tmp = (x_46re + (x_46im * (y_46im / y_46re))) / y_46re
else
tmp = (x_46im + ((x_46re * y_46re) / y_46im)) / y_46im
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -6.2e-51) || !(y_46_re <= 1.1e-46)) {
tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re;
} else {
tmp = (x_46_im + ((x_46_re * y_46_re) / y_46_im)) / y_46_im;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re <= -6.2e-51) or not (y_46_re <= 1.1e-46): tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re else: tmp = (x_46_im + ((x_46_re * y_46_re) / y_46_im)) / y_46_im return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -6.2e-51) || !(y_46_re <= 1.1e-46)) tmp = Float64(Float64(x_46_re + Float64(x_46_im * Float64(y_46_im / y_46_re))) / y_46_re); else tmp = Float64(Float64(x_46_im + Float64(Float64(x_46_re * y_46_re) / y_46_im)) / y_46_im); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_re <= -6.2e-51) || ~((y_46_re <= 1.1e-46))) tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re; else tmp = (x_46_im + ((x_46_re * y_46_re) / y_46_im)) / y_46_im; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -6.2e-51], N[Not[LessEqual[y$46$re, 1.1e-46]], $MachinePrecision]], N[(N[(x$46$re + N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(x$46$im + N[(N[(x$46$re * y$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -6.2 \cdot 10^{-51} \lor \neg \left(y.re \leq 1.1 \cdot 10^{-46}\right):\\
\;\;\;\;\frac{x.re + x.im \cdot \frac{y.im}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im}\\
\end{array}
\end{array}
if y.re < -6.1999999999999995e-51 or 1.1e-46 < y.re Initial program 54.9%
Taylor expanded in y.re around inf 79.2%
+-commutative79.2%
associate-/l*82.5%
fma-define82.5%
Simplified82.5%
fma-undefine82.5%
Applied egg-rr82.5%
if -6.1999999999999995e-51 < y.re < 1.1e-46Initial program 74.0%
Taylor expanded in y.im around inf 84.6%
Final simplification83.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -2.1e-51) (not (<= y.re 1.25e-46))) (/ (+ x.re (/ (* x.im y.im) y.re)) y.re) (/ (+ x.im (/ (* x.re y.re) y.im)) y.im)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -2.1e-51) || !(y_46_re <= 1.25e-46)) {
tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
} else {
tmp = (x_46_im + ((x_46_re * y_46_re) / y_46_im)) / y_46_im;
}
return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: tmp
if ((y_46re <= (-2.1d-51)) .or. (.not. (y_46re <= 1.25d-46))) then
tmp = (x_46re + ((x_46im * y_46im) / y_46re)) / y_46re
else
tmp = (x_46im + ((x_46re * y_46re) / y_46im)) / y_46im
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -2.1e-51) || !(y_46_re <= 1.25e-46)) {
tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re;
} else {
tmp = (x_46_im + ((x_46_re * y_46_re) / y_46_im)) / y_46_im;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re <= -2.1e-51) or not (y_46_re <= 1.25e-46): tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re else: tmp = (x_46_im + ((x_46_re * y_46_re) / y_46_im)) / y_46_im return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_re <= -2.1e-51) || !(y_46_re <= 1.25e-46)) tmp = Float64(Float64(x_46_re + Float64(Float64(x_46_im * y_46_im) / y_46_re)) / y_46_re); else tmp = Float64(Float64(x_46_im + Float64(Float64(x_46_re * y_46_re) / y_46_im)) / y_46_im); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_re <= -2.1e-51) || ~((y_46_re <= 1.25e-46))) tmp = (x_46_re + ((x_46_im * y_46_im) / y_46_re)) / y_46_re; else tmp = (x_46_im + ((x_46_re * y_46_re) / y_46_im)) / y_46_im; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -2.1e-51], N[Not[LessEqual[y$46$re, 1.25e-46]], $MachinePrecision]], N[(N[(x$46$re + N[(N[(x$46$im * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(x$46$im + N[(N[(x$46$re * y$46$re), $MachinePrecision] / y$46$im), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -2.1 \cdot 10^{-51} \lor \neg \left(y.re \leq 1.25 \cdot 10^{-46}\right):\\
\;\;\;\;\frac{x.re + \frac{x.im \cdot y.im}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im + \frac{x.re \cdot y.re}{y.im}}{y.im}\\
\end{array}
\end{array}
if y.re < -2.10000000000000002e-51 or 1.24999999999999998e-46 < y.re Initial program 54.9%
Taylor expanded in y.re around inf 79.2%
if -2.10000000000000002e-51 < y.re < 1.24999999999999998e-46Initial program 74.0%
Taylor expanded in y.im around inf 84.6%
Final simplification81.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -4e-34) (not (<= y.im 1550000.0))) (/ (+ x.im (* x.re (/ y.re y.im))) y.im) (/ x.re y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_im <= -4e-34) || !(y_46_im <= 1550000.0)) {
tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im;
} else {
tmp = x_46_re / y_46_re;
}
return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: tmp
if ((y_46im <= (-4d-34)) .or. (.not. (y_46im <= 1550000.0d0))) then
tmp = (x_46im + (x_46re * (y_46re / y_46im))) / y_46im
else
tmp = x_46re / y_46re
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_im <= -4e-34) || !(y_46_im <= 1550000.0)) {
tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im;
} else {
tmp = x_46_re / y_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_im <= -4e-34) or not (y_46_im <= 1550000.0): tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im else: tmp = x_46_re / y_46_re return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_im <= -4e-34) || !(y_46_im <= 1550000.0)) tmp = Float64(Float64(x_46_im + Float64(x_46_re * Float64(y_46_re / y_46_im))) / y_46_im); else tmp = Float64(x_46_re / y_46_re); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_im <= -4e-34) || ~((y_46_im <= 1550000.0))) tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im; else tmp = x_46_re / y_46_re; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -4e-34], N[Not[LessEqual[y$46$im, 1550000.0]], $MachinePrecision]], N[(N[(x$46$im + N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -4 \cdot 10^{-34} \lor \neg \left(y.im \leq 1550000\right):\\
\;\;\;\;\frac{x.im + x.re \cdot \frac{y.re}{y.im}}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.im < -3.99999999999999971e-34 or 1.55e6 < y.im Initial program 55.3%
Taylor expanded in y.im around inf 69.6%
associate-/l*72.7%
*-commutative72.7%
Applied egg-rr72.7%
if -3.99999999999999971e-34 < y.im < 1.55e6Initial program 69.8%
Taylor expanded in y.re around inf 79.1%
Final simplification75.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -5.6e-34) (not (<= y.im 3800000.0))) (/ x.im y.im) (/ x.re y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_im <= -5.6e-34) || !(y_46_im <= 3800000.0)) {
tmp = x_46_im / y_46_im;
} else {
tmp = x_46_re / y_46_re;
}
return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: tmp
if ((y_46im <= (-5.6d-34)) .or. (.not. (y_46im <= 3800000.0d0))) then
tmp = x_46im / y_46im
else
tmp = x_46re / y_46re
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_im <= -5.6e-34) || !(y_46_im <= 3800000.0)) {
tmp = x_46_im / y_46_im;
} else {
tmp = x_46_re / y_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_im <= -5.6e-34) or not (y_46_im <= 3800000.0): tmp = x_46_im / y_46_im else: tmp = x_46_re / y_46_re return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_im <= -5.6e-34) || !(y_46_im <= 3800000.0)) tmp = Float64(x_46_im / y_46_im); else tmp = Float64(x_46_re / y_46_re); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_im <= -5.6e-34) || ~((y_46_im <= 3800000.0))) tmp = x_46_im / y_46_im; else tmp = x_46_re / y_46_re; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -5.6e-34], N[Not[LessEqual[y$46$im, 3800000.0]], $MachinePrecision]], N[(x$46$im / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -5.6 \cdot 10^{-34} \lor \neg \left(y.im \leq 3800000\right):\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.im < -5.59999999999999994e-34 or 3.8e6 < y.im Initial program 55.3%
Taylor expanded in y.re around 0 64.0%
if -5.59999999999999994e-34 < y.im < 3.8e6Initial program 69.8%
Taylor expanded in y.re around inf 79.1%
Final simplification71.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.im y.im))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / y_46_im;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
code = x_46im / y_46im
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / y_46_im;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return x_46_im / y_46_im
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(x_46_im / y_46_im) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = x_46_im / y_46_im; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$im), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.im}{y.im}
\end{array}
Initial program 62.6%
Taylor expanded in y.re around 0 36.9%
herbie shell --seed 2024096
(FPCore (x.re x.im y.re y.im)
:name "_divideComplex, real part"
:precision binary64
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im))))