Average Error: 32.8 → 6.9
Time: 14.0s
Precision: binary64
\[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} \]
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;
}

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Derivation

  1. Split input into 4 regimes
  2. if y.re < -7.52840611590200902e48

    1. Initial program 35.3

      \[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) \]
    2. Simplified10.6

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)} \]
    3. Applied expm1-log1p-u_binary6410.6

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right)} \]
    4. Taylor expanded in y.im around 0 2.3

      \[\leadsto \color{blue}{e^{\log \left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right) \cdot y.re}} \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right) \]
    5. Simplified2.3

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}} \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right) \]
    6. Applied *-un-lft-identity_binary642.3

      \[\leadsto {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \color{blue}{\left(1 \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\right)\right)\right)\right) \]
    7. Applied associate-*r*_binary642.3

      \[\leadsto {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \color{blue}{\left(y.re \cdot 1\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}}\right)\right)\right)\right) \]

    if -7.52840611590200902e48 < y.re < 3.335270517894325e-21

    1. Initial program 34.1

      \[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) \]
    2. Simplified5.3

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)} \]

    if 3.335270517894325e-21 < y.re < 1.9591354278808688e171

    1. Initial program 23.8

      \[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) \]

    if 1.9591354278808688e171 < y.re

    1. Initial program 19.5

      \[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) \]
    2. Simplified19.4

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)} \]
    3. Taylor expanded in x.re around 0 39.6

      \[\leadsto \color{blue}{\frac{e^{\log x.im \cdot y.re}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \]
    4. Simplified18.3

      \[\leadsto \color{blue}{\frac{{x.im}^{y.re}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.9

    \[\leadsto \begin{array}{l} \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(\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right)\\ \mathbf{elif}\;y.re \leq 3.335270517894325 \cdot 10^{-21}:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}\\ \mathbf{elif}\;y.re \leq 1.9591354278808688 \cdot 10^{+171}:\\ \;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{{x.im}^{y.re}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}\\ \end{array} \]

Reproduce

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)))))