
(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 10 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.re -1.62e+97)
(fma (/ y.im y.re) (/ x.im y.re) (/ x.re y.re))
(if (<= y.re -1.2e-46)
t_0
(if (<= y.re 8.5e-122)
(/ (fma (/ y.re y.im) x.re x.im) y.im)
(if (<= y.re 1.7e+96) t_0 (/ (fma (/ y.im y.re) x.im x.re) y.re)))))))
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_re <= -1.62e+97) {
tmp = fma((y_46_im / y_46_re), (x_46_im / y_46_re), (x_46_re / y_46_re));
} else if (y_46_re <= -1.2e-46) {
tmp = t_0;
} else if (y_46_re <= 8.5e-122) {
tmp = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
} else if (y_46_re <= 1.7e+96) {
tmp = t_0;
} else {
tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
}
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_re <= -1.62e+97) tmp = fma(Float64(y_46_im / y_46_re), Float64(x_46_im / y_46_re), Float64(x_46_re / y_46_re)); elseif (y_46_re <= -1.2e-46) tmp = t_0; elseif (y_46_re <= 8.5e-122) tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im); elseif (y_46_re <= 1.7e+96) tmp = t_0; else tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re); 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$re, -1.62e+97], N[(N[(y$46$im / y$46$re), $MachinePrecision] * N[(x$46$im / y$46$re), $MachinePrecision] + N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -1.2e-46], t$95$0, If[LessEqual[y$46$re, 8.5e-122], 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$re, 1.7e+96], t$95$0, N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $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.re \leq -1.62 \cdot 10^{+97}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y.im}{y.re}, \frac{x.im}{y.re}, \frac{x.re}{y.re}\right)\\
\mathbf{elif}\;y.re \leq -1.2 \cdot 10^{-46}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 8.5 \cdot 10^{-122}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\mathbf{elif}\;y.re \leq 1.7 \cdot 10^{+96}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\end{array}
\end{array}
if y.re < -1.62e97Initial program 35.4%
Taylor expanded in y.im around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6478.5
Applied rewrites78.5%
Applied rewrites88.2%
if -1.62e97 < y.re < -1.20000000000000007e-46 or 8.50000000000000003e-122 < y.re < 1.7e96Initial program 74.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6474.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.7
Applied rewrites74.7%
if -1.20000000000000007e-46 < y.re < 8.50000000000000003e-122Initial program 68.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6468.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.4
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6468.4
Applied rewrites68.4%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6487.9
Applied rewrites87.9%
if 1.7e96 < y.re Initial program 28.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6428.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6428.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6428.1
Applied rewrites28.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6484.9
Applied rewrites84.9%
Final simplification83.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)))))
(if (<= y.re -1.62e+97)
(/ (fma (/ x.im y.re) y.im x.re) y.re)
(if (<= y.re -1.2e-46)
t_0
(if (<= y.re 8.5e-122)
(/ (fma (/ y.re y.im) x.re x.im) y.im)
(if (<= y.re 1.7e+96) t_0 (/ (fma (/ y.im y.re) x.im x.re) y.re)))))))
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_re <= -1.62e+97) {
tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
} else if (y_46_re <= -1.2e-46) {
tmp = t_0;
} else if (y_46_re <= 8.5e-122) {
tmp = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
} else if (y_46_re <= 1.7e+96) {
tmp = t_0;
} else {
tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
}
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_re <= -1.62e+97) tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re); elseif (y_46_re <= -1.2e-46) tmp = t_0; elseif (y_46_re <= 8.5e-122) tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im); elseif (y_46_re <= 1.7e+96) tmp = t_0; else tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re); 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$re, -1.62e+97], 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.2e-46], t$95$0, If[LessEqual[y$46$re, 8.5e-122], 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$re, 1.7e+96], t$95$0, N[(N[(N[(y$46$im / y$46$re), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$re), $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.re \leq -1.62 \cdot 10^{+97}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\mathbf{elif}\;y.re \leq -1.2 \cdot 10^{-46}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 8.5 \cdot 10^{-122}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\mathbf{elif}\;y.re \leq 1.7 \cdot 10^{+96}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\end{array}
\end{array}
if y.re < -1.62e97Initial program 35.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-/.f6488.2
Applied rewrites88.2%
if -1.62e97 < y.re < -1.20000000000000007e-46 or 8.50000000000000003e-122 < y.re < 1.7e96Initial program 74.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6474.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.7
Applied rewrites74.7%
if -1.20000000000000007e-46 < y.re < 8.50000000000000003e-122Initial program 68.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6468.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.4
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6468.4
Applied rewrites68.4%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6487.9
Applied rewrites87.9%
if 1.7e96 < y.re Initial program 28.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6428.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6428.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6428.1
Applied rewrites28.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6484.9
Applied rewrites84.9%
Final simplification83.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -3.35e+112)
(/ x.im y.im)
(if (<= y.im -2.8e-65)
(* (/ y.im (fma y.im y.im (* y.re y.re))) x.im)
(if (<= y.im 7.8e+141)
(/ (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 <= -3.35e+112) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= -2.8e-65) {
tmp = (y_46_im / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * x_46_im;
} else if (y_46_im <= 7.8e+141) {
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 <= -3.35e+112) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= -2.8e-65) tmp = Float64(Float64(y_46_im / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * x_46_im); elseif (y_46_im <= 7.8e+141) 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, -3.35e+112], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -2.8e-65], N[(N[(y$46$im / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision], If[LessEqual[y$46$im, 7.8e+141], 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 -3.35 \cdot 10^{+112}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq -2.8 \cdot 10^{-65}:\\
\;\;\;\;\frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot x.im\\
\mathbf{elif}\;y.im \leq 7.8 \cdot 10^{+141}:\\
\;\;\;\;\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 < -3.3499999999999999e112 or 7.79999999999999983e141 < y.im Initial program 28.1%
Taylor expanded in y.im around inf
lower-/.f6479.0
Applied rewrites79.0%
if -3.3499999999999999e112 < y.im < -2.8e-65Initial program 81.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6481.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6481.7
Applied rewrites81.7%
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-*.f6468.8
Applied rewrites68.8%
if -2.8e-65 < y.im < 7.79999999999999983e141Initial program 67.6%
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-/.f6478.4
Applied rewrites78.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -3.35e+112)
(/ x.im y.im)
(if (<= y.im -5.6e-71)
(* (/ y.im (fma y.im y.im (* y.re y.re))) x.im)
(if (<= y.im -3.4e-253)
(/ (fma y.im x.im (* x.re y.re)) (* y.re y.re))
(if (<= y.im 5.2e+141) (/ 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 <= -3.35e+112) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= -5.6e-71) {
tmp = (y_46_im / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * x_46_im;
} else if (y_46_im <= -3.4e-253) {
tmp = fma(y_46_im, x_46_im, (x_46_re * y_46_re)) / (y_46_re * y_46_re);
} else if (y_46_im <= 5.2e+141) {
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 <= -3.35e+112) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= -5.6e-71) tmp = Float64(Float64(y_46_im / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * x_46_im); elseif (y_46_im <= -3.4e-253) tmp = Float64(fma(y_46_im, x_46_im, Float64(x_46_re * y_46_re)) / Float64(y_46_re * y_46_re)); elseif (y_46_im <= 5.2e+141) 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, -3.35e+112], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -5.6e-71], N[(N[(y$46$im / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision], If[LessEqual[y$46$im, -3.4e-253], N[(N[(y$46$im * x$46$im + N[(x$46$re * y$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 5.2e+141], 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 -3.35 \cdot 10^{+112}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq -5.6 \cdot 10^{-71}:\\
\;\;\;\;\frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot x.im\\
\mathbf{elif}\;y.im \leq -3.4 \cdot 10^{-253}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, x.re \cdot y.re\right)}{y.re \cdot y.re}\\
\mathbf{elif}\;y.im \leq 5.2 \cdot 10^{+141}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -3.3499999999999999e112 or 5.1999999999999999e141 < y.im Initial program 28.1%
Taylor expanded in y.im around inf
lower-/.f6479.0
Applied rewrites79.0%
if -3.3499999999999999e112 < y.im < -5.60000000000000001e-71Initial program 79.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6479.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6479.5
Applied rewrites79.5%
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-*.f6467.1
Applied rewrites67.1%
if -5.60000000000000001e-71 < y.im < -3.39999999999999985e-253Initial program 82.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6482.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6482.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6482.9
Applied rewrites82.9%
Taylor expanded in y.im around 0
unpow2N/A
lower-*.f6468.4
Applied rewrites68.4%
if -3.39999999999999985e-253 < y.im < 5.1999999999999999e141Initial program 62.4%
Taylor expanded in y.im around 0
lower-/.f6462.8
Applied rewrites62.8%
Final simplification69.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -250000.0)
(/ (fma (/ y.im y.re) x.im x.re) y.re)
(if (<= y.re 6.5e+50)
(/ (fma (/ y.re y.im) x.re x.im) y.im)
(/ (fma (/ x.im y.re) 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 <= -250000.0) {
tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
} else if (y_46_re <= 6.5e+50) {
tmp = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
} else {
tmp = fma((x_46_im / y_46_re), y_46_im, 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 <= -250000.0) tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re); elseif (y_46_re <= 6.5e+50) tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im); else tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, 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, -250000.0], 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$re, 6.5e+50], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -250000:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\mathbf{elif}\;y.re \leq 6.5 \cdot 10^{+50}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\end{array}
\end{array}
if y.re < -2.5e5Initial program 48.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6448.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6448.3
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6448.3
Applied rewrites48.3%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6481.5
Applied rewrites81.5%
if -2.5e5 < y.re < 6.5000000000000003e50Initial program 70.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6470.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6470.1
Applied rewrites70.1%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6477.8
Applied rewrites77.8%
if 6.5000000000000003e50 < y.re Initial program 36.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-/.f6481.0
Applied rewrites81.0%
(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 -1.7e-7)
t_0
(if (<= y.im 5.2e+141) (/ (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 <= -1.7e-7) {
tmp = t_0;
} else if (y_46_im <= 5.2e+141) {
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 <= -1.7e-7) tmp = t_0; elseif (y_46_im <= 5.2e+141) 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, -1.7e-7], t$95$0, If[LessEqual[y$46$im, 5.2e+141], 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 -1.7 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 5.2 \cdot 10^{+141}:\\
\;\;\;\;\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 < -1.69999999999999987e-7 or 5.1999999999999999e141 < y.im Initial program 40.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-/.f6480.6
Applied rewrites80.6%
if -1.69999999999999987e-7 < y.im < 5.1999999999999999e141Initial program 69.2%
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-/.f6478.2
Applied rewrites78.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -3.35e+112)
(/ x.im y.im)
(if (<= y.im -8.2e-67)
(* (/ y.im (fma y.im y.im (* y.re y.re))) x.im)
(if (<= y.im 5.2e+141) (/ 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 <= -3.35e+112) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= -8.2e-67) {
tmp = (y_46_im / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * x_46_im;
} else if (y_46_im <= 5.2e+141) {
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 <= -3.35e+112) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= -8.2e-67) tmp = Float64(Float64(y_46_im / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * x_46_im); elseif (y_46_im <= 5.2e+141) 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, -3.35e+112], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -8.2e-67], N[(N[(y$46$im / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision], If[LessEqual[y$46$im, 5.2e+141], 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 -3.35 \cdot 10^{+112}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq -8.2 \cdot 10^{-67}:\\
\;\;\;\;\frac{y.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot x.im\\
\mathbf{elif}\;y.im \leq 5.2 \cdot 10^{+141}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -3.3499999999999999e112 or 5.1999999999999999e141 < y.im Initial program 28.1%
Taylor expanded in y.im around inf
lower-/.f6479.0
Applied rewrites79.0%
if -3.3499999999999999e112 < y.im < -8.1999999999999994e-67Initial program 81.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6481.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6481.7
Applied rewrites81.7%
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-*.f6468.8
Applied rewrites68.8%
if -8.1999999999999994e-67 < y.im < 5.1999999999999999e141Initial program 67.6%
Taylor expanded in y.im around 0
lower-/.f6460.3
Applied rewrites60.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -2.8e+115)
(/ x.im y.im)
(if (<= y.im -8.5e-67)
(* (/ x.im (fma y.im y.im (* y.re y.re))) y.im)
(if (<= y.im 5.2e+141) (/ 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.8e+115) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= -8.5e-67) {
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 <= 5.2e+141) {
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.8e+115) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= -8.5e-67) 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 <= 5.2e+141) 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.8e+115], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -8.5e-67], 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, 5.2e+141], 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.8 \cdot 10^{+115}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq -8.5 \cdot 10^{-67}:\\
\;\;\;\;\frac{x.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot y.im\\
\mathbf{elif}\;y.im \leq 5.2 \cdot 10^{+141}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -2.8e115 or 5.1999999999999999e141 < y.im Initial program 27.1%
Taylor expanded in y.im around inf
lower-/.f6478.7
Applied rewrites78.7%
if -2.8e115 < y.im < -8.49999999999999993e-67Initial program 82.1%
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-*.f6467.2
Applied rewrites67.2%
if -8.49999999999999993e-67 < y.im < 5.1999999999999999e141Initial program 67.6%
Taylor expanded in y.im around 0
lower-/.f6460.3
Applied rewrites60.3%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.im -2.6e-65) (/ x.im y.im) (if (<= y.im 5.2e+141) (/ 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.6e-65) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 5.2e+141) {
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 <= (-2.6d-65)) then
tmp = x_46im / y_46im
else if (y_46im <= 5.2d+141) 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 <= -2.6e-65) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 5.2e+141) {
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 <= -2.6e-65: tmp = x_46_im / y_46_im elif y_46_im <= 5.2e+141: 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.6e-65) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 5.2e+141) 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 <= -2.6e-65) tmp = x_46_im / y_46_im; elseif (y_46_im <= 5.2e+141) 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, -2.6e-65], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 5.2e+141], 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.6 \cdot 10^{-65}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 5.2 \cdot 10^{+141}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -2.6000000000000001e-65 or 5.1999999999999999e141 < y.im Initial program 45.6%
Taylor expanded in y.im around inf
lower-/.f6469.3
Applied rewrites69.3%
if -2.6000000000000001e-65 < y.im < 5.1999999999999999e141Initial program 67.6%
Taylor expanded in y.im around 0
lower-/.f6460.3
Applied rewrites60.3%
(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 57.9%
Taylor expanded in y.im around inf
lower-/.f6441.8
Applied rewrites41.8%
herbie shell --seed 2024243
(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))))