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.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, t_0\right)\right)\\
\mathbf{if}\;y.re \leq -7.528406115902009 \cdot 10^{+48}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(t_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_3 := e^{t_2}\\
\mathbf{if}\;y.re \leq 3.335270517894325 \cdot 10^{-21}:\\
\;\;\;\;t_1 \cdot \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{t_3}\\
\mathbf{elif}\;y.re \leq 1.9591354278808688 \cdot 10^{+171}:\\
\;\;\;\;\begin{array}{l}
t_4 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{y.re \cdot t_4 - t_2} \cdot \cos \left(t_0 + y.im \cdot t_4\right)
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \frac{{x.im}^{y.re}}{t_3}\\
\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.re (atan2 x.im x.re)))
(t_1 (cos (fma (log (hypot x.re x.im)) y.im t_0))))
(if (<= y.re -7.528406115902009e+48)
(* (pow (hypot x.im x.re) y.re) (expm1 (log1p t_1)))
(let* ((t_2 (* y.im (atan2 x.im x.re))) (t_3 (exp t_2)))
(if (<= y.re 3.335270517894325e-21)
(* t_1 (/ (pow (hypot x.re x.im) y.re) t_3))
(if (<= y.re 1.9591354278808688e+171)
(let* ((t_4 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
(* (exp (- (* y.re t_4) t_2)) (cos (+ t_0 (* y.im t_4)))))
(* t_1 (/ (pow x.im y.re) t_3))))))))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_re * atan2(x_46_im, x_46_re);
double t_1 = cos(fma(log(hypot(x_46_re, x_46_im)), y_46_im, t_0));
double tmp;
if (y_46_re <= -7.528406115902009e+48) {
tmp = pow(hypot(x_46_im, x_46_re), y_46_re) * expm1(log1p(t_1));
} else {
double t_2 = y_46_im * atan2(x_46_im, x_46_re);
double t_3 = exp(t_2);
double tmp_1;
if (y_46_re <= 3.335270517894325e-21) {
tmp_1 = t_1 * (pow(hypot(x_46_re, x_46_im), y_46_re) / t_3);
} else if (y_46_re <= 1.9591354278808688e+171) {
double t_4 = log(sqrt((x_46_re * x_46_re) + (x_46_im * x_46_im)));
tmp_1 = exp((y_46_re * t_4) - t_2) * cos(t_0 + (y_46_im * t_4));
} else {
tmp_1 = t_1 * (pow(x_46_im, y_46_re) / t_3);
}
tmp = tmp_1;
}
return tmp;
}



Bits error versus x.re



Bits error versus x.im



Bits error versus y.re



Bits error versus y.im
if y.re < -7.52840611590200902e48Initial program 35.3
Simplified10.6
Applied expm1-log1p-u_binary6410.6
Taylor expanded in y.im around 0 2.3
Simplified2.3
Applied *-un-lft-identity_binary642.3
Applied associate-*r*_binary642.3
if -7.52840611590200902e48 < y.re < 3.335270517894325e-21Initial program 34.1
Simplified5.3
if 3.335270517894325e-21 < y.re < 1.9591354278808688e171Initial program 23.8
if 1.9591354278808688e171 < y.re Initial program 19.5
Simplified19.4
Taylor expanded in x.re around 0 39.6
Simplified18.3
Final simplification6.9
herbie shell --seed 2022081
(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)))))