e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\begin{array}{l}
\mathbf{if}\;x.re \leq -9.437066424131207 \cdot 10^{+101}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\mathbf{elif}\;x.re \leq 8.213506235332776 \cdot 10^{-56}:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log \left(\left|x.im\right|\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\end{array}(FPCore (x.re x.im y.re y.im)
:precision binary64
(*
(exp
(-
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
(* (atan2 x.im x.re) y.im)))
(cos
(+
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im)
(* (atan2 x.im x.re) y.re)))))(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (<= x.re -9.437066424131207e+101)
(*
(exp (- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im)))
(cos (* y.re (atan2 x.im x.re))))
(if (<= x.re 8.213506235332776e-56)
(*
(cos (* y.re (atan2 x.im x.re)))
(exp (- (* y.re (log (fabs x.im))) (* (atan2 x.im x.re) y.im))))
(*
(cos (* y.re (atan2 x.im x.re)))
(exp (- (* y.re (log x.re)) (* (atan2 x.im x.re) y.im)))))))double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return exp((log(sqrt((x_46_re * x_46_re) + (x_46_im * x_46_im))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im)) * cos((log(sqrt((x_46_re * x_46_re) + (x_46_im * x_46_im))) * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_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 <= -9.437066424131207e+101) {
tmp = exp((log(-x_46_re) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im)) * cos(y_46_re * atan2(x_46_im, x_46_re));
} else if (x_46_re <= 8.213506235332776e-56) {
tmp = cos(y_46_re * atan2(x_46_im, x_46_re)) * exp((y_46_re * log(fabs(x_46_im))) - (atan2(x_46_im, x_46_re) * y_46_im));
} else {
tmp = cos(y_46_re * atan2(x_46_im, x_46_re)) * exp((y_46_re * log(x_46_re)) - (atan2(x_46_im, x_46_re) * y_46_im));
}
return tmp;
}











Bits error versus x.re











Bits error versus x.im











Bits error versus y.re











Bits error versus y.im
Results
| Alternative 1 | |
|---|---|
| Error | 4.5 |
| Cost | 39553 |
| Alternative 2 | |
|---|---|
| Error | 8.9 |
| Cost | 33481 |
| Alternative 3 | |
|---|---|
| Error | 11.3 |
| Cost | 33802 |
| Alternative 4 | |
|---|---|
| Error | 13.9 |
| Cost | 28429 |
| Alternative 5 | |
|---|---|
| Error | 17.2 |
| Cost | 28037 |
| Alternative 6 | |
|---|---|
| Error | 17.3 |
| Cost | 14917 |
| Alternative 7 | |
|---|---|
| Error | 18.6 |
| Cost | 1348 |
| Alternative 8 | |
|---|---|
| Error | 39.3 |
| Cost | 64 |


if x.re < -9.4370664241312073e101Initial program 51.6
Taylor expanded around 0 29.2
Simplified29.2
Taylor expanded around -inf 1.0
Simplified1.0
Simplified1.0
if -9.4370664241312073e101 < x.re < 8.2135062353327755e-56Initial program 22.8
Taylor expanded around 0 12.8
Simplified12.8
rmApplied add-sqr-sqrt_binary6412.8
Applied rem-sqrt-square_binary6412.8
Taylor expanded around 0 2.7
Simplified2.7
if 8.2135062353327755e-56 < x.re Initial program 40.4
Taylor expanded around 0 25.2
Simplified25.2
Taylor expanded around inf 12.2
Simplified12.2
Final simplification5.4
herbie shell --seed 2021040
(FPCore (x.re x.im y.re y.im)
:name "powComplex, real part"
:precision binary64
(* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))))