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.im \leq -339342992904603.25:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log \left(-x.im\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{elif}\;x.im \leq -1.0162343325851357 \cdot 10^{-69}:\\
\;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{elif}\;x.im \leq 4.3354624121682 \cdot 10^{-310}:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log \left(-x.im\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.im - \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.im -339342992904603.25)
(*
(cos (* y.re (atan2 x.im x.re)))
(exp (- (* y.re (log (- x.im))) (* (atan2 x.im x.re) y.im))))
(if (<= x.im -1.0162343325851357e-69)
(exp
(-
(* y.re (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(* (atan2 x.im x.re) y.im)))
(if (<= x.im 4.3354624121682e-310)
(*
(cos (* y.re (atan2 x.im x.re)))
(exp (- (* y.re (log (- x.im))) (* (atan2 x.im x.re) y.im))))
(*
(cos (* y.re (atan2 x.im x.re)))
(exp (- (* y.re (log x.im)) (* (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_im <= -339342992904603.25) {
tmp = cos(y_46_re * atan2(x_46_im, x_46_re)) * exp((y_46_re * log(-x_46_im)) - (atan2(x_46_im, x_46_re) * y_46_im));
} else if (x_46_im <= -1.0162343325851357e-69) {
tmp = exp((y_46_re * log(sqrt((x_46_re * x_46_re) + (x_46_im * x_46_im)))) - (atan2(x_46_im, x_46_re) * y_46_im));
} else if (x_46_im <= 4.3354624121682e-310) {
tmp = cos(y_46_re * atan2(x_46_im, x_46_re)) * exp((y_46_re * log(-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_im)) - (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 | 9.6 |
| Cost | 110785 |
| Alternative 2 | |
|---|---|
| Error | 9.5 |
| Cost | 66243 |
| Alternative 3 | |
|---|---|
| Error | 9.6 |
| Cost | 33795 |
| Alternative 4 | |
|---|---|
| Error | 14.5 |
| Cost | 27459 |
| Alternative 5 | |
|---|---|
| Error | 14.6 |
| Cost | 1348 |
| Alternative 6 | |
|---|---|
| Error | 38.4 |
| Cost | 64 |

if x.im < -339342992904603.25 or -1.01623433258513573e-69 < x.im < 4.33546241216819e-310Initial program 35.5
Taylor expanded around 0 20.6
Simplified20.6
Taylor expanded around -inf 9.0
Simplified9.0
Simplified9.0
if -339342992904603.25 < x.im < -1.01623433258513573e-69Initial program 20.6
Taylor expanded around 0 12.0
Simplified12.0
Taylor expanded around 0 11.9
Simplified11.9
if 4.33546241216819e-310 < x.im Initial program 33.2
Taylor expanded around 0 20.0
Simplified20.0
Taylor expanded around 0 9.6
Simplified9.6
Final simplification9.5
herbie shell --seed 2021044
(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)))))