
(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
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))))
(if (<= y.im -1.65e+49)
(/ (+ x.im (* y.re (/ x.re y.im))) y.im)
(if (<= y.im -2.2e-118)
t_0
(if (<= y.im 1.25e-156)
(/ (+ x.re (* x.im (/ y.im y.re))) y.re)
(if (<= y.im 7e+81) t_0 (/ (+ x.im (/ y.re (/ y.im x.re))) y.im)))))))
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_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
double tmp;
if (y_46_im <= -1.65e+49) {
tmp = (x_46_im + (y_46_re * (x_46_re / y_46_im))) / y_46_im;
} else if (y_46_im <= -2.2e-118) {
tmp = t_0;
} else if (y_46_im <= 1.25e-156) {
tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re;
} else if (y_46_im <= 7e+81) {
tmp = t_0;
} else {
tmp = (x_46_im + (y_46_re / (y_46_im / x_46_re))) / 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) :: t_0
real(8) :: tmp
t_0 = ((x_46re * y_46re) + (x_46im * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
if (y_46im <= (-1.65d+49)) then
tmp = (x_46im + (y_46re * (x_46re / y_46im))) / y_46im
else if (y_46im <= (-2.2d-118)) then
tmp = t_0
else if (y_46im <= 1.25d-156) then
tmp = (x_46re + (x_46im * (y_46im / y_46re))) / y_46re
else if (y_46im <= 7d+81) then
tmp = t_0
else
tmp = (x_46im + (y_46re / (y_46im / x_46re))) / 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 t_0 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
double tmp;
if (y_46_im <= -1.65e+49) {
tmp = (x_46_im + (y_46_re * (x_46_re / y_46_im))) / y_46_im;
} else if (y_46_im <= -2.2e-118) {
tmp = t_0;
} else if (y_46_im <= 1.25e-156) {
tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re;
} else if (y_46_im <= 7e+81) {
tmp = t_0;
} else {
tmp = (x_46_im + (y_46_re / (y_46_im / x_46_re))) / y_46_im;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = ((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)) tmp = 0 if y_46_im <= -1.65e+49: tmp = (x_46_im + (y_46_re * (x_46_re / y_46_im))) / y_46_im elif y_46_im <= -2.2e-118: tmp = t_0 elif y_46_im <= 1.25e-156: tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re elif y_46_im <= 7e+81: tmp = t_0 else: tmp = (x_46_im + (y_46_re / (y_46_im / x_46_re))) / y_46_im return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = 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))) tmp = 0.0 if (y_46_im <= -1.65e+49) tmp = Float64(Float64(x_46_im + Float64(y_46_re * Float64(x_46_re / y_46_im))) / y_46_im); elseif (y_46_im <= -2.2e-118) tmp = t_0; elseif (y_46_im <= 1.25e-156) tmp = Float64(Float64(x_46_re + Float64(x_46_im * Float64(y_46_im / y_46_re))) / y_46_re); elseif (y_46_im <= 7e+81) tmp = t_0; else tmp = Float64(Float64(x_46_im + Float64(y_46_re / Float64(y_46_im / x_46_re))) / y_46_im); 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_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); tmp = 0.0; if (y_46_im <= -1.65e+49) tmp = (x_46_im + (y_46_re * (x_46_re / y_46_im))) / y_46_im; elseif (y_46_im <= -2.2e-118) tmp = t_0; elseif (y_46_im <= 1.25e-156) tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re; elseif (y_46_im <= 7e+81) tmp = t_0; else tmp = (x_46_im + (y_46_re / (y_46_im / x_46_re))) / y_46_im; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(N[(x$46$re * y$46$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]}, If[LessEqual[y$46$im, -1.65e+49], N[(N[(x$46$im + N[(y$46$re * N[(x$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, -2.2e-118], t$95$0, If[LessEqual[y$46$im, 1.25e-156], N[(N[(x$46$re + N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], If[LessEqual[y$46$im, 7e+81], t$95$0, N[(N[(x$46$im + N[(y$46$re / N[(y$46$im / x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
\mathbf{if}\;y.im \leq -1.65 \cdot 10^{+49}:\\
\;\;\;\;\frac{x.im + y.re \cdot \frac{x.re}{y.im}}{y.im}\\
\mathbf{elif}\;y.im \leq -2.2 \cdot 10^{-118}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y.im \leq 1.25 \cdot 10^{-156}:\\
\;\;\;\;\frac{x.re + x.im \cdot \frac{y.im}{y.re}}{y.re}\\
\mathbf{elif}\;y.im \leq 7 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im + \frac{y.re}{\frac{y.im}{x.re}}}{y.im}\\
\end{array}
\end{array}
if y.im < -1.6499999999999999e49Initial program 48.2%
Taylor expanded in y.im around inf 88.0%
*-commutative88.0%
associate-/l*91.4%
Applied egg-rr91.4%
if -1.6499999999999999e49 < y.im < -2.19999999999999984e-118 or 1.25000000000000002e-156 < y.im < 7.0000000000000001e81Initial program 81.1%
if -2.19999999999999984e-118 < y.im < 1.25000000000000002e-156Initial program 65.9%
*-un-lft-identity65.9%
add-sqr-sqrt65.9%
times-frac65.9%
hypot-define65.9%
fma-define65.8%
hypot-define80.4%
Applied egg-rr80.4%
Taylor expanded in y.re around inf 92.3%
associate-/l*93.2%
Simplified93.2%
if 7.0000000000000001e81 < y.im Initial program 40.3%
Taylor expanded in y.im around inf 79.3%
*-commutative79.3%
associate-/l*84.3%
Applied egg-rr84.3%
clear-num84.3%
un-div-inv84.4%
Applied egg-rr84.4%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<=
(/ (+ (* x.re y.re) (* x.im y.im)) (+ (* y.re y.re) (* y.im y.im)))
1e+306)
(/ (/ (fma y.re x.re (* x.im y.im)) (hypot y.re y.im)) (hypot y.re y.im))
(/ (+ x.re (* x.im (/ y.im y.re))) y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((((x_46_re * y_46_re) + (x_46_im * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 1e+306) {
tmp = (fma(y_46_re, x_46_re, (x_46_im * y_46_im)) / hypot(y_46_re, y_46_im)) / hypot(y_46_re, y_46_im);
} else {
tmp = (x_46_re + (x_46_im * (y_46_im / y_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 (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))) <= 1e+306) tmp = Float64(Float64(fma(y_46_re, x_46_re, Float64(x_46_im * y_46_im)) / hypot(y_46_re, y_46_im)) / hypot(y_46_re, y_46_im)); else tmp = Float64(Float64(x_46_re + Float64(x_46_im * Float64(y_46_im / y_46_re))) / y_46_re); end return tmp end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[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], 1e+306], N[(N[(N[(y$46$re * x$46$re + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re + N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x.re \cdot y.re + x.im \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \leq 10^{+306}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(y.re, x.re, x.im \cdot y.im\right)}{\mathsf{hypot}\left(y.re, y.im\right)}}{\mathsf{hypot}\left(y.re, y.im\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re + x.im \cdot \frac{y.im}{y.re}}{y.re}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 x.re y.re) (*.f64 x.im y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) < 1.00000000000000002e306Initial program 79.5%
*-un-lft-identity79.5%
add-sqr-sqrt79.5%
times-frac79.5%
hypot-define79.5%
fma-define79.5%
hypot-define96.2%
Applied egg-rr96.2%
*-commutative96.2%
associate-*l/96.3%
div-inv96.4%
fma-undefine96.5%
*-commutative96.5%
fma-define96.4%
*-commutative96.4%
Applied egg-rr96.4%
if 1.00000000000000002e306 < (/.f64 (+.f64 (*.f64 x.re y.re) (*.f64 x.im y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) Initial program 12.4%
*-un-lft-identity12.4%
add-sqr-sqrt12.4%
times-frac12.4%
hypot-define12.4%
fma-define12.4%
hypot-define18.3%
Applied egg-rr18.3%
Taylor expanded in y.re around inf 51.8%
associate-/l*57.7%
Simplified57.7%
Final simplification86.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (+ (* x.re y.re) (* x.im y.im))))
(if (<= (/ t_0 (+ (* y.re y.re) (* y.im y.im))) 1e+306)
(* (/ 1.0 (hypot y.re y.im)) (/ t_0 (hypot y.re y.im)))
(/ (+ x.re (* x.im (/ y.im y.re))) y.re))))
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_re) + (x_46_im * y_46_im);
double tmp;
if ((t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 1e+306) {
tmp = (1.0 / hypot(y_46_re, y_46_im)) * (t_0 / hypot(y_46_re, y_46_im));
} else {
tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re;
}
return tmp;
}
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_re) + (x_46_im * y_46_im);
double tmp;
if ((t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 1e+306) {
tmp = (1.0 / Math.hypot(y_46_re, y_46_im)) * (t_0 / Math.hypot(y_46_re, y_46_im));
} else {
tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = (x_46_re * y_46_re) + (x_46_im * y_46_im) tmp = 0 if (t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 1e+306: tmp = (1.0 / math.hypot(y_46_re, y_46_im)) * (t_0 / math.hypot(y_46_re, y_46_im)) else: tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(x_46_re * y_46_re) + Float64(x_46_im * y_46_im)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) <= 1e+306) tmp = Float64(Float64(1.0 / hypot(y_46_re, y_46_im)) * Float64(t_0 / hypot(y_46_re, y_46_im))); else tmp = Float64(Float64(x_46_re + Float64(x_46_im * Float64(y_46_im / y_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) t_0 = (x_46_re * y_46_re) + (x_46_im * y_46_im); tmp = 0.0; if ((t_0 / ((y_46_re * y_46_re) + (y_46_im * y_46_im))) <= 1e+306) tmp = (1.0 / hypot(y_46_re, y_46_im)) * (t_0 / hypot(y_46_re, y_46_im)); else tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$re * y$46$re), $MachinePrecision] + N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+306], N[(N[(1.0 / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re + N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.re \cdot y.re + x.im \cdot y.im\\
\mathbf{if}\;\frac{t\_0}{y.re \cdot y.re + y.im \cdot y.im} \leq 10^{+306}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{t\_0}{\mathsf{hypot}\left(y.re, y.im\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re + x.im \cdot \frac{y.im}{y.re}}{y.re}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 x.re y.re) (*.f64 x.im y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) < 1.00000000000000002e306Initial program 79.5%
*-un-lft-identity79.5%
add-sqr-sqrt79.5%
times-frac79.5%
hypot-define79.5%
fma-define79.5%
hypot-define96.2%
Applied egg-rr96.2%
fma-undefine96.2%
*-commutative96.2%
*-commutative96.2%
Applied egg-rr96.2%
if 1.00000000000000002e306 < (/.f64 (+.f64 (*.f64 x.re y.re) (*.f64 x.im y.im)) (+.f64 (*.f64 y.re y.re) (*.f64 y.im y.im))) Initial program 12.4%
*-un-lft-identity12.4%
add-sqr-sqrt12.4%
times-frac12.4%
hypot-define12.4%
fma-define12.4%
hypot-define18.3%
Applied egg-rr18.3%
Taylor expanded in y.re around inf 51.8%
associate-/l*57.7%
Simplified57.7%
Final simplification86.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -9.5e+90) (not (<= y.re 215000000000.0))) (/ (+ x.re (* y.im (/ x.im y.re))) y.re) (/ (+ x.im (* x.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) {
double tmp;
if ((y_46_re <= -9.5e+90) || !(y_46_re <= 215000000000.0)) {
tmp = (x_46_re + (y_46_im * (x_46_im / y_46_re))) / y_46_re;
} else {
tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im;
}
return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: tmp
if ((y_46re <= (-9.5d+90)) .or. (.not. (y_46re <= 215000000000.0d0))) then
tmp = (x_46re + (y_46im * (x_46im / y_46re))) / y_46re
else
tmp = (x_46im + (x_46re * (y_46re / y_46im))) / y_46im
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -9.5e+90) || !(y_46_re <= 215000000000.0)) {
tmp = (x_46_re + (y_46_im * (x_46_im / y_46_re))) / y_46_re;
} else {
tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re <= -9.5e+90) or not (y_46_re <= 215000000000.0): tmp = (x_46_re + (y_46_im * (x_46_im / y_46_re))) / y_46_re else: tmp = (x_46_im + (x_46_re * (y_46_re / y_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 <= -9.5e+90) || !(y_46_re <= 215000000000.0)) tmp = Float64(Float64(x_46_re + Float64(y_46_im * Float64(x_46_im / y_46_re))) / y_46_re); else tmp = Float64(Float64(x_46_im + Float64(x_46_re * Float64(y_46_re / y_46_im))) / y_46_im); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_re <= -9.5e+90) || ~((y_46_re <= 215000000000.0))) tmp = (x_46_re + (y_46_im * (x_46_im / y_46_re))) / y_46_re; else tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -9.5e+90], N[Not[LessEqual[y$46$re, 215000000000.0]], $MachinePrecision]], N[(N[(x$46$re + N[(y$46$im * N[(x$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(x$46$im + N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -9.5 \cdot 10^{+90} \lor \neg \left(y.re \leq 215000000000\right):\\
\;\;\;\;\frac{x.re + y.im \cdot \frac{x.im}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im + x.re \cdot \frac{y.re}{y.im}}{y.im}\\
\end{array}
\end{array}
if y.re < -9.4999999999999994e90 or 2.15e11 < y.re Initial program 52.5%
Taylor expanded in y.re around inf 77.2%
*-commutative77.2%
Simplified77.2%
associate-/l*80.4%
*-commutative80.4%
Applied egg-rr80.4%
if -9.4999999999999994e90 < y.re < 2.15e11Initial program 68.2%
Taylor expanded in y.im around inf 82.8%
associate-/l*82.9%
Simplified82.9%
Final simplification81.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.re -1.6e+93) (not (<= y.re 28500000000000.0))) (/ x.re y.re) (/ (+ x.im (* x.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) {
double tmp;
if ((y_46_re <= -1.6e+93) || !(y_46_re <= 28500000000000.0)) {
tmp = x_46_re / y_46_re;
} else {
tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im;
}
return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8), intent (in) :: y_46re
real(8), intent (in) :: y_46im
real(8) :: tmp
if ((y_46re <= (-1.6d+93)) .or. (.not. (y_46re <= 28500000000000.0d0))) then
tmp = x_46re / y_46re
else
tmp = (x_46im + (x_46re * (y_46re / y_46im))) / y_46im
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re <= -1.6e+93) || !(y_46_re <= 28500000000000.0)) {
tmp = x_46_re / y_46_re;
} else {
tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re <= -1.6e+93) or not (y_46_re <= 28500000000000.0): tmp = x_46_re / y_46_re else: tmp = (x_46_im + (x_46_re * (y_46_re / y_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 <= -1.6e+93) || !(y_46_re <= 28500000000000.0)) tmp = Float64(x_46_re / y_46_re); else tmp = Float64(Float64(x_46_im + Float64(x_46_re * Float64(y_46_re / y_46_im))) / y_46_im); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_re <= -1.6e+93) || ~((y_46_re <= 28500000000000.0))) tmp = x_46_re / y_46_re; else tmp = (x_46_im + (x_46_re * (y_46_re / y_46_im))) / y_46_im; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -1.6e+93], N[Not[LessEqual[y$46$re, 28500000000000.0]], $MachinePrecision]], N[(x$46$re / y$46$re), $MachinePrecision], N[(N[(x$46$im + N[(x$46$re * N[(y$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -1.6 \cdot 10^{+93} \lor \neg \left(y.re \leq 28500000000000\right):\\
\;\;\;\;\frac{x.re}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im + x.re \cdot \frac{y.re}{y.im}}{y.im}\\
\end{array}
\end{array}
if y.re < -1.6000000000000001e93 or 2.85e13 < y.re Initial program 52.5%
Taylor expanded in y.re around inf 71.4%
if -1.6000000000000001e93 < y.re < 2.85e13Initial program 68.2%
Taylor expanded in y.im around inf 82.8%
associate-/l*82.9%
Simplified82.9%
Final simplification78.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= y.im -3000.0)
(/ (+ x.im (* y.re (/ x.re y.im))) y.im)
(if (<= y.im 3.3e+21)
(/ (+ x.re (* x.im (/ y.im y.re))) y.re)
(/ (+ x.im (/ y.re (/ y.im x.re))) 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 <= -3000.0) {
tmp = (x_46_im + (y_46_re * (x_46_re / y_46_im))) / y_46_im;
} else if (y_46_im <= 3.3e+21) {
tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re;
} else {
tmp = (x_46_im + (y_46_re / (y_46_im / x_46_re))) / 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 <= (-3000.0d0)) then
tmp = (x_46im + (y_46re * (x_46re / y_46im))) / y_46im
else if (y_46im <= 3.3d+21) then
tmp = (x_46re + (x_46im * (y_46im / y_46re))) / y_46re
else
tmp = (x_46im + (y_46re / (y_46im / x_46re))) / 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 <= -3000.0) {
tmp = (x_46_im + (y_46_re * (x_46_re / y_46_im))) / y_46_im;
} else if (y_46_im <= 3.3e+21) {
tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re;
} else {
tmp = (x_46_im + (y_46_re / (y_46_im / x_46_re))) / 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 <= -3000.0: tmp = (x_46_im + (y_46_re * (x_46_re / y_46_im))) / y_46_im elif y_46_im <= 3.3e+21: tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re else: tmp = (x_46_im + (y_46_re / (y_46_im / x_46_re))) / 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 <= -3000.0) tmp = Float64(Float64(x_46_im + Float64(y_46_re * Float64(x_46_re / y_46_im))) / y_46_im); elseif (y_46_im <= 3.3e+21) tmp = Float64(Float64(x_46_re + Float64(x_46_im * Float64(y_46_im / y_46_re))) / y_46_re); else tmp = Float64(Float64(x_46_im + Float64(y_46_re / Float64(y_46_im / x_46_re))) / 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 <= -3000.0) tmp = (x_46_im + (y_46_re * (x_46_re / y_46_im))) / y_46_im; elseif (y_46_im <= 3.3e+21) tmp = (x_46_re + (x_46_im * (y_46_im / y_46_re))) / y_46_re; else tmp = (x_46_im + (y_46_re / (y_46_im / x_46_re))) / 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, -3000.0], N[(N[(x$46$im + N[(y$46$re * N[(x$46$re / y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision], If[LessEqual[y$46$im, 3.3e+21], N[(N[(x$46$re + N[(x$46$im * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$re), $MachinePrecision], N[(N[(x$46$im + N[(y$46$re / N[(y$46$im / x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$46$im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \leq -3000:\\
\;\;\;\;\frac{x.im + y.re \cdot \frac{x.re}{y.im}}{y.im}\\
\mathbf{elif}\;y.im \leq 3.3 \cdot 10^{+21}:\\
\;\;\;\;\frac{x.re + x.im \cdot \frac{y.im}{y.re}}{y.re}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.im + \frac{y.re}{\frac{y.im}{x.re}}}{y.im}\\
\end{array}
\end{array}
if y.im < -3e3Initial program 52.3%
Taylor expanded in y.im around inf 83.9%
*-commutative83.9%
associate-/l*86.8%
Applied egg-rr86.8%
if -3e3 < y.im < 3.3e21Initial program 71.5%
*-un-lft-identity71.5%
add-sqr-sqrt71.5%
times-frac71.5%
hypot-define71.5%
fma-define71.5%
hypot-define81.7%
Applied egg-rr81.7%
Taylor expanded in y.re around inf 78.3%
associate-/l*78.8%
Simplified78.8%
if 3.3e21 < y.im Initial program 51.0%
Taylor expanded in y.im around inf 78.3%
*-commutative78.3%
associate-/l*82.4%
Applied egg-rr82.4%
clear-num82.4%
un-div-inv82.5%
Applied egg-rr82.5%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= y.im -8.8e+32) (not (<= y.im 2.2e+24))) (/ 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 <= -8.8e+32) || !(y_46_im <= 2.2e+24)) {
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 <= (-8.8d+32)) .or. (.not. (y_46im <= 2.2d+24))) 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 <= -8.8e+32) || !(y_46_im <= 2.2e+24)) {
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 <= -8.8e+32) or not (y_46_im <= 2.2e+24): 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 <= -8.8e+32) || !(y_46_im <= 2.2e+24)) 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 <= -8.8e+32) || ~((y_46_im <= 2.2e+24))) 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, -8.8e+32], N[Not[LessEqual[y$46$im, 2.2e+24]], $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 -8.8 \cdot 10^{+32} \lor \neg \left(y.im \leq 2.2 \cdot 10^{+24}\right):\\
\;\;\;\;\frac{x.im}{y.im}\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re}{y.re}\\
\end{array}
\end{array}
if y.im < -8.80000000000000004e32 or 2.20000000000000002e24 < y.im Initial program 50.0%
Taylor expanded in y.re around 0 73.4%
if -8.80000000000000004e32 < y.im < 2.20000000000000002e24Initial program 71.7%
Taylor expanded in y.re around inf 62.5%
Final simplification67.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 45.8%
herbie shell --seed 2024146
(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))))