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 -503.57920634283624:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{elif}\;x.re \leq -6.714498088069512 \cdot 10^{-243}:\\
\;\;\;\;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.re \leq 4.73173669096454 \cdot 10^{-310}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{elif}\;x.re \leq 1.588731696940018 \cdot 10^{-167} \lor \neg \left(x.re \leq 9.090880273551032 \cdot 10^{-13}\right):\\
\;\;\;\;e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
\mathbf{else}:\\
\;\;\;\;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}\\
\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 -503.57920634283624)
(exp (- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im)))
(if (<= x.re -6.714498088069512e-243)
(exp
(-
(* y.re (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(* (atan2 x.im x.re) y.im)))
(if (<= x.re 4.73173669096454e-310)
(exp (- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im)))
(if (or (<= x.re 1.588731696940018e-167)
(not (<= x.re 9.090880273551032e-13)))
(exp (- (* y.re (log x.re)) (* (atan2 x.im x.re) y.im)))
(exp
(-
(* y.re (log (sqrt (+ (* x.re x.re) (* x.im 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_re <= -503.57920634283624) {
tmp = exp((log(-x_46_re) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im));
} else if (x_46_re <= -6.714498088069512e-243) {
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_re <= 4.73173669096454e-310) {
tmp = exp((log(-x_46_re) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im));
} else if ((x_46_re <= 1.588731696940018e-167) || !(x_46_re <= 9.090880273551032e-13)) {
tmp = exp((y_46_re * log(x_46_re)) - (atan2(x_46_im, x_46_re) * y_46_im));
} else {
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));
}
return tmp;
}



Bits error versus x.re



Bits error versus x.im



Bits error versus y.re



Bits error versus y.im
Results
if x.re < -503.579206342836244 or -6.7144980880695118e-243 < x.re < 4.731736690964537e-310Initial program 39.4
Taylor expanded around 0 22.3
Taylor expanded around -inf 3.0
Simplified3.0
if -503.579206342836244 < x.re < -6.7144980880695118e-243 or 1.58873169694001803e-167 < x.re < 9.0908802735510325e-13Initial program 19.9
Taylor expanded around 0 11.8
if 4.731736690964537e-310 < x.re < 1.58873169694001803e-167 or 9.0908802735510325e-13 < x.re Initial program 39.1
Taylor expanded around 0 24.6
Taylor expanded around inf 11.8
Final simplification9.2
herbie shell --seed 2020220
(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)))))