
(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 9 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 (/ (fma y.im x.im (* x.re y.re)) (fma y.im y.im (* y.re y.re)))))
(if (<= y.im -1.45e+112)
(/ (fma (/ y.re y.im) x.re x.im) y.im)
(if (<= y.im -4.6e-119)
t_0
(if (<= y.im 1.26e-65)
(/ (fma (/ y.im y.re) x.im x.re) y.re)
(if (<= y.im 3e+49)
t_0
(/ (fma (* (- y.re) (/ -1.0 y.im)) x.re 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, x_46_im, (x_46_re * y_46_re)) / fma(y_46_im, y_46_im, (y_46_re * y_46_re));
double tmp;
if (y_46_im <= -1.45e+112) {
tmp = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
} else if (y_46_im <= -4.6e-119) {
tmp = t_0;
} else if (y_46_im <= 1.26e-65) {
tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
} else if (y_46_im <= 3e+49) {
tmp = t_0;
} else {
tmp = fma((-y_46_re * (-1.0 / y_46_im)), x_46_re, x_46_im) / y_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(fma(y_46_im, x_46_im, Float64(x_46_re * y_46_re)) / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) tmp = 0.0 if (y_46_im <= -1.45e+112) tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im); elseif (y_46_im <= -4.6e-119) tmp = t_0; elseif (y_46_im <= 1.26e-65) tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re); elseif (y_46_im <= 3e+49) tmp = t_0; else tmp = Float64(fma(Float64(Float64(-y_46_re) * Float64(-1.0 / y_46_im)), x_46_re, 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[(N[(y$46$im * x$46$im + N[(x$46$re * y$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -1.45e+112], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -4.6e-119], t$95$0, If[LessEqual[y$46$im, 1.26e-65], N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 3e+49], t$95$0, N[(N[(N[((-y$46$re) * N[(-1.0 / y$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(y.im, x.im, x.re \cdot y.re\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
\mathbf{if}\;y.im \leq -1.45 \cdot 10^{+112}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\mathbf{elif}\;y.im \leq -4.6 \cdot 10^{-119}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 1.26 \cdot 10^{-65}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\mathbf{elif}\;y.im \leq 3 \cdot 10^{+49}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(-y.re\right) \cdot \frac{-1}{y.im}, x.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -1.4500000000000001e112Initial program 46.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6446.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6446.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6446.2
Applied rewrites46.2%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6492.4
Applied rewrites92.4%
if -1.4500000000000001e112 < y.im < -4.59999999999999987e-119 or 1.26e-65 < y.im < 3.0000000000000002e49Initial program 82.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6482.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6482.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6482.7
Applied rewrites82.7%
if -4.59999999999999987e-119 < y.im < 1.26e-65Initial program 67.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6467.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6467.8
Applied rewrites67.8%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6494.6
Applied rewrites94.6%
if 3.0000000000000002e49 < y.im Initial program 40.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6440.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6440.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6440.5
Applied rewrites40.5%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6484.3
Applied rewrites84.3%
Applied rewrites84.3%
Final simplification88.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma y.im x.im (* x.re y.re)) (fma y.im y.im (* y.re y.re))))
(t_1 (/ (fma (/ y.re y.im) x.re x.im) y.im)))
(if (<= y.im -1.45e+112)
t_1
(if (<= y.im -4.6e-119)
t_0
(if (<= y.im 1.26e-65)
(/ (fma (/ y.im y.re) x.im x.re) y.re)
(if (<= y.im 3e+49) 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 = fma(y_46_im, x_46_im, (x_46_re * y_46_re)) / fma(y_46_im, y_46_im, (y_46_re * y_46_re));
double t_1 = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
double tmp;
if (y_46_im <= -1.45e+112) {
tmp = t_1;
} else if (y_46_im <= -4.6e-119) {
tmp = t_0;
} else if (y_46_im <= 1.26e-65) {
tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
} else if (y_46_im <= 3e+49) {
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(fma(y_46_im, x_46_im, Float64(x_46_re * y_46_re)) / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) t_1 = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im) tmp = 0.0 if (y_46_im <= -1.45e+112) tmp = t_1; elseif (y_46_im <= -4.6e-119) tmp = t_0; elseif (y_46_im <= 1.26e-65) tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re); elseif (y_46_im <= 3e+49) 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[(y$46$im * x$46$im + N[(x$46$re * y$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -1.45e+112], t$95$1, If[LessEqual[y$46$im, -4.6e-119], t$95$0, If[LessEqual[y$46$im, 1.26e-65], N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 3e+49], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(y.im, x.im, x.re \cdot y.re\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
t_1 := \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\mathbf{if}\;y.im \leq -1.45 \cdot 10^{+112}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq -4.6 \cdot 10^{-119}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 1.26 \cdot 10^{-65}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\mathbf{elif}\;y.im \leq 3 \cdot 10^{+49}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.im < -1.4500000000000001e112 or 3.0000000000000002e49 < y.im Initial program 42.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6442.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6442.8
Applied rewrites42.8%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6487.6
Applied rewrites87.6%
if -1.4500000000000001e112 < y.im < -4.59999999999999987e-119 or 1.26e-65 < y.im < 3.0000000000000002e49Initial program 82.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6482.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6482.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6482.7
Applied rewrites82.7%
if -4.59999999999999987e-119 < y.im < 1.26e-65Initial program 67.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6467.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6467.8
Applied rewrites67.8%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6494.6
Applied rewrites94.6%
Final simplification88.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -3.2e-21)
(/ (fma (/ x.re y.im) y.re x.im) y.im)
(if (<= y.im 1.66e-65)
(/ (fma (/ y.im y.re) x.im x.re) y.re)
(/ (fma (/ y.re y.im) x.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 <= -3.2e-21) {
tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
} else if (y_46_im <= 1.66e-65) {
tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
} else {
tmp = fma((y_46_re / y_46_im), x_46_re, 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 <= -3.2e-21) tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im); elseif (y_46_im <= 1.66e-65) tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re); else tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, 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, -3.2e-21], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 1.66e-65], N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -3.2 \cdot 10^{-21}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\mathbf{elif}\;y.im \leq 1.66 \cdot 10^{-65}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.im < -3.2000000000000002e-21Initial program 62.0%
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-/.f6483.3
Applied rewrites83.3%
if -3.2000000000000002e-21 < y.im < 1.6599999999999999e-65Initial program 69.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6469.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6469.7
Applied rewrites69.7%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6490.4
Applied rewrites90.4%
if 1.6599999999999999e-65 < y.im Initial program 54.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6454.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6454.4
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6454.4
Applied rewrites54.4%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6475.5
Applied rewrites75.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma (/ x.re y.im) y.re x.im) y.im)))
(if (<= y.im -3.2e-21)
t_0
(if (<= y.im 1.66e-65) (/ (fma (/ y.im y.re) x.im x.re) y.re) 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_re / y_46_im), y_46_re, x_46_im) / y_46_im;
double tmp;
if (y_46_im <= -3.2e-21) {
tmp = t_0;
} else if (y_46_im <= 1.66e-65) {
tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
} 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_re / y_46_im), y_46_re, x_46_im) / y_46_im) tmp = 0.0 if (y_46_im <= -3.2e-21) tmp = t_0; elseif (y_46_im <= 1.66e-65) tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re); 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$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -3.2e-21], t$95$0, If[LessEqual[y$46$im, 1.66e-65], N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\mathbf{if}\;y.im \leq -3.2 \cdot 10^{-21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 1.66 \cdot 10^{-65}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -3.2000000000000002e-21 or 1.6599999999999999e-65 < y.im Initial program 57.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-/.f6478.9
Applied rewrites78.9%
if -3.2000000000000002e-21 < y.im < 1.6599999999999999e-65Initial program 69.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6469.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6469.7
Applied rewrites69.7%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6490.4
Applied rewrites90.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma (/ x.re y.im) y.re x.im) y.im)))
(if (<= y.im -3.2e-21)
t_0
(if (<= y.im 1.66e-65) (/ (fma (/ x.im y.re) y.im x.re) y.re) 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_re / y_46_im), y_46_re, x_46_im) / y_46_im;
double tmp;
if (y_46_im <= -3.2e-21) {
tmp = t_0;
} else if (y_46_im <= 1.66e-65) {
tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
} 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_re / y_46_im), y_46_re, x_46_im) / y_46_im) tmp = 0.0 if (y_46_im <= -3.2e-21) tmp = t_0; elseif (y_46_im <= 1.66e-65) tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re); 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$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -3.2e-21], t$95$0, If[LessEqual[y$46$im, 1.66e-65], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\mathbf{if}\;y.im \leq -3.2 \cdot 10^{-21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 1.66 \cdot 10^{-65}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -3.2000000000000002e-21 or 1.6599999999999999e-65 < y.im Initial program 57.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-/.f6478.9
Applied rewrites78.9%
if -3.2000000000000002e-21 < y.im < 1.6599999999999999e-65Initial program 69.7%
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-/.f6488.4
Applied rewrites88.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -7e-21)
(/ x.im y.im)
(if (<= y.im 1.72e+84)
(/ (fma (/ x.im y.re) y.im 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-21) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 1.72e+84) {
tmp = fma((x_46_im / y_46_re), y_46_im, 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-21) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 1.72e+84) tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, 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, -7e-21], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 1.72e+84], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / 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^{-21}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 1.72 \cdot 10^{+84}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -7.0000000000000007e-21 or 1.72e84 < y.im Initial program 53.5%
Taylor expanded in y.re around 0
lower-/.f6475.2
Applied rewrites75.2%
if -7.0000000000000007e-21 < y.im < 1.72e84Initial program 70.4%
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-/.f6479.9
Applied rewrites79.9%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -2.2e+73)
(/ x.im y.im)
(if (<= y.im -5.5e-37)
(/ (fma y.im x.im (* x.re y.re)) (* y.im y.im))
(if (<= y.im 1.66e-65) (/ 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 <= -2.2e+73) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= -5.5e-37) {
tmp = fma(y_46_im, x_46_im, (x_46_re * y_46_re)) / (y_46_im * y_46_im);
} else if (y_46_im <= 1.66e-65) {
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 <= -2.2e+73) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= -5.5e-37) tmp = Float64(fma(y_46_im, x_46_im, Float64(x_46_re * y_46_re)) / Float64(y_46_im * y_46_im)); elseif (y_46_im <= 1.66e-65) 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, -2.2e+73], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -5.5e-37], N[(N[(y$46$im * x$46$im + N[(x$46$re * y$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 1.66e-65], 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 -2.2 \cdot 10^{+73}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq -5.5 \cdot 10^{-37}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, x.re \cdot y.re\right)}{y.im \cdot y.im}\\
\mathbf{elif}\;y.im \leq 1.66 \cdot 10^{-65}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -2.2e73 or 1.6599999999999999e-65 < y.im Initial program 53.8%
Taylor expanded in y.re around 0
lower-/.f6470.3
Applied rewrites70.3%
if -2.2e73 < y.im < -5.4999999999999998e-37Initial program 75.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6475.5
Applied rewrites75.5%
Taylor expanded in y.re around 0
unpow2N/A
lower-*.f6469.0
Applied rewrites69.0%
if -5.4999999999999998e-37 < y.im < 1.6599999999999999e-65Initial program 70.4%
Taylor expanded in y.re around inf
lower-/.f6473.3
Applied rewrites73.3%
Final simplification71.5%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.im -6.5e-21) (/ x.im y.im) (if (<= y.im 1.66e-65) (/ 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 <= -6.5e-21) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 1.66e-65) {
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 <= (-6.5d-21)) then
tmp = x_46im / y_46im
else if (y_46im <= 1.66d-65) 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 <= -6.5e-21) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 1.66e-65) {
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 <= -6.5e-21: tmp = x_46_im / y_46_im elif y_46_im <= 1.66e-65: 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 <= -6.5e-21) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 1.66e-65) 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 <= -6.5e-21) tmp = x_46_im / y_46_im; elseif (y_46_im <= 1.66e-65) 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, -6.5e-21], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 1.66e-65], 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 -6.5 \cdot 10^{-21}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 1.66 \cdot 10^{-65}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -6.49999999999999987e-21 or 1.6599999999999999e-65 < y.im Initial program 57.8%
Taylor expanded in y.re around 0
lower-/.f6468.2
Applied rewrites68.2%
if -6.49999999999999987e-21 < y.im < 1.6599999999999999e-65Initial program 69.7%
Taylor expanded in y.re around inf
lower-/.f6471.8
Applied rewrites71.8%
(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 63.1%
Taylor expanded in y.re around 0
lower-/.f6442.6
Applied rewrites42.6%
herbie shell --seed 2024325
(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))))