
(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.im y.im) (* y.re x.re)) (+ (* y.im y.im) (* y.re y.re))))
(t_1 (/ (fma x.re (/ y.re y.im) x.im) y.im)))
(if (<= y.im -4.5e+91)
t_1
(if (<= y.im -2.95e-161)
t_0
(if (<= y.im 1.1e-129)
(/ (fma (/ x.im y.re) y.im x.re) y.re)
(if (<= y.im 7.2e+99) t_0 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_im * y_46_im) + (y_46_re * x_46_re)) / ((y_46_im * y_46_im) + (y_46_re * y_46_re));
double t_1 = fma(x_46_re, (y_46_re / y_46_im), x_46_im) / y_46_im;
double tmp;
if (y_46_im <= -4.5e+91) {
tmp = t_1;
} else if (y_46_im <= -2.95e-161) {
tmp = t_0;
} else if (y_46_im <= 1.1e-129) {
tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
} else if (y_46_im <= 7.2e+99) {
tmp = t_0;
} 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_im * y_46_im) + Float64(y_46_re * x_46_re)) / Float64(Float64(y_46_im * y_46_im) + Float64(y_46_re * y_46_re))) t_1 = Float64(fma(x_46_re, Float64(y_46_re / y_46_im), x_46_im) / y_46_im) tmp = 0.0 if (y_46_im <= -4.5e+91) tmp = t_1; elseif (y_46_im <= -2.95e-161) tmp = t_0; elseif (y_46_im <= 1.1e-129) tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re); elseif (y_46_im <= 7.2e+99) tmp = t_0; else tmp = t_1; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(x$46$im * y$46$im), $MachinePrecision] + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$im * y$46$im), $MachinePrecision] + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -4.5e+91], t$95$1, If[LessEqual[y$46$im, -2.95e-161], t$95$0, If[LessEqual[y$46$im, 1.1e-129], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 7.2e+99], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x.im \cdot y.im + y.re \cdot x.re}{y.im \cdot y.im + y.re \cdot y.re}\\
t_1 := \frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\
\mathbf{if}\;y.im \leq -4.5 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq -2.95 \cdot 10^{-161}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 1.1 \cdot 10^{-129}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\mathbf{elif}\;y.im \leq 7.2 \cdot 10^{+99}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.im < -4.5e91 or 7.2000000000000003e99 < y.im Initial program 28.8%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6489.8
Applied rewrites89.8%
Applied rewrites89.8%
if -4.5e91 < y.im < -2.9500000000000001e-161 or 1.10000000000000001e-129 < y.im < 7.2000000000000003e99Initial program 81.7%
if -2.9500000000000001e-161 < y.im < 1.10000000000000001e-129Initial program 73.8%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6490.5
Applied rewrites90.5%
Final simplification86.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -5e+144)
(/ x.im y.im)
(if (<= y.im -9e-18)
(* (/ x.im (fma y.im y.im (* y.re y.re))) y.im)
(if (<= y.im 2.5e-41)
(/ x.re y.re)
(if (<= y.im 1.02e+123)
(/ (fma y.re x.re (* x.im y.im)) (* y.im y.im))
(/ x.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_im <= -5e+144) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= -9e-18) {
tmp = (x_46_im / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * y_46_im;
} else if (y_46_im <= 2.5e-41) {
tmp = x_46_re / y_46_re;
} else if (y_46_im <= 1.02e+123) {
tmp = fma(y_46_re, x_46_re, (x_46_im * y_46_im)) / (y_46_im * y_46_im);
} else {
tmp = x_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_im <= -5e+144) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= -9e-18) tmp = Float64(Float64(x_46_im / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * y_46_im); elseif (y_46_im <= 2.5e-41) tmp = Float64(x_46_re / y_46_re); elseif (y_46_im <= 1.02e+123) tmp = Float64(fma(y_46_re, x_46_re, Float64(x_46_im * y_46_im)) / Float64(y_46_im * y_46_im)); else tmp = Float64(x_46_im / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -5e+144], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -9e-18], N[(N[(x$46$im / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 2.5e-41], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 1.02e+123], N[(N[(y$46$re * x$46$re + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -5 \cdot 10^{+144}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq -9 \cdot 10^{-18}:\\
\;\;\;\;\frac{x.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot y.im\\
\mathbf{elif}\;y.im \leq 2.5 \cdot 10^{-41}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.im \leq 1.02 \cdot 10^{+123}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.re, x.re, x.im \cdot y.im\right)}{y.im \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -4.9999999999999999e144 or 1.02e123 < y.im Initial program 26.0%
Taylor expanded in y.im around inf
lower-/.f6487.4
Applied rewrites87.4%
if -4.9999999999999999e144 < y.im < -8.99999999999999987e-18Initial program 69.7%
Taylor expanded in x.im around inf
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6463.3
Applied rewrites63.3%
if -8.99999999999999987e-18 < y.im < 2.4999999999999998e-41Initial program 77.5%
Taylor expanded in y.im around 0
lower-/.f6474.2
Applied rewrites74.2%
if 2.4999999999999998e-41 < y.im < 1.02e123Initial program 74.7%
Taylor expanded in y.im around inf
unpow2N/A
lower-*.f6457.6
Applied rewrites57.6%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6457.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6457.6
Applied rewrites57.6%
Final simplification74.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (fma y.im y.im (* y.re y.re))))
(if (<= y.im -5e+144)
(/ x.im y.im)
(if (<= y.im -9e-18)
(* (/ x.im t_0) y.im)
(if (<= y.im 6.5e-118)
(/ x.re y.re)
(if (<= y.im 1.18e+93) (* (/ y.im t_0) x.im) (/ x.im y.im)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma(y_46_im, y_46_im, (y_46_re * y_46_re));
double tmp;
if (y_46_im <= -5e+144) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= -9e-18) {
tmp = (x_46_im / t_0) * y_46_im;
} else if (y_46_im <= 6.5e-118) {
tmp = x_46_re / y_46_re;
} else if (y_46_im <= 1.18e+93) {
tmp = (y_46_im / t_0) * x_46_im;
} else {
tmp = x_46_im / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)) tmp = 0.0 if (y_46_im <= -5e+144) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= -9e-18) tmp = Float64(Float64(x_46_im / t_0) * y_46_im); elseif (y_46_im <= 6.5e-118) tmp = Float64(x_46_re / y_46_re); elseif (y_46_im <= 1.18e+93) tmp = Float64(Float64(y_46_im / t_0) * x_46_im); else tmp = Float64(x_46_im / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -5e+144], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -9e-18], N[(N[(x$46$im / t$95$0), $MachinePrecision] * y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 6.5e-118], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 1.18e+93], N[(N[(y$46$im / t$95$0), $MachinePrecision] * x$46$im), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\
\mathbf{if}\;y.im \leq -5 \cdot 10^{+144}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq -9 \cdot 10^{-18}:\\
\;\;\;\;\frac{x.im}{t\_0} \cdot y.im\\
\mathbf{elif}\;y.im \leq 6.5 \cdot 10^{-118}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.im \leq 1.18 \cdot 10^{+93}:\\
\;\;\;\;\frac{y.im}{t\_0} \cdot x.im\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -4.9999999999999999e144 or 1.1799999999999999e93 < y.im Initial program 29.0%
Taylor expanded in y.im around inf
lower-/.f6483.9
Applied rewrites83.9%
if -4.9999999999999999e144 < y.im < -8.99999999999999987e-18Initial program 69.7%
Taylor expanded in x.im around inf
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6463.3
Applied rewrites63.3%
if -8.99999999999999987e-18 < y.im < 6.49999999999999958e-118Initial program 76.2%
Taylor expanded in y.im around 0
lower-/.f6477.4
Applied rewrites77.4%
if 6.49999999999999958e-118 < y.im < 1.1799999999999999e93Initial program 79.6%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6452.2
Applied rewrites52.2%
Taylor expanded in x.im around inf
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6456.6
Applied rewrites56.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -2.5e+146)
(/ x.re y.re)
(if (<= y.re -1.6e+14)
(/ (fma y.im x.im (* y.re x.re)) (* y.re y.re))
(if (<= y.re 4e+77)
(/ (fma x.re (/ y.re y.im) 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_re <= -2.5e+146) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= -1.6e+14) {
tmp = fma(y_46_im, x_46_im, (y_46_re * x_46_re)) / (y_46_re * y_46_re);
} else if (y_46_re <= 4e+77) {
tmp = fma(x_46_re, (y_46_re / y_46_im), 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_re <= -2.5e+146) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= -1.6e+14) tmp = Float64(fma(y_46_im, x_46_im, Float64(y_46_re * x_46_re)) / Float64(y_46_re * y_46_re)); elseif (y_46_re <= 4e+77) tmp = Float64(fma(x_46_re, Float64(y_46_re / y_46_im), x_46_im) / y_46_im); else tmp = Float64(x_46_re / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -2.5e+146], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -1.6e+14], N[(N[(y$46$im * x$46$im + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 4e+77], N[(N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -2.5 \cdot 10^{+146}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq -1.6 \cdot 10^{+14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.re \cdot y.re}\\
\mathbf{elif}\;y.re \leq 4 \cdot 10^{+77}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -2.4999999999999999e146 or 3.99999999999999993e77 < y.re Initial program 43.4%
Taylor expanded in y.im around 0
lower-/.f6479.0
Applied rewrites79.0%
if -2.4999999999999999e146 < y.re < -1.6e14Initial program 69.7%
Taylor expanded in y.im around inf
*-commutativeN/A
lower-*.f6426.2
Applied rewrites26.2%
Taylor expanded in y.im around 0
unpow2N/A
lower-*.f6426.1
Applied rewrites26.1%
Taylor expanded in y.im around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6466.2
Applied rewrites66.2%
if -1.6e14 < y.re < 3.99999999999999993e77Initial program 68.9%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6481.1
Applied rewrites81.1%
Applied rewrites82.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma (/ x.im y.re) y.im x.re) y.re)))
(if (<= y.re -1.6e+14)
t_0
(if (<= y.re 2.05e+77) (/ (fma x.re (/ y.re y.im) x.im) y.im) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
double tmp;
if (y_46_re <= -1.6e+14) {
tmp = t_0;
} else if (y_46_re <= 2.05e+77) {
tmp = fma(x_46_re, (y_46_re / y_46_im), x_46_im) / y_46_im;
} else {
tmp = t_0;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re) tmp = 0.0 if (y_46_re <= -1.6e+14) tmp = t_0; elseif (y_46_re <= 2.05e+77) tmp = Float64(fma(x_46_re, Float64(y_46_re / y_46_im), x_46_im) / y_46_im); else tmp = t_0; end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -1.6e+14], t$95$0, If[LessEqual[y$46$re, 2.05e+77], N[(N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\mathbf{if}\;y.re \leq -1.6 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 2.05 \cdot 10^{+77}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.re, \frac{y.re}{y.im}, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.6e14 or 2.05e77 < y.re Initial program 49.9%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6481.0
Applied rewrites81.0%
if -1.6e14 < y.re < 2.05e77Initial program 68.9%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6481.1
Applied rewrites81.1%
Applied rewrites82.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -5e+144)
(/ x.im y.im)
(if (<= y.im -9e-18)
(* (/ x.im (fma y.im y.im (* y.re y.re))) y.im)
(if (<= y.im 2.9e+22) (/ x.re y.re) (/ x.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_im <= -5e+144) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= -9e-18) {
tmp = (x_46_im / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * y_46_im;
} else if (y_46_im <= 2.9e+22) {
tmp = x_46_re / y_46_re;
} else {
tmp = x_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_im <= -5e+144) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= -9e-18) tmp = Float64(Float64(x_46_im / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * y_46_im); elseif (y_46_im <= 2.9e+22) tmp = Float64(x_46_re / y_46_re); else tmp = Float64(x_46_im / y_46_im); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -5e+144], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -9e-18], N[(N[(x$46$im / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 2.9e+22], N[(x$46$re / y$46$re), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -5 \cdot 10^{+144}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq -9 \cdot 10^{-18}:\\
\;\;\;\;\frac{x.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot y.im\\
\mathbf{elif}\;y.im \leq 2.9 \cdot 10^{+22}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -4.9999999999999999e144 or 2.9e22 < y.im Initial program 36.1%
Taylor expanded in y.im around inf
lower-/.f6477.3
Applied rewrites77.3%
if -4.9999999999999999e144 < y.im < -8.99999999999999987e-18Initial program 69.7%
Taylor expanded in x.im around inf
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6463.3
Applied rewrites63.3%
if -8.99999999999999987e-18 < y.im < 2.9e22Initial program 77.6%
Taylor expanded in y.im around 0
lower-/.f6471.0
Applied rewrites71.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.im -7e-17) (/ x.im y.im) (if (<= y.im 2.9e+22) (/ x.re y.re) (/ x.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_im <= -7e-17) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 2.9e+22) {
tmp = x_46_re / y_46_re;
} else {
tmp = x_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_46im <= (-7d-17)) then
tmp = x_46im / y_46im
else if (y_46im <= 2.9d+22) then
tmp = x_46re / y_46re
else
tmp = x_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_im <= -7e-17) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 2.9e+22) {
tmp = x_46_re / y_46_re;
} else {
tmp = x_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_im <= -7e-17: tmp = x_46_im / y_46_im elif y_46_im <= 2.9e+22: tmp = x_46_re / y_46_re else: tmp = x_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_im <= -7e-17) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 2.9e+22) tmp = Float64(x_46_re / y_46_re); else tmp = Float64(x_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_im <= -7e-17) tmp = x_46_im / y_46_im; elseif (y_46_im <= 2.9e+22) tmp = x_46_re / y_46_re; else tmp = x_46_im / y_46_im; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -7e-17], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 2.9e+22], N[(x$46$re / y$46$re), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -7 \cdot 10^{-17}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 2.9 \cdot 10^{+22}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -7.0000000000000003e-17 or 2.9e22 < y.im Initial program 43.9%
Taylor expanded in y.im around inf
lower-/.f6470.7
Applied rewrites70.7%
if -7.0000000000000003e-17 < y.im < 2.9e22Initial program 77.6%
Taylor expanded in y.im around 0
lower-/.f6471.0
Applied rewrites71.0%
(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 61.1%
Taylor expanded in y.im around inf
lower-/.f6444.5
Applied rewrites44.5%
herbie shell --seed 2024242
(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))))