Average Error: 38.0 → 13.3
Time: 12.6s
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.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} \]
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;
}

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 2 regimes
  2. if y.im < -5.3798839873550329e66 or 2.71159535863384599e-202 < y.im

    1. Initial program 39.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. Simplified23.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 y.re around 0 43.5

      \[\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}{\left(\cos \left(\log \left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right) \cdot y.im\right) - y.re \cdot \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \sin \left(\log \left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right) \cdot y.im\right)\right)\right)} \]
    4. Simplified23.1

      \[\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}{\left(\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right) - y.re \cdot \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \sin \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)\right)} \]
    5. Taylor expanded in y.im around 0 23.3

      \[\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 \left(\color{blue}{1} - y.re \cdot \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \sin \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)\right) \]
    6. Applied pow-to-exp_binary6423.3

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \left(1 - y.re \cdot \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \sin \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)\right) \]
    7. Applied div-exp_binary6415.8

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

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

    if -5.3798839873550329e66 < y.im < 2.71159535863384599e-202

    1. Initial program 35.7

      \[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. Simplified8.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. Taylor expanded in y.im around 0 35.8

      \[\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}{\left(\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) - \left(0.5 \cdot \left(\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \left({\log \left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{2} \cdot {y.im}^{2}\right)\right) + \log \left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right) \cdot \left(\sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im\right)\right)\right)} \]
    4. Simplified9.5

      \[\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}{\left(\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) - \mathsf{fma}\left(0.5, \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \left(\left(y.im \cdot y.im\right) \cdot {\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{2}\right), \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot \left(y.im \cdot \sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification13.3

    \[\leadsto \begin{array}{l} \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 \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \left(1 - y.re \cdot \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \sin \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \cdot \left(\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) - \mathsf{fma}\left(0.5, \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \left(\left(y.im \cdot y.im\right) \cdot {\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{2}\right), \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot \left(y.im \cdot \sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right)\\ \end{array} \]

Reproduce

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