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}
t_0 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
\mathbf{if}\;y.im \leq -5.379883987355033 \cdot 10^{+66} \lor \neg \left(y.im \leq 2.711595358633846 \cdot 10^{-202}\right):\\
\;\;\;\;e^{y.re \cdot t_1 - t_0} \cdot \left(1 - y.re \cdot \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \sin \left(y.im \cdot t_1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_3 := \cos t_2\\
\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{e^{t_0}} \cdot \left(t_3 - \mathsf{fma}\left(0.5, t_3 \cdot \left(\left(y.im \cdot y.im\right) \cdot {t_1}^{2}\right), t_1 \cdot \left(y.im \cdot \sin t_2\right)\right)\right)
\end{array}\\
\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
(let* ((t_0 (* y.im (atan2 x.im x.re))) (t_1 (log (hypot x.im x.re))))
(if (or (<= y.im -5.379883987355033e+66)
(not (<= y.im 2.711595358633846e-202)))
(*
(exp (- (* y.re t_1) t_0))
(- 1.0 (* y.re (* (atan2 x.im x.re) (sin (* y.im t_1))))))
(let* ((t_2 (* y.re (atan2 x.im x.re))) (t_3 (cos t_2)))
(*
(/ (pow (hypot x.re x.im) y.re) (exp t_0))
(-
t_3
(fma
0.5
(* t_3 (* (* y.im y.im) (pow t_1 2.0)))
(* t_1 (* y.im (sin t_2))))))))))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 t_0 = y_46_im * atan2(x_46_im, x_46_re);
double t_1 = log(hypot(x_46_im, x_46_re));
double tmp;
if ((y_46_im <= -5.379883987355033e+66) || !(y_46_im <= 2.711595358633846e-202)) {
tmp = exp((y_46_re * t_1) - t_0) * (1.0 - (y_46_re * (atan2(x_46_im, x_46_re) * sin(y_46_im * t_1))));
} else {
double t_2 = y_46_re * atan2(x_46_im, x_46_re);
double t_3 = cos(t_2);
tmp = (pow(hypot(x_46_re, x_46_im), y_46_re) / exp(t_0)) * (t_3 - fma(0.5, (t_3 * ((y_46_im * y_46_im) * pow(t_1, 2.0))), (t_1 * (y_46_im * sin(t_2)))));
}
return tmp;
}



Bits error versus x.re



Bits error versus x.im



Bits error versus y.re



Bits error versus y.im
if y.im < -5.3798839873550329e66 or 2.71159535863384599e-202 < y.im Initial program 39.5
Simplified23.4
Taylor expanded in y.re around 0 43.5
Simplified23.1
Taylor expanded in y.im around 0 23.3
Applied pow-to-exp_binary6423.3
Applied div-exp_binary6415.8
Simplified15.8
if -5.3798839873550329e66 < y.im < 2.71159535863384599e-202Initial program 35.7
Simplified8.6
Taylor expanded in y.im around 0 35.8
Simplified9.5
Final simplification13.3
herbie shell --seed 2022067
(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)))))