
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (- (* x.im y.re) (* x.re 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_im * y_46_re) - (x_46_re * 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_46im * y_46re) - (x_46re * 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_im * y_46_re) - (x_46_re * 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_im * y_46_re) - (x_46_re * 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_im * y_46_re) - Float64(x_46_re * 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_im * y_46_re) - (x_46_re * 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$im * y$46$re), $MachinePrecision] - N[(x$46$re * 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.im \cdot y.re - x.re \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.im y.re) (* x.re 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_im * y_46_re) - (x_46_re * 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_46im * y_46re) - (x_46re * 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_im * y_46_re) - (x_46_re * 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_im * y_46_re) - (x_46_re * 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_im * y_46_re) - Float64(x_46_re * 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_im * y_46_re) - (x_46_re * 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$im * y$46$re), $MachinePrecision] - N[(x$46$re * 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.im \cdot y.re - x.re \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 y.im (/ x.re (- y.re)) x.im) y.re)))
(if (<= y.re -1.72e+84)
t_1
(if (<= y.re -7.5e-136)
(fma (/ x.im t_0) y.re (/ (- (* x.re y.im)) t_0))
(if (<= y.re 1.95e-14)
(/ (fma x.im (/ y.re y.im) (- x.re)) y.im)
(if (<= y.re 6.6e+92)
(fma (- y.im) (/ x.re t_0) (/ (* y.re x.im) 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, y_46_im, (y_46_re * y_46_re));
double t_1 = fma(y_46_im, (x_46_re / -y_46_re), x_46_im) / y_46_re;
double tmp;
if (y_46_re <= -1.72e+84) {
tmp = t_1;
} else if (y_46_re <= -7.5e-136) {
tmp = fma((x_46_im / t_0), y_46_re, (-(x_46_re * y_46_im) / t_0));
} else if (y_46_re <= 1.95e-14) {
tmp = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / y_46_im;
} else if (y_46_re <= 6.6e+92) {
tmp = fma(-y_46_im, (x_46_re / t_0), ((y_46_re * x_46_im) / t_0));
} else {
tmp = t_1;
}
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 = Float64(fma(y_46_im, Float64(x_46_re / Float64(-y_46_re)), x_46_im) / y_46_re) tmp = 0.0 if (y_46_re <= -1.72e+84) tmp = t_1; elseif (y_46_re <= -7.5e-136) tmp = fma(Float64(x_46_im / t_0), y_46_re, Float64(Float64(-Float64(x_46_re * y_46_im)) / t_0)); elseif (y_46_re <= 1.95e-14) tmp = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / y_46_im); elseif (y_46_re <= 6.6e+92) tmp = fma(Float64(-y_46_im), Float64(x_46_re / t_0), Float64(Float64(y_46_re * x_46_im) / 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[(y$46$im * y$46$im + N[(y$46$re * y$46$re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y$46$im * N[(x$46$re / (-y$46$re)), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -1.72e+84], t$95$1, If[LessEqual[y$46$re, -7.5e-136], N[(N[(x$46$im / t$95$0), $MachinePrecision] * y$46$re + N[((-N[(x$46$re * y$46$im), $MachinePrecision]) / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.95e-14], N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 6.6e+92], N[((-y$46$im) * N[(x$46$re / t$95$0), $MachinePrecision] + N[(N[(y$46$re * x$46$im), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y.im, y.im, y.re \cdot y.re\right)\\
t_1 := \frac{\mathsf{fma}\left(y.im, \frac{x.re}{-y.re}, x.im\right)}{y.re}\\
\mathbf{if}\;y.re \leq -1.72 \cdot 10^{+84}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.re \leq -7.5 \cdot 10^{-136}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x.im}{t\_0}, y.re, \frac{-x.re \cdot y.im}{t\_0}\right)\\
\mathbf{elif}\;y.re \leq 1.95 \cdot 10^{-14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\mathbf{elif}\;y.re \leq 6.6 \cdot 10^{+92}:\\
\;\;\;\;\mathsf{fma}\left(-y.im, \frac{x.re}{t\_0}, \frac{y.re \cdot x.im}{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.re < -1.72e84 or 6.59999999999999948e92 < y.re Initial program 50.0%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6450.0
Applied rewrites50.0%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6483.2
Applied rewrites83.2%
if -1.72e84 < y.re < -7.5000000000000003e-136Initial program 80.9%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites91.5%
if -7.5000000000000003e-136 < y.re < 1.9499999999999999e-14Initial program 69.5%
Taylor expanded in y.re around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
associate-/l*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6491.0
Applied rewrites91.0%
Applied rewrites92.9%
if 1.9499999999999999e-14 < y.re < 6.59999999999999948e92Initial program 68.8%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f6475.6
Applied rewrites75.6%
Final simplification87.1%
(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 (- y.im) (/ x.re t_0) (/ (* y.re x.im) t_0)))
(t_2 (/ (fma y.im (/ x.re (- y.re)) x.im) y.re)))
(if (<= y.re -3e+22)
t_2
(if (<= y.re -4e-133)
t_1
(if (<= y.re 1.95e-14)
(/ (fma x.im (/ y.re y.im) (- x.re)) y.im)
(if (<= y.re 6.6e+92) 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(-y_46_im, (x_46_re / t_0), ((y_46_re * x_46_im) / t_0));
double t_2 = fma(y_46_im, (x_46_re / -y_46_re), x_46_im) / y_46_re;
double tmp;
if (y_46_re <= -3e+22) {
tmp = t_2;
} else if (y_46_re <= -4e-133) {
tmp = t_1;
} else if (y_46_re <= 1.95e-14) {
tmp = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / y_46_im;
} else if (y_46_re <= 6.6e+92) {
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(Float64(-y_46_im), Float64(x_46_re / t_0), Float64(Float64(y_46_re * x_46_im) / t_0)) t_2 = Float64(fma(y_46_im, Float64(x_46_re / Float64(-y_46_re)), x_46_im) / y_46_re) tmp = 0.0 if (y_46_re <= -3e+22) tmp = t_2; elseif (y_46_re <= -4e-133) tmp = t_1; elseif (y_46_re <= 1.95e-14) tmp = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / y_46_im); elseif (y_46_re <= 6.6e+92) 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[((-y$46$im) * N[(x$46$re / t$95$0), $MachinePrecision] + N[(N[(y$46$re * x$46$im), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y$46$im * N[(x$46$re / (-y$46$re)), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -3e+22], t$95$2, If[LessEqual[y$46$re, -4e-133], t$95$1, If[LessEqual[y$46$re, 1.95e-14], N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 6.6e+92], 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(-y.im, \frac{x.re}{t\_0}, \frac{y.re \cdot x.im}{t\_0}\right)\\
t_2 := \frac{\mathsf{fma}\left(y.im, \frac{x.re}{-y.re}, x.im\right)}{y.re}\\
\mathbf{if}\;y.re \leq -3 \cdot 10^{+22}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y.re \leq -4 \cdot 10^{-133}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.re \leq 1.95 \cdot 10^{-14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\mathbf{elif}\;y.re \leq 6.6 \cdot 10^{+92}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if y.re < -3e22 or 6.59999999999999948e92 < y.re Initial program 52.1%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6452.1
Applied rewrites52.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6483.9
Applied rewrites83.9%
if -3e22 < y.re < -4.0000000000000003e-133 or 1.9499999999999999e-14 < y.re < 6.59999999999999948e92Initial program 76.8%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f6482.5
Applied rewrites82.5%
if -4.0000000000000003e-133 < y.re < 1.9499999999999999e-14Initial program 69.1%
Taylor expanded in y.re around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
associate-/l*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6490.2
Applied rewrites90.2%
Applied rewrites92.1%
Final simplification86.7%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (- (* y.re x.im) (* x.re y.im)) (fma y.re y.re (* y.im y.im))))
(t_1 (/ (fma y.im (/ x.re (- y.re)) x.im) y.re)))
(if (<= y.re -1.32e+22)
t_1
(if (<= y.re -1.6e-123)
t_0
(if (<= y.re 1.95e-14)
(/ (fma x.im (/ y.re y.im) (- x.re)) y.im)
(if (<= y.re 6.4e+69) 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 = ((y_46_re * x_46_im) - (x_46_re * y_46_im)) / fma(y_46_re, y_46_re, (y_46_im * y_46_im));
double t_1 = fma(y_46_im, (x_46_re / -y_46_re), x_46_im) / y_46_re;
double tmp;
if (y_46_re <= -1.32e+22) {
tmp = t_1;
} else if (y_46_re <= -1.6e-123) {
tmp = t_0;
} else if (y_46_re <= 1.95e-14) {
tmp = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / y_46_im;
} else if (y_46_re <= 6.4e+69) {
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(Float64(Float64(y_46_re * x_46_im) - Float64(x_46_re * y_46_im)) / fma(y_46_re, y_46_re, Float64(y_46_im * y_46_im))) t_1 = Float64(fma(y_46_im, Float64(x_46_re / Float64(-y_46_re)), x_46_im) / y_46_re) tmp = 0.0 if (y_46_re <= -1.32e+22) tmp = t_1; elseif (y_46_re <= -1.6e-123) tmp = t_0; elseif (y_46_re <= 1.95e-14) tmp = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / y_46_im); elseif (y_46_re <= 6.4e+69) 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[(N[(y$46$re * x$46$im), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(y$46$re * y$46$re + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y$46$im * N[(x$46$re / (-y$46$re)), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -1.32e+22], t$95$1, If[LessEqual[y$46$re, -1.6e-123], t$95$0, If[LessEqual[y$46$re, 1.95e-14], N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$re, 6.4e+69], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y.re \cdot x.im - x.re \cdot y.im}{\mathsf{fma}\left(y.re, y.re, y.im \cdot y.im\right)}\\
t_1 := \frac{\mathsf{fma}\left(y.im, \frac{x.re}{-y.re}, x.im\right)}{y.re}\\
\mathbf{if}\;y.re \leq -1.32 \cdot 10^{+22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y.re \leq -1.6 \cdot 10^{-123}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 1.95 \cdot 10^{-14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\mathbf{elif}\;y.re \leq 6.4 \cdot 10^{+69}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.re < -1.32e22 or 6.3999999999999997e69 < y.re Initial program 52.1%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6452.1
Applied rewrites52.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6482.7
Applied rewrites82.7%
if -1.32e22 < y.re < -1.59999999999999989e-123 or 1.9499999999999999e-14 < y.re < 6.3999999999999997e69Initial program 80.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6480.4
Applied rewrites80.4%
if -1.59999999999999989e-123 < y.re < 1.9499999999999999e-14Initial program 68.5%
Taylor expanded in y.re around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
associate-/l*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6489.4
Applied rewrites89.4%
Applied rewrites91.2%
Final simplification85.6%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma y.im (/ x.re (- y.re)) x.im) y.re)))
(if (<= y.re -1700000000000.0)
t_0
(if (<= y.re 5e+69) (/ (fma x.im (/ y.re y.im) (- x.re)) 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(y_46_im, (x_46_re / -y_46_re), x_46_im) / y_46_re;
double tmp;
if (y_46_re <= -1700000000000.0) {
tmp = t_0;
} else if (y_46_re <= 5e+69) {
tmp = fma(x_46_im, (y_46_re / y_46_im), -x_46_re) / 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(y_46_im, Float64(x_46_re / Float64(-y_46_re)), x_46_im) / y_46_re) tmp = 0.0 if (y_46_re <= -1700000000000.0) tmp = t_0; elseif (y_46_re <= 5e+69) tmp = Float64(fma(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / 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[(y$46$im * N[(x$46$re / (-y$46$re)), $MachinePrecision] + x$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -1700000000000.0], t$95$0, If[LessEqual[y$46$re, 5e+69], N[(N[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(y.im, \frac{x.re}{-y.re}, x.im\right)}{y.re}\\
\mathbf{if}\;y.re \leq -1700000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.re \leq 5 \cdot 10^{+69}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.re < -1.7e12 or 5.00000000000000036e69 < y.re Initial program 52.5%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6452.5
Applied rewrites52.5%
Taylor expanded in y.re around inf
lower-/.f64N/A
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6482.3
Applied rewrites82.3%
if -1.7e12 < y.re < 5.00000000000000036e69Initial program 72.3%
Taylor expanded in y.re around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
associate-/l*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6478.7
Applied rewrites78.7%
Applied rewrites80.0%
Final simplification81.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ (fma x.im (/ y.re y.im) (- x.re)) y.im)))
(if (<= y.im -1.65e+78)
t_0
(if (<= y.im 210000000000.0)
(/ (- x.im (/ (* x.re 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_im;
double tmp;
if (y_46_im <= -1.65e+78) {
tmp = t_0;
} else if (y_46_im <= 210000000000.0) {
tmp = (x_46_im - ((x_46_re * 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(x_46_im, Float64(y_46_re / y_46_im), Float64(-x_46_re)) / y_46_im) tmp = 0.0 if (y_46_im <= -1.65e+78) tmp = t_0; elseif (y_46_im <= 210000000000.0) tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / 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[(x$46$im * N[(y$46$re / y$46$im), $MachinePrecision] + (-x$46$re)), $MachinePrecision] / y$46$im), $MachinePrecision]}, If[LessEqual[y$46$im, -1.65e+78], t$95$0, If[LessEqual[y$46$im, 210000000000.0], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(x.im, \frac{y.re}{y.im}, -x.re\right)}{y.im}\\
\mathbf{if}\;y.im \leq -1.65 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 210000000000:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -1.65e78 or 2.1e11 < y.im Initial program 45.6%
Taylor expanded in y.re around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
unpow2N/A
associate-/r*N/A
div-subN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
associate-/l*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6482.2
Applied rewrites82.2%
Applied rewrites82.2%
if -1.65e78 < y.im < 2.1e11Initial program 76.9%
Taylor expanded in y.re around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6478.5
Applied rewrites78.5%
Final simplification80.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ x.re (- y.im))))
(if (<= y.im -1.05e+81)
t_0
(if (<= y.im 6.1e+59) (/ (- x.im (/ (* x.re 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 = x_46_re / -y_46_im;
double tmp;
if (y_46_im <= -1.05e+81) {
tmp = t_0;
} else if (y_46_im <= 6.1e+59) {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = x_46re / -y_46im
if (y_46im <= (-1.05d+81)) then
tmp = t_0
else if (y_46im <= 6.1d+59) then
tmp = (x_46im - ((x_46re * y_46im) / y_46re)) / y_46re
else
tmp = t_0
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 t_0 = x_46_re / -y_46_im;
double tmp;
if (y_46_im <= -1.05e+81) {
tmp = t_0;
} else if (y_46_im <= 6.1e+59) {
tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re;
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = x_46_re / -y_46_im tmp = 0 if y_46_im <= -1.05e+81: tmp = t_0 elif y_46_im <= 6.1e+59: tmp = (x_46_im - ((x_46_re * 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(x_46_re / Float64(-y_46_im)) tmp = 0.0 if (y_46_im <= -1.05e+81) tmp = t_0; elseif (y_46_im <= 6.1e+59) tmp = Float64(Float64(x_46_im - Float64(Float64(x_46_re * y_46_im) / y_46_re)) / y_46_re); else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = x_46_re / -y_46_im; tmp = 0.0; if (y_46_im <= -1.05e+81) tmp = t_0; elseif (y_46_im <= 6.1e+59) tmp = (x_46_im - ((x_46_re * y_46_im) / y_46_re)) / y_46_re; else tmp = t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(x$46$re / (-y$46$im)), $MachinePrecision]}, If[LessEqual[y$46$im, -1.05e+81], t$95$0, If[LessEqual[y$46$im, 6.1e+59], N[(N[(x$46$im - N[(N[(x$46$re * y$46$im), $MachinePrecision] / y$46$re), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x.re}{-y.im}\\
\mathbf{if}\;y.im \leq -1.05 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 6.1 \cdot 10^{+59}:\\
\;\;\;\;\frac{x.im - \frac{x.re \cdot y.im}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -1.0499999999999999e81 or 6.09999999999999973e59 < y.im Initial program 42.1%
Taylor expanded in y.re around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6476.1
Applied rewrites76.1%
if -1.0499999999999999e81 < y.im < 6.09999999999999973e59Initial program 77.1%
Taylor expanded in y.re around inf
lower-/.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6476.4
Applied rewrites76.4%
Final simplification76.3%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (/ x.re (- y.im))))
(if (<= y.im -1.65e+78)
t_0
(if (<= y.im 240000000000.0) (/ x.im 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 = x_46_re / -y_46_im;
double tmp;
if (y_46_im <= -1.65e+78) {
tmp = t_0;
} else if (y_46_im <= 240000000000.0) {
tmp = x_46_im / y_46_re;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = x_46re / -y_46im
if (y_46im <= (-1.65d+78)) then
tmp = t_0
else if (y_46im <= 240000000000.0d0) then
tmp = x_46im / y_46re
else
tmp = t_0
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 t_0 = x_46_re / -y_46_im;
double tmp;
if (y_46_im <= -1.65e+78) {
tmp = t_0;
} else if (y_46_im <= 240000000000.0) {
tmp = x_46_im / y_46_re;
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = x_46_re / -y_46_im tmp = 0 if y_46_im <= -1.65e+78: tmp = t_0 elif y_46_im <= 240000000000.0: tmp = x_46_im / 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(x_46_re / Float64(-y_46_im)) tmp = 0.0 if (y_46_im <= -1.65e+78) tmp = t_0; elseif (y_46_im <= 240000000000.0) tmp = Float64(x_46_im / y_46_re); else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = x_46_re / -y_46_im; tmp = 0.0; if (y_46_im <= -1.65e+78) tmp = t_0; elseif (y_46_im <= 240000000000.0) tmp = x_46_im / y_46_re; else tmp = t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(x$46$re / (-y$46$im)), $MachinePrecision]}, If[LessEqual[y$46$im, -1.65e+78], t$95$0, If[LessEqual[y$46$im, 240000000000.0], N[(x$46$im / y$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x.re}{-y.im}\\
\mathbf{if}\;y.im \leq -1.65 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 240000000000:\\
\;\;\;\;\frac{x.im}{y.re}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y.im < -1.65e78 or 2.4e11 < y.im Initial program 45.6%
Taylor expanded in y.re around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6472.5
Applied rewrites72.5%
if -1.65e78 < y.im < 2.4e11Initial program 76.9%
Taylor expanded in y.re around inf
lower-/.f6467.9
Applied rewrites67.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ x.im y.re))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return x_46_im / y_46_re;
}
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_46re
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_re;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return x_46_im / y_46_re
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(x_46_im / y_46_re) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = x_46_im / y_46_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im / y$46$re), $MachinePrecision]
\begin{array}{l}
\\
\frac{x.im}{y.re}
\end{array}
Initial program 63.9%
Taylor expanded in y.re around inf
lower-/.f6446.0
Applied rewrites46.0%
herbie shell --seed 2024237
(FPCore (x.re x.im y.re y.im)
:name "_divideComplex, imaginary part"
:precision binary64
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))