
(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 (fma y.im y.im (* y.re y.re)))
(t_1 (fma x.im (/ y.im t_0) (* y.re (/ x.re t_0)))))
(if (<= y.im -1.6e+140)
(fma
(/ y.re y.im)
(/ (fma (/ (- y.re) y.im) x.im x.re) y.im)
(/ x.im y.im))
(if (<= y.im -4.9e+26)
t_1
(if (<= y.im 0.105)
(/ (fma (/ y.im y.re) x.im x.re) y.re)
(if (<= y.im 4.6e+150)
t_1
(/ (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 t_0 = fma(y_46_im, y_46_im, (y_46_re * y_46_re));
double t_1 = fma(x_46_im, (y_46_im / t_0), (y_46_re * (x_46_re / t_0)));
double tmp;
if (y_46_im <= -1.6e+140) {
tmp = fma((y_46_re / y_46_im), (fma((-y_46_re / y_46_im), x_46_im, x_46_re) / y_46_im), (x_46_im / y_46_im));
} else if (y_46_im <= -4.9e+26) {
tmp = t_1;
} else if (y_46_im <= 0.105) {
tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
} else if (y_46_im <= 4.6e+150) {
tmp = t_1;
} 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) t_0 = fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re)) t_1 = fma(x_46_im, Float64(y_46_im / t_0), Float64(y_46_re * Float64(x_46_re / t_0))) tmp = 0.0 if (y_46_im <= -1.6e+140) tmp = fma(Float64(y_46_re / y_46_im), Float64(fma(Float64(Float64(-y_46_re) / y_46_im), x_46_im, x_46_re) / y_46_im), Float64(x_46_im / y_46_im)); elseif (y_46_im <= -4.9e+26) tmp = t_1; elseif (y_46_im <= 0.105) tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re); elseif (y_46_im <= 4.6e+150) tmp = t_1; 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_] := Block[{t$95$0 = N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x$46$im * N[(y$46$im / t$95$0), $MachinePrecision] + N[(y$46$re * N[(x$46$re / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -1.6e+140], N[(N[(y$46$re / y$46$im), $MachinePrecision] * N[(N[(N[((-y$46$re) / y$46$im), $MachinePrecision] * x$46$im + x$46$re), $MachinePrecision] / y$46$im), $MachinePrecision] + N[(x$46$im / y$46$im), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, -4.9e+26], t$95$1, If[LessEqual[y$46$im, 0.105], 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, 4.6e+150], t$95$1, 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}
t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\
t_1 := \mathsf{fma}\left(x.im, \frac{y.im}{t\_0}, y.re \cdot \frac{x.re}{t\_0}\right)\\
\mathbf{if}\;y.im \leq -1.6 \cdot 10^{+140}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y.re}{y.im}, \frac{\mathsf{fma}\left(\frac{-y.re}{y.im}, x.im, x.re\right)}{y.im}, \frac{x.im}{y.im}\right)\\
\mathbf{elif}\;y.im \leq -4.9 \cdot 10^{+26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq 0.105:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\mathbf{elif}\;y.im \leq 4.6 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\
\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 < -1.60000000000000005e140Initial program 26.5%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6430.4
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6430.4
Applied rewrites30.4%
Taylor expanded in y.re around 0
Applied rewrites80.8%
Applied rewrites89.5%
if -1.60000000000000005e140 < y.im < -4.89999999999999974e26 or 0.104999999999999996 < y.im < 4.60000000000000002e150Initial program 73.6%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6492.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6492.0
Applied rewrites92.0%
if -4.89999999999999974e26 < y.im < 0.104999999999999996Initial program 68.9%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6467.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6467.1
Applied rewrites67.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6488.5
Applied rewrites88.5%
if 4.60000000000000002e150 < y.im Initial program 27.0%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6432.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6432.0
Applied rewrites32.0%
Taylor expanded in y.re around 0
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6490.8
Applied rewrites90.8%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (fma y.im y.im (* y.re y.re)))
(t_1 (fma x.im (/ y.im t_0) (* y.re (/ x.re t_0))))
(t_2 (/ (fma (/ y.re y.im) x.re x.im) y.im)))
(if (<= y.im -1.6e+140)
t_2
(if (<= y.im -4.9e+26)
t_1
(if (<= y.im 0.105)
(/ (fma (/ y.im y.re) x.im x.re) y.re)
(if (<= y.im 4.6e+150) t_1 t_2))))))
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 t_1 = fma(x_46_im, (y_46_im / t_0), (y_46_re * (x_46_re / t_0)));
double t_2 = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
double tmp;
if (y_46_im <= -1.6e+140) {
tmp = t_2;
} else if (y_46_im <= -4.9e+26) {
tmp = t_1;
} else if (y_46_im <= 0.105) {
tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
} else if (y_46_im <= 4.6e+150) {
tmp = t_1;
} else {
tmp = t_2;
}
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)) t_1 = fma(x_46_im, Float64(y_46_im / t_0), Float64(y_46_re * Float64(x_46_re / t_0))) t_2 = 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.6e+140) tmp = t_2; elseif (y_46_im <= -4.9e+26) tmp = t_1; elseif (y_46_im <= 0.105) tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re); elseif (y_46_im <= 4.6e+150) tmp = t_1; else tmp = t_2; 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]}, Block[{t$95$1 = N[(x$46$im * N[(y$46$im / t$95$0), $MachinePrecision] + N[(y$46$re * N[(x$46$re / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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.6e+140], t$95$2, If[LessEqual[y$46$im, -4.9e+26], t$95$1, If[LessEqual[y$46$im, 0.105], 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, 4.6e+150], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\
t_1 := \mathsf{fma}\left(x.im, \frac{y.im}{t\_0}, y.re \cdot \frac{x.re}{t\_0}\right)\\
t_2 := \frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\mathbf{if}\;y.im \leq -1.6 \cdot 10^{+140}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y.im \leq -4.9 \cdot 10^{+26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.im \leq 0.105:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\mathbf{elif}\;y.im \leq 4.6 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if y.im < -1.60000000000000005e140 or 4.60000000000000002e150 < y.im Initial program 26.7%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6431.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6431.2
Applied rewrites31.2%
Taylor expanded in y.re around 0
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6490.0
Applied rewrites90.0%
if -1.60000000000000005e140 < y.im < -4.89999999999999974e26 or 0.104999999999999996 < y.im < 4.60000000000000002e150Initial program 73.6%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6492.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6492.0
Applied rewrites92.0%
if -4.89999999999999974e26 < y.im < 0.104999999999999996Initial program 68.9%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6467.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6467.1
Applied rewrites67.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6488.5
Applied rewrites88.5%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -4e+59)
(/ x.im y.im)
(if (<= y.im 6.2e+14)
(/ (fma (/ y.im y.re) x.im x.re) y.re)
(if (<= y.im 2.85e+144)
(* (/ y.im (fma y.re y.re (* y.im y.im))) 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 tmp;
if (y_46_im <= -4e+59) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 6.2e+14) {
tmp = fma((y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re;
} else if (y_46_im <= 2.85e+144) {
tmp = (y_46_im / fma(y_46_re, y_46_re, (y_46_im * y_46_im))) * 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) tmp = 0.0 if (y_46_im <= -4e+59) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 6.2e+14) tmp = Float64(fma(Float64(y_46_im / y_46_re), x_46_im, x_46_re) / y_46_re); elseif (y_46_im <= 2.85e+144) tmp = Float64(Float64(y_46_im / fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im))) * 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_] := If[LessEqual[y$46$im, -4e+59], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 6.2e+14], 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, 2.85e+144], N[(N[(y$46$im / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -4 \cdot 10^{+59}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 6.2 \cdot 10^{+14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\mathbf{elif}\;y.im \leq 2.85 \cdot 10^{+144}:\\
\;\;\;\;\frac{y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)} \cdot x.im\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -3.99999999999999989e59 or 2.85000000000000002e144 < y.im Initial program 34.3%
Taylor expanded in y.re around 0
lower-/.f6481.0
Applied rewrites81.0%
if -3.99999999999999989e59 < y.im < 6.2e14Initial program 69.7%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6468.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6468.7
Applied rewrites68.7%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
if 6.2e14 < y.im < 2.85000000000000002e144Initial program 70.9%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6490.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6490.1
Applied rewrites90.1%
Taylor expanded in x.re around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6457.9
Applied rewrites57.9%
Final simplification80.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -1.02e+27)
(/ x.im y.im)
(if (<= y.im 1050000.0)
(/ x.re y.re)
(if (<= y.im 2.85e+144)
(* (/ y.im (fma y.re y.re (* y.im y.im))) 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 tmp;
if (y_46_im <= -1.02e+27) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 1050000.0) {
tmp = x_46_re / y_46_re;
} else if (y_46_im <= 2.85e+144) {
tmp = (y_46_im / fma(y_46_re, y_46_re, (y_46_im * y_46_im))) * 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) tmp = 0.0 if (y_46_im <= -1.02e+27) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 1050000.0) tmp = Float64(x_46_re / y_46_re); elseif (y_46_im <= 2.85e+144) tmp = Float64(Float64(y_46_im / fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im))) * 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_] := If[LessEqual[y$46$im, -1.02e+27], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 1050000.0], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 2.85e+144], N[(N[(y$46$im / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision], N[(x$46$im / y$46$im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -1.02 \cdot 10^{+27}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 1050000:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.im \leq 2.85 \cdot 10^{+144}:\\
\;\;\;\;\frac{y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)} \cdot x.im\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\end{array}
\end{array}
if y.im < -1.0199999999999999e27 or 2.85000000000000002e144 < y.im Initial program 38.8%
Taylor expanded in y.re around 0
lower-/.f6476.4
Applied rewrites76.4%
if -1.0199999999999999e27 < y.im < 1.05e6Initial program 69.1%
Taylor expanded in y.re around inf
lower-/.f6475.1
Applied rewrites75.1%
if 1.05e6 < y.im < 2.85000000000000002e144Initial program 70.9%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6490.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6490.1
Applied rewrites90.1%
Taylor expanded in x.re around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6457.9
Applied rewrites57.9%
Final simplification73.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -9.4e+26) (not (<= y.im 1.7))) (/ (fma (/ x.re y.im) y.re x.im) y.im) (/ (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 tmp;
if ((y_46_im <= -9.4e+26) || !(y_46_im <= 1.7)) {
tmp = fma((x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im;
} 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) tmp = 0.0 if ((y_46_im <= -9.4e+26) || !(y_46_im <= 1.7)) tmp = Float64(fma(Float64(x_46_re / y_46_im), y_46_re, x_46_im) / y_46_im); 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_] := If[Or[LessEqual[y$46$im, -9.4e+26], N[Not[LessEqual[y$46$im, 1.7]], $MachinePrecision]], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], 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}
\mathbf{if}\;y.im \leq -9.4 \cdot 10^{+26} \lor \neg \left(y.im \leq 1.7\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\end{array}
\end{array}
if y.im < -9.3999999999999995e26 or 1.69999999999999996 < y.im Initial program 48.5%
Taylor expanded in y.re around 0
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6481.7
Applied rewrites81.7%
if -9.3999999999999995e26 < y.im < 1.69999999999999996Initial program 68.9%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6467.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6467.1
Applied rewrites67.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6488.5
Applied rewrites88.5%
Final simplification85.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -9.4e+26) (not (<= y.im 1.7))) (/ (fma (/ y.re y.im) x.re x.im) y.im) (/ (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 tmp;
if ((y_46_im <= -9.4e+26) || !(y_46_im <= 1.7)) {
tmp = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
} 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) tmp = 0.0 if ((y_46_im <= -9.4e+26) || !(y_46_im <= 1.7)) tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im); 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_] := If[Or[LessEqual[y$46$im, -9.4e+26], N[Not[LessEqual[y$46$im, 1.7]], $MachinePrecision]], N[(N[(N[(y$46$re / y$46$im), $MachinePrecision] * x$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision], 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}
\mathbf{if}\;y.im \leq -9.4 \cdot 10^{+26} \lor \neg \left(y.im \leq 1.7\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.im}{y.re}, x.im, x.re\right)}{y.re}\\
\end{array}
\end{array}
if y.im < -9.3999999999999995e26 or 1.69999999999999996 < y.im Initial program 48.5%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6459.4
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6459.4
Applied rewrites59.4%
Taylor expanded in y.re around 0
unpow2N/A
associate-/r*N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6479.6
Applied rewrites79.6%
if -9.3999999999999995e26 < y.im < 1.69999999999999996Initial program 68.9%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6467.1
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6467.1
Applied rewrites67.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6488.5
Applied rewrites88.5%
Final simplification84.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -1.02e+27) (not (<= y.im 6.2e+14))) (/ x.im y.im) (/ x.re y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_im <= -1.02e+27) || !(y_46_im <= 6.2e+14)) {
tmp = x_46_im / y_46_im;
} else {
tmp = x_46_re / y_46_re;
}
return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: tmp
if ((y_46im <= (-1.02d+27)) .or. (.not. (y_46im <= 6.2d+14))) then
tmp = x_46im / y_46im
else
tmp = x_46re / y_46re
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_im <= -1.02e+27) || !(y_46_im <= 6.2e+14)) {
tmp = x_46_im / y_46_im;
} else {
tmp = x_46_re / y_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_im <= -1.02e+27) or not (y_46_im <= 6.2e+14): tmp = x_46_im / y_46_im else: tmp = x_46_re / y_46_re return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((y_46_im <= -1.02e+27) || !(y_46_im <= 6.2e+14)) tmp = Float64(x_46_im / y_46_im); else tmp = Float64(x_46_re / y_46_re); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_im <= -1.02e+27) || ~((y_46_im <= 6.2e+14))) tmp = x_46_im / y_46_im; else tmp = x_46_re / y_46_re; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$im, -1.02e+27], N[Not[LessEqual[y$46$im, 6.2e+14]], $MachinePrecision]], N[(x$46$im / y$46$im), $MachinePrecision], N[(x$46$re / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -1.02 \cdot 10^{+27} \lor \neg \left(y.im \leq 6.2 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.im < -1.0199999999999999e27 or 6.2e14 < y.im Initial program 48.0%
Taylor expanded in y.re around 0
lower-/.f6467.6
Applied rewrites67.6%
if -1.0199999999999999e27 < y.im < 6.2e14Initial program 69.1%
Taylor expanded in y.re around inf
lower-/.f6475.1
Applied rewrites75.1%
Final simplification71.5%
(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 59.1%
Taylor expanded in y.re around 0
lower-/.f6439.4
Applied rewrites39.4%
Final simplification39.4%
herbie shell --seed 2024340
(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))))