
(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 11 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 (/ x.im y.re) y.im x.re) y.re)))
(if (<= y.re -1600000000.0)
t_0
(if (<= y.re 1.85e-166)
(/ (fma (/ y.re y.im) x.re x.im) y.im)
(if (<= y.re 2.7e+84)
(/ (fma y.im x.im (* y.re x.re)) (fma y.im y.im (* y.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_im / y_46_re), y_46_im, x_46_re) / y_46_re;
double tmp;
if (y_46_re <= -1600000000.0) {
tmp = t_0;
} else if (y_46_re <= 1.85e-166) {
tmp = fma((y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im;
} else if (y_46_re <= 2.7e+84) {
tmp = fma(y_46_im, x_46_im, (y_46_re * x_46_re)) / fma(y_46_im, y_46_im, (y_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_im / y_46_re), y_46_im, x_46_re) / y_46_re) tmp = 0.0 if (y_46_re <= -1600000000.0) tmp = t_0; elseif (y_46_re <= 1.85e-166) tmp = Float64(fma(Float64(y_46_re / y_46_im), x_46_re, x_46_im) / y_46_im); elseif (y_46_re <= 2.7e+84) tmp = Float64(fma(y_46_im, x_46_im, Float64(y_46_re * x_46_re)) / fma(y_46_im, y_46_im, Float64(y_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$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -1600000000.0], t$95$0, If[LessEqual[y$46$re, 1.85e-166], 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, 2.7e+84], N[(N[(y$46$im * x$46$im + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]), $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 -1600000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 1.85 \cdot 10^{-166}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y.re}{y.im}, x.re, x.im\right)}{y.im}\\
\mathbf{elif}\;y.re \leq 2.7 \cdot 10^{+84}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.6e9 or 2.7e84 < y.re Initial program 46.0%
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-/.f6484.9
Applied rewrites84.9%
if -1.6e9 < y.re < 1.8500000000000001e-166Initial program 69.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6469.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6469.0
Applied rewrites69.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-/.f6487.7
Applied rewrites87.7%
if 1.8500000000000001e-166 < y.re < 2.7e84Initial program 76.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6476.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.3
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6476.3
Applied rewrites76.3%
Final simplification84.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -1e-58)
(/ x.im y.im)
(if (<= y.im 1.15e-49)
(/ (fma (/ x.im y.re) y.im x.re) y.re)
(if (<= y.im 1.08e+121)
(/ (fma y.im x.im (* y.re x.re)) (* y.im y.im))
(/ x.im (fabs 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 <= -1e-58) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 1.15e-49) {
tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
} else if (y_46_im <= 1.08e+121) {
tmp = fma(y_46_im, x_46_im, (y_46_re * x_46_re)) / (y_46_im * y_46_im);
} else {
tmp = x_46_im / fabs(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 <= -1e-58) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 1.15e-49) tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re); elseif (y_46_im <= 1.08e+121) tmp = Float64(fma(y_46_im, x_46_im, Float64(y_46_re * x_46_re)) / Float64(y_46_im * y_46_im)); else tmp = Float64(x_46_im / abs(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, -1e-58], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 1.15e-49], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 1.08e+121], N[(N[(y$46$im * x$46$im + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], N[(x$46$im / N[Abs[y$46$im], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -1 \cdot 10^{-58}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 1.15 \cdot 10^{-49}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\mathbf{elif}\;y.im \leq 1.08 \cdot 10^{+121}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{\left|y.im\right|}\\
\end{array}
\end{array}
if y.im < -1e-58Initial program 52.1%
Taylor expanded in y.re around 0
lower-/.f6461.8
Applied rewrites61.8%
if -1e-58 < y.im < 1.15e-49Initial program 75.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-/.f6484.7
Applied rewrites84.7%
if 1.15e-49 < y.im < 1.08e121Initial program 82.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6482.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6482.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6482.5
Applied rewrites82.5%
Taylor expanded in y.re around 0
unpow2N/A
lower-*.f6466.5
Applied rewrites66.5%
if 1.08e121 < y.im Initial program 32.8%
Taylor expanded in y.re around 0
lower-/.f6477.4
Applied rewrites77.4%
Applied rewrites77.4%
Final simplification75.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (fma y.im x.im (* y.re x.re))))
(if (<= y.im -1e-58)
(/ x.im y.im)
(if (<= y.im 7e-113)
(/ t_0 (* y.re y.re))
(if (<= y.im 1.08e+121) (/ t_0 (* y.im y.im)) (/ x.im (fabs 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, (y_46_re * x_46_re));
double tmp;
if (y_46_im <= -1e-58) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 7e-113) {
tmp = t_0 / (y_46_re * y_46_re);
} else if (y_46_im <= 1.08e+121) {
tmp = t_0 / (y_46_im * y_46_im);
} else {
tmp = x_46_im / fabs(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, x_46_im, Float64(y_46_re * x_46_re)) tmp = 0.0 if (y_46_im <= -1e-58) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 7e-113) tmp = Float64(t_0 / Float64(y_46_re * y_46_re)); elseif (y_46_im <= 1.08e+121) tmp = Float64(t_0 / Float64(y_46_im * y_46_im)); else tmp = Float64(x_46_im / abs(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 * x$46$im + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$im, -1e-58], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 7e-113], N[(t$95$0 / N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 1.08e+121], N[(t$95$0 / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], N[(x$46$im / N[Abs[y$46$im], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)\\
\mathbf{if}\;y.im \leq -1 \cdot 10^{-58}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 7 \cdot 10^{-113}:\\
\;\;\;\;\frac{t\_0}{y.re \cdot y.re}\\
\mathbf{elif}\;y.im \leq 1.08 \cdot 10^{+121}:\\
\;\;\;\;\frac{t\_0}{y.im \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{\left|y.im\right|}\\
\end{array}
\end{array}
if y.im < -1e-58Initial program 52.1%
Taylor expanded in y.re around 0
lower-/.f6461.8
Applied rewrites61.8%
if -1e-58 < y.im < 7.00000000000000057e-113Initial program 75.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6475.9
Applied rewrites75.9%
Taylor expanded in y.re around 0
unpow2N/A
lower-*.f6421.8
Applied rewrites21.8%
Taylor expanded in y.re around inf
unpow2N/A
lower-*.f6473.5
Applied rewrites73.5%
if 7.00000000000000057e-113 < y.im < 1.08e121Initial program 77.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6477.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6477.6
Applied rewrites77.6%
Taylor expanded in y.re around 0
unpow2N/A
lower-*.f6459.3
Applied rewrites59.3%
if 1.08e121 < y.im Initial program 32.8%
Taylor expanded in y.re around 0
lower-/.f6477.4
Applied rewrites77.4%
Applied rewrites77.4%
Final simplification68.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -1e-58)
(/ x.im y.im)
(if (<= y.im 4e-95)
(/ x.re y.re)
(if (<= y.im 1.08e+121)
(/ (fma y.im x.im (* y.re x.re)) (* y.im y.im))
(/ x.im (fabs 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 <= -1e-58) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 4e-95) {
tmp = x_46_re / y_46_re;
} else if (y_46_im <= 1.08e+121) {
tmp = fma(y_46_im, x_46_im, (y_46_re * x_46_re)) / (y_46_im * y_46_im);
} else {
tmp = x_46_im / fabs(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 <= -1e-58) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 4e-95) tmp = Float64(x_46_re / y_46_re); elseif (y_46_im <= 1.08e+121) tmp = Float64(fma(y_46_im, x_46_im, Float64(y_46_re * x_46_re)) / Float64(y_46_im * y_46_im)); else tmp = Float64(x_46_im / abs(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, -1e-58], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 4e-95], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 1.08e+121], N[(N[(y$46$im * x$46$im + N[(y$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] / N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision], N[(x$46$im / N[Abs[y$46$im], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -1 \cdot 10^{-58}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 4 \cdot 10^{-95}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.im \leq 1.08 \cdot 10^{+121}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y.im, x.im, y.re \cdot x.re\right)}{y.im \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{\left|y.im\right|}\\
\end{array}
\end{array}
if y.im < -1e-58Initial program 52.1%
Taylor expanded in y.re around 0
lower-/.f6461.8
Applied rewrites61.8%
if -1e-58 < y.im < 3.99999999999999996e-95Initial program 74.4%
Taylor expanded in y.re around inf
lower-/.f6470.7
Applied rewrites70.7%
if 3.99999999999999996e-95 < y.im < 1.08e121Initial program 82.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6482.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6482.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6482.6
Applied rewrites82.6%
Taylor expanded in y.re around 0
unpow2N/A
lower-*.f6460.7
Applied rewrites60.7%
if 1.08e121 < y.im Initial program 32.8%
Taylor expanded in y.re around 0
lower-/.f6477.4
Applied rewrites77.4%
Applied rewrites77.4%
Final simplification68.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.re -2.75e-13)
(/ x.re y.re)
(if (<= y.re 9.8e-23)
(/ x.im y.im)
(if (<= y.re 1.2e+83)
(* (/ x.re (fma y.im y.im (* y.re y.re))) y.re)
(/ x.re y.re)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if (y_46_re <= -2.75e-13) {
tmp = x_46_re / y_46_re;
} else if (y_46_re <= 9.8e-23) {
tmp = x_46_im / y_46_im;
} else if (y_46_re <= 1.2e+83) {
tmp = (x_46_re / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * y_46_re;
} else {
tmp = x_46_re / y_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (y_46_re <= -2.75e-13) tmp = Float64(x_46_re / y_46_re); elseif (y_46_re <= 9.8e-23) tmp = Float64(x_46_im / y_46_im); elseif (y_46_re <= 1.2e+83) tmp = Float64(Float64(x_46_re / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * y_46_re); else tmp = Float64(x_46_re / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[y$46$re, -2.75e-13], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$re, 9.8e-23], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 1.2e+83], 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], N[(x$46$re / y$46$re), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -2.75 \cdot 10^{-13}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.re \leq 9.8 \cdot 10^{-23}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.re \leq 1.2 \cdot 10^{+83}:\\
\;\;\;\;\frac{x.re}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot y.re\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.re < -2.74999999999999989e-13 or 1.19999999999999996e83 < y.re Initial program 47.8%
Taylor expanded in y.re around inf
lower-/.f6470.5
Applied rewrites70.5%
if -2.74999999999999989e-13 < y.re < 9.7999999999999996e-23Initial program 71.6%
Taylor expanded in y.re around 0
lower-/.f6466.4
Applied rewrites66.4%
if 9.7999999999999996e-23 < y.re < 1.19999999999999996e83Initial program 69.7%
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-*.f6454.1
Applied rewrites54.1%
Final simplification66.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -1e-58)
(/ x.im y.im)
(if (<= y.im 1.25e-93)
(/ x.re y.re)
(if (<= y.im 1.15e+102)
(* (/ x.im (fma y.im y.im (* y.re y.re))) y.im)
(/ x.im (fabs 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 <= -1e-58) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 1.25e-93) {
tmp = x_46_re / y_46_re;
} else if (y_46_im <= 1.15e+102) {
tmp = (x_46_im / fma(y_46_im, y_46_im, (y_46_re * y_46_re))) * y_46_im;
} else {
tmp = x_46_im / fabs(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 <= -1e-58) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 1.25e-93) tmp = Float64(x_46_re / y_46_re); elseif (y_46_im <= 1.15e+102) tmp = Float64(Float64(x_46_im / fma(y_46_im, y_46_im, Float64(y_46_re * y_46_re))) * y_46_im); else tmp = Float64(x_46_im / abs(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, -1e-58], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 1.25e-93], N[(x$46$re / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 1.15e+102], 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], N[(x$46$im / N[Abs[y$46$im], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -1 \cdot 10^{-58}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 1.25 \cdot 10^{-93}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{elif}\;y.im \leq 1.15 \cdot 10^{+102}:\\
\;\;\;\;\frac{x.im}{\mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)} \cdot y.im\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{\left|y.im\right|}\\
\end{array}
\end{array}
if y.im < -1e-58Initial program 52.1%
Taylor expanded in y.re around 0
lower-/.f6461.8
Applied rewrites61.8%
if -1e-58 < y.im < 1.24999999999999999e-93Initial program 74.6%
Taylor expanded in y.re around inf
lower-/.f6470.0
Applied rewrites70.0%
if 1.24999999999999999e-93 < y.im < 1.1499999999999999e102Initial program 80.9%
Taylor expanded in x.re around 0
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6451.6
Applied rewrites51.6%
if 1.1499999999999999e102 < y.im Initial program 35.6%
Taylor expanded in y.re around 0
lower-/.f6476.3
Applied rewrites76.3%
Applied rewrites76.3%
Final simplification66.7%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -1600000000.0) (not (<= y.re 3e+14))) (/ (fma (/ x.im y.re) y.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_re <= -1600000000.0) || !(y_46_re <= 3e+14)) {
tmp = fma((x_46_im / y_46_re), y_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_re <= -1600000000.0) || !(y_46_re <= 3e+14)) tmp = Float64(fma(Float64(x_46_im / y_46_re), y_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[Or[LessEqual[y$46$re, -1600000000.0], N[Not[LessEqual[y$46$re, 3e+14]], $MachinePrecision]], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$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.re \leq -1600000000 \lor \neg \left(y.re \leq 3 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.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.re < -1.6e9 or 3e14 < y.re Initial program 49.8%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6480.3
Applied rewrites80.3%
if -1.6e9 < y.re < 3e14Initial program 71.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6471.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6471.6
Applied rewrites71.6%
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-/.f6481.7
Applied rewrites81.7%
Final simplification81.1%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -1600000000.0) (not (<= y.re 3e+14))) (/ (fma (/ x.im y.re) y.im x.re) y.re) (/ (fma (/ x.re y.im) 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_re <= -1600000000.0) || !(y_46_re <= 3e+14)) {
tmp = fma((x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re;
} else {
tmp = fma((x_46_re / y_46_im), y_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_re <= -1600000000.0) || !(y_46_re <= 3e+14)) tmp = Float64(fma(Float64(x_46_im / y_46_re), y_46_im, x_46_re) / y_46_re); else tmp = Float64(fma(Float64(x_46_re / y_46_im), y_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[Or[LessEqual[y$46$re, -1600000000.0], N[Not[LessEqual[y$46$re, 3e+14]], $MachinePrecision]], N[(N[(N[(x$46$im / y$46$re), $MachinePrecision] * y$46$im + x$46$re), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(N[(x$46$re / y$46$im), $MachinePrecision] * y$46$re + x$46$im), $MachinePrecision] / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -1600000000 \lor \neg \left(y.re \leq 3 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.im}{y.re}, y.im, x.re\right)}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x.re}{y.im}, y.re, x.im\right)}{y.im}\\
\end{array}
\end{array}
if y.re < -1.6e9 or 3e14 < y.re Initial program 49.8%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6480.3
Applied rewrites80.3%
if -1.6e9 < y.re < 3e14Initial program 71.6%
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-/.f6480.3
Applied rewrites80.3%
Final simplification80.3%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= y.im -1e-58) (/ x.im y.im) (if (<= y.im 3.9e-92) (/ x.re y.re) (/ x.im (fabs 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 <= -1e-58) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 3.9e-92) {
tmp = x_46_re / y_46_re;
} else {
tmp = x_46_im / fabs(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 <= (-1d-58)) then
tmp = x_46im / y_46im
else if (y_46im <= 3.9d-92) then
tmp = x_46re / y_46re
else
tmp = x_46im / abs(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 <= -1e-58) {
tmp = x_46_im / y_46_im;
} else if (y_46_im <= 3.9e-92) {
tmp = x_46_re / y_46_re;
} else {
tmp = x_46_im / Math.abs(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 <= -1e-58: tmp = x_46_im / y_46_im elif y_46_im <= 3.9e-92: tmp = x_46_re / y_46_re else: tmp = x_46_im / math.fabs(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 <= -1e-58) tmp = Float64(x_46_im / y_46_im); elseif (y_46_im <= 3.9e-92) tmp = Float64(x_46_re / y_46_re); else tmp = Float64(x_46_im / abs(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 <= -1e-58) tmp = x_46_im / y_46_im; elseif (y_46_im <= 3.9e-92) tmp = x_46_re / y_46_re; else tmp = x_46_im / abs(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, -1e-58], N[(x$46$im / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 3.9e-92], N[(x$46$re / y$46$re), $MachinePrecision], N[(x$46$im / N[Abs[y$46$im], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -1 \cdot 10^{-58}:\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{elif}\;y.im \leq 3.9 \cdot 10^{-92}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im}{\left|y.im\right|}\\
\end{array}
\end{array}
if y.im < -1e-58Initial program 52.1%
Taylor expanded in y.re around 0
lower-/.f6461.8
Applied rewrites61.8%
if -1e-58 < y.im < 3.8999999999999997e-92Initial program 74.6%
Taylor expanded in y.re around inf
lower-/.f6470.0
Applied rewrites70.0%
if 3.8999999999999997e-92 < y.im Initial program 53.4%
Taylor expanded in y.re around 0
lower-/.f6459.6
Applied rewrites59.6%
Applied rewrites59.6%
Final simplification64.5%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -1e-58) (not (<= y.im 3.9e-92))) (/ 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 <= -1e-58) || !(y_46_im <= 3.9e-92)) {
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 <= (-1d-58)) .or. (.not. (y_46im <= 3.9d-92))) 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 <= -1e-58) || !(y_46_im <= 3.9e-92)) {
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 <= -1e-58) or not (y_46_im <= 3.9e-92): 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 <= -1e-58) || !(y_46_im <= 3.9e-92)) 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 <= -1e-58) || ~((y_46_im <= 3.9e-92))) 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, -1e-58], N[Not[LessEqual[y$46$im, 3.9e-92]], $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 \cdot 10^{-58} \lor \neg \left(y.im \leq 3.9 \cdot 10^{-92}\right):\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.im < -1e-58 or 3.8999999999999997e-92 < y.im Initial program 52.7%
Taylor expanded in y.re around 0
lower-/.f6460.6
Applied rewrites60.6%
if -1e-58 < y.im < 3.8999999999999997e-92Initial program 74.6%
Taylor expanded in y.re around inf
lower-/.f6470.0
Applied rewrites70.0%
Final simplification64.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 61.7%
Taylor expanded in y.re around 0
lower-/.f6443.0
Applied rewrites43.0%
Final simplification43.0%
herbie shell --seed 2024339
(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))))