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 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
t_2 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
t_3 := \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{e^{t_2}}\\
t_4 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_5 := e^{t_1 \cdot y.re - t_2} \cdot \cos \left(t_1 \cdot y.im + t_4\right)\\
t_6 := \sqrt[3]{\mathsf{fma}\left(t_0, y.im, t_4\right)}\\
t_7 := t_6 \cdot t_6\\
\mathbf{if}\;t_5 \leq -0.7146837806593755:\\
\;\;\;\;\begin{array}{l}
t_8 := \sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re}}\\
t_3 \cdot \cos \left(t_7 \cdot \sqrt[3]{\mathsf{fma}\left(t_0, y.im, t_8 \cdot \left(y.re \cdot \left(t_8 \cdot t_8\right)\right)\right)}\right)
\end{array}\\
\mathbf{elif}\;t_5 \leq \infty:\\
\;\;\;\;t_5\\
\mathbf{else}:\\
\;\;\;\;t_3 \cdot \cos \left(t_7 \cdot \sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)}\right)\\
\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 (log (hypot x.re x.im)))
(t_1 (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(t_2 (* (atan2 x.im x.re) y.im))
(t_3 (/ (pow (hypot x.re x.im) y.re) (exp t_2)))
(t_4 (* y.re (atan2 x.im x.re)))
(t_5 (* (exp (- (* t_1 y.re) t_2)) (cos (+ (* t_1 y.im) t_4))))
(t_6 (cbrt (fma t_0 y.im t_4)))
(t_7 (* t_6 t_6)))
(if (<= t_5 -0.7146837806593755)
(let* ((t_8 (cbrt (atan2 x.im x.re))))
(*
t_3
(cos (* t_7 (cbrt (fma t_0 y.im (* t_8 (* y.re (* t_8 t_8)))))))))
(if (<= t_5 INFINITY)
t_5
(* t_3 (cos (* t_7 (cbrt (* y.im (log (hypot x.im x.re)))))))))))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 = log(hypot(x_46_re, x_46_im));
double t_1 = log(sqrt((x_46_re * x_46_re) + (x_46_im * x_46_im)));
double t_2 = atan2(x_46_im, x_46_re) * y_46_im;
double t_3 = pow(hypot(x_46_re, x_46_im), y_46_re) / exp(t_2);
double t_4 = y_46_re * atan2(x_46_im, x_46_re);
double t_5 = exp((t_1 * y_46_re) - t_2) * cos((t_1 * y_46_im) + t_4);
double t_6 = cbrt(fma(t_0, y_46_im, t_4));
double t_7 = t_6 * t_6;
double tmp;
if (t_5 <= -0.7146837806593755) {
double t_8_1 = cbrt(atan2(x_46_im, x_46_re));
tmp = t_3 * cos(t_7 * cbrt(fma(t_0, y_46_im, (t_8_1 * (y_46_re * (t_8_1 * t_8_1))))));
} else if (t_5 <= ((double) INFINITY)) {
tmp = t_5;
} else {
tmp = t_3 * cos(t_7 * cbrt(y_46_im * log(hypot(x_46_im, x_46_re))));
}
return tmp;
}



Bits error versus x.re



Bits error versus x.im



Bits error versus y.re



Bits error versus y.im
if (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) < -0.71468378065937554Initial program 37.4
Simplified41.8
Applied add-cube-cbrt_binary6436.2
Applied add-cube-cbrt_binary6437.0
Applied associate-*r*_binary6436.7
if -0.71468378065937554 < (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) < +inf.0Initial program 6.5
if +inf.0 < (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) Initial program 64.0
Simplified17.5
Applied add-cube-cbrt_binary6417.3
Taylor expanded in y.re around 0 64.0
Simplified17.4
Final simplification14.6
herbie shell --seed 2022088
(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)))))