
(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))))
(t_1 (/ (fma (/ x.im y.re) y.im x.re) y.re)))
(if (<= y.re -6.2e+120)
t_1
(if (<= y.re -5.8e-116)
t_0
(if (<= y.re 1.3e-129)
(/ (fma (/ y.re y.im) x.re x.im) y.im)
(if (<= y.re 1.46e+85) 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((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
double tmp;
if (y_46_re <= -6.2e+120) {
tmp = t_1;
} else if (y_46_re <= -5.8e-116) {
tmp = t_0;
} else if (y_46_re <= 1.3e-129) {
tmp = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
} else if (y_46_re <= 1.46e+85) {
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(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re) tmp = 0.0 if (y_46_re <= -6.2e+120) tmp = t_1; elseif (y_46_re <= -5.8e-116) tmp = t_0; elseif (y_46_re <= 1.3e-129) tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im); elseif (y_46_re <= 1.46e+85) 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[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -6.2e+120], t$95$1, If[LessEqual[y$46$re, -5.8e-116], t$95$0, If[LessEqual[y$46$re, 1.3e-129], 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.46e+85], 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{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\mathbf{if}\;y.re \leq -6.2 \cdot 10^{+120}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.re \leq -5.8 \cdot 10^{-116}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 1.3 \cdot 10^{-129}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\mathbf{elif}\;y.re \leq 1.46 \cdot 10^{+85}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.re < -6.19999999999999947e120 or 1.46e85 < y.re Initial program 39.5%
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-/.f6491.0
Applied rewrites91.0%
if -6.19999999999999947e120 < y.re < -5.7999999999999996e-116 or 1.3e-129 < y.re < 1.46e85Initial program 84.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6484.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6484.1
Applied rewrites84.1%
if -5.7999999999999996e-116 < y.re < 1.3e-129Initial program 72.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6472.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6472.2
Applied rewrites72.2%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6491.1
Applied rewrites91.1%
Final simplification88.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -7.5e+120)
(/ x.re y.re)
(if (<= y.re -3e-39)
(* (/ x.re (fma y.im y.im (* y.re y.re))) y.re)
(if (<= y.re 8.1e-196)
(/ (fma y.im x.im (* x.re y.re)) (* y.im y.im))
(if (<= y.re 48000.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_re <= -7.5e+120) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= -3e-39) {
tmp = (x_46_re / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * y_46_re;
} else if (y_46_re <= 8.1e-196) {
tmp = fma(y_46_im, x_46_im, (x_46_re * y_46_re)) / (y_46_im * y_46_im);
} else if (y_46_re <= 48000.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_re <= -7.5e+120) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= -3e-39) tmp = Float64(Float64(x_46_re / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * y_46_re); elseif (y_46_re <= 8.1e-196) 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_re <= 48000.0) tmp = Float64(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, -7.5e+120], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -3e-39], N[(N[(x$46$re / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 8.1e-196], 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$re, 48000.0], 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.re \leq -7.5 \cdot 10^{+120}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq -3 \cdot 10^{-39}:\\
\;\;\;\;\frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot y.re\\
\mathbf{elif}\;y.re \leq 8.1 \cdot 10^{-196}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, x.re \cdot y.re\right)}{y.im \cdot y.im}\\
\mathbf{elif}\;y.re \leq 48000:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -7.5000000000000006e120 or 48000 < y.re Initial program 49.8%
Taylor expanded in y.re around inf
lower-/.f6473.0
Applied rewrites73.0%
if -7.5000000000000006e120 < y.re < -3.00000000000000028e-39Initial program 77.6%
Taylor expanded in x.re 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-*.f6462.1
Applied rewrites62.1%
if -3.00000000000000028e-39 < y.re < 8.09999999999999992e-196Initial program 78.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6478.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.4
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6478.4
Applied rewrites78.4%
Taylor expanded in y.re around 0
unpow2N/A
lower-*.f6473.5
Applied rewrites73.5%
if 8.09999999999999992e-196 < y.re < 48000Initial program 76.2%
Taylor expanded in y.re around 0
lower-/.f6472.0
Applied rewrites72.0%
Final simplification71.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -5.8)
(/ (fma (/ y.im y.re) x.im x.re) y.re)
(if (<= y.re 18000000000000.0)
(/ (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 <= -5.8) {
tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
} else if (y_46_re <= 18000000000000.0) {
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 <= -5.8) tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re); elseif (y_46_re <= 18000000000000.0) 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, -5.8], 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, 18000000000000.0], 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 -5.8:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\mathbf{elif}\;y.re \leq 18000000000000:\\
\;\;\;\;\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 < -5.79999999999999982Initial program 51.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6451.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6451.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6451.0
Applied rewrites51.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6478.0
Applied rewrites78.0%
if -5.79999999999999982 < y.re < 1.8e13Initial program 78.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6478.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6478.1
Applied rewrites78.1%
Taylor expanded in y.im around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6482.0
Applied rewrites82.0%
if 1.8e13 < y.re Initial program 57.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-/.f6486.5
Applied rewrites86.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -5.8)
(/ (fma (/ y.im y.re) x.im x.re) y.re)
(if (<= y.re 18000000000000.0)
(/ (fma (/ x.re y.im) y.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 <= -5.8) {
tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
} else if (y_46_re <= 18000000000000.0) {
tmp = fma((x_46_re / y_46_im), y_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 <= -5.8) tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re); elseif (y_46_re <= 18000000000000.0) tmp = Float64(fma(Float64(x_46_re / y_46_im), y_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, -5.8], 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, 18000000000000.0], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$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 -5.8:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\mathbf{elif}\;y.re \leq 18000000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.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 < -5.79999999999999982Initial program 51.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6451.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6451.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6451.0
Applied rewrites51.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6478.0
Applied rewrites78.0%
if -5.79999999999999982 < y.re < 1.8e13Initial program 78.1%
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.5
Applied rewrites80.5%
if 1.8e13 < y.re Initial program 57.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-/.f6486.5
Applied rewrites86.5%
(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 -5.8)
t_0
(if (<= y.re 18000000000000.0)
(/ (fma (/ x.re y.im) y.re 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 <= -5.8) {
tmp = t_0;
} else if (y_46_re <= 18000000000000.0) {
tmp = fma((x_46_re / y_46_im), y_46_re, 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 <= -5.8) tmp = t_0; elseif (y_46_re <= 18000000000000.0) tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, 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, -5.8], t$95$0, If[LessEqual[y$46$re, 18000000000000.0], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + 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 -5.8:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 18000000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -5.79999999999999982 or 1.8e13 < y.re Initial program 54.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-/.f6482.6
Applied rewrites82.6%
if -5.79999999999999982 < y.re < 1.8e13Initial program 78.1%
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.5
Applied rewrites80.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -7.8e+130)
(/ x.im y.im)
(if (<= y.im 1.8e+58)
(/ (fma (/ x.im y.re) y.im x.re) y.re)
(/ 1.0 (/ y.im x.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 <= -7.8e+130) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 1.8e+58) {
tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
} else {
tmp = 1.0 / (y_46_im / x_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 <= -7.8e+130) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 1.8e+58) tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re); else tmp = Float64(1.0 / Float64(y_46_im / x_46_im)); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$im, -7.8e+130], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 1.8e+58], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], N[(1.0 / N[(y$46$im / x$46$im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -7.8 \cdot 10^{+130}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 1.8 \cdot 10^{+58}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{y.im}{x.im}}\\
\end{array}
\end{array}
if y.im < -7.8000000000000004e130Initial program 45.3%
Taylor expanded in y.re around 0
lower-/.f6477.5
Applied rewrites77.5%
if -7.8000000000000004e130 < y.im < 1.79999999999999998e58Initial program 73.5%
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-/.f6475.0
Applied rewrites75.0%
if 1.79999999999999998e58 < y.im Initial program 56.5%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6456.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6456.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6456.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6456.5
Applied rewrites56.5%
Taylor expanded in y.re around 0
lower-/.f6476.2
Applied rewrites76.2%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -7.5e+120)
(/ x.re y.re)
(if (<= y.re -2e-56)
(* (/ x.re (fma y.im y.im (* y.re y.re))) y.re)
(if (<= y.re 48000.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_re <= -7.5e+120) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= -2e-56) {
tmp = (x_46_re / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * y_46_re;
} else if (y_46_re <= 48000.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_re <= -7.5e+120) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= -2e-56) tmp = Float64(Float64(x_46_re / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * y_46_re); elseif (y_46_re <= 48000.0) tmp = Float64(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, -7.5e+120], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, -2e-56], N[(N[(x$46$re / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 48000.0], 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.re \leq -7.5 \cdot 10^{+120}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq -2 \cdot 10^{-56}:\\
\;\;\;\;\frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot y.re\\
\mathbf{elif}\;y.re \leq 48000:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -7.5000000000000006e120 or 48000 < y.re Initial program 49.8%
Taylor expanded in y.re around inf
lower-/.f6473.0
Applied rewrites73.0%
if -7.5000000000000006e120 < y.re < -2.0000000000000001e-56Initial program 79.4%
Taylor expanded in x.re 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-*.f6460.1
Applied rewrites60.1%
if -2.0000000000000001e-56 < y.re < 48000Initial program 77.1%
Taylor expanded in y.re around 0
lower-/.f6468.7
Applied rewrites68.7%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.re -1.4e-34) (/ x.re y.re) (if (<= y.re 48000.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_re <= -1.4e-34) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 48000.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_46re <= (-1.4d-34)) then
tmp = x_46re / y_46re
else if (y_46re <= 48000.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_re <= -1.4e-34) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 48000.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_re <= -1.4e-34: tmp = x_46_re / y_46_re elif y_46_re <= 48000.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_re <= -1.4e-34) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= 48000.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_re <= -1.4e-34) tmp = x_46_re / y_46_re; elseif (y_46_re <= 48000.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[LessEqual[y$46$re, -1.4e-34], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 48000.0], 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.re \leq -1.4 \cdot 10^{-34}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 48000:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -1.39999999999999998e-34 or 48000 < y.re Initial program 56.5%
Taylor expanded in y.re around inf
lower-/.f6465.8
Applied rewrites65.8%
if -1.39999999999999998e-34 < y.re < 48000Initial program 77.4%
Taylor expanded in y.re around 0
lower-/.f6467.8
Applied rewrites67.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 66.0%
Taylor expanded in y.re around 0
lower-/.f6440.9
Applied rewrites40.9%
herbie shell --seed 2024296
(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))))