Average Error: 38.3 → 18.5
Time: 20.3s
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 \sin \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 := \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{if}\;y.im \leq -7.512750821835541 \cdot 10^{+133}:\\ \;\;\;\;t_1 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right) \cdot \left(\sqrt[3]{y.im} \cdot t_0\right)\right)\right)\right)\\ \mathbf{elif}\;y.im \leq -859914823969486.9 \lor \neg \left(y.im \leq 5.908482168426287 \cdot 10^{+93}\right):\\ \;\;\;\;t_1 \cdot \mathsf{expm1}\left(\mathsf{fma}\left(t_0, y.im, \left(\left(y.im \cdot y.im\right) \cdot {t_0}^{2}\right) \cdot -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_2 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ t_3 := \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\ t_4 := \sin t_2\\ t_1 \cdot \left(\mathsf{fma}\left(\cos t_2, y.im \cdot t_3, t_4\right) - 0.5 \cdot \left({t_3}^{2} \cdot \left(\left(y.im \cdot y.im\right) \cdot t_4\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 \sin \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 := \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{if}\;y.im \leq -7.512750821835541 \cdot 10^{+133}:\\
\;\;\;\;t_1 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right) \cdot \left(\sqrt[3]{y.im} \cdot t_0\right)\right)\right)\right)\\

\mathbf{elif}\;y.im \leq -859914823969486.9 \lor \neg \left(y.im \leq 5.908482168426287 \cdot 10^{+93}\right):\\
\;\;\;\;t_1 \cdot \mathsf{expm1}\left(\mathsf{fma}\left(t_0, y.im, \left(\left(y.im \cdot y.im\right) \cdot {t_0}^{2}\right) \cdot -0.5\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_3 := \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
t_4 := \sin t_2\\
t_1 \cdot \left(\mathsf{fma}\left(\cos t_2, y.im \cdot t_3, t_4\right) - 0.5 \cdot \left({t_3}^{2} \cdot \left(\left(y.im \cdot y.im\right) \cdot t_4\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)))
  (sin
   (+
    (* (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
         (/ (pow (hypot x.re x.im) y.re) (exp (* y.im (atan2 x.im x.re))))))
   (if (<= y.im -7.512750821835541e+133)
     (*
      t_1
      (expm1
       (log1p (sin (* (* (cbrt y.im) (cbrt y.im)) (* (cbrt y.im) t_0))))))
     (if (or (<= y.im -859914823969486.9)
             (not (<= y.im 5.908482168426287e+93)))
       (* t_1 (expm1 (fma t_0 y.im (* (* (* y.im y.im) (pow t_0 2.0)) -0.5))))
       (let* ((t_2 (* y.re (atan2 x.im x.re)))
              (t_3 (log (hypot x.im x.re)))
              (t_4 (sin t_2)))
         (*
          t_1
          (-
           (fma (cos t_2) (* y.im t_3) t_4)
           (* 0.5 (* (pow t_3 2.0) (* (* y.im y.im) t_4))))))))))
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)) * sin((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 = pow(hypot(x_46_re, x_46_im), y_46_re) / exp(y_46_im * atan2(x_46_im, x_46_re));
	double tmp;
	if (y_46_im <= -7.512750821835541e+133) {
		tmp = t_1 * expm1(log1p(sin((cbrt(y_46_im) * cbrt(y_46_im)) * (cbrt(y_46_im) * t_0))));
	} else if ((y_46_im <= -859914823969486.9) || !(y_46_im <= 5.908482168426287e+93)) {
		tmp = t_1 * expm1(fma(t_0, y_46_im, (((y_46_im * y_46_im) * pow(t_0, 2.0)) * -0.5)));
	} else {
		double t_2 = y_46_re * atan2(x_46_im, x_46_re);
		double t_3 = log(hypot(x_46_im, x_46_re));
		double t_4 = sin(t_2);
		tmp = t_1 * (fma(cos(t_2), (y_46_im * t_3), t_4) - (0.5 * (pow(t_3, 2.0) * ((y_46_im * y_46_im) * t_4))));
	}
	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 3 regimes
  2. if y.im < -7.51275082183554086e133

    1. Initial program 41.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 \sin \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. Simplified31.2

      \[\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 \sin \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_binary6431.2

      \[\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(\sin \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.re around 0 46.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 \mathsf{expm1}\left(\color{blue}{\log \left(1 + \sin \left(\log \left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right) \cdot y.im\right)\right)}\right) \]
    5. Simplified30.9

      \[\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 \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\sin \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)}\right) \]
    6. Applied add-cube-cbrt_binary6430.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 \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\color{blue}{\left(\left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right) \cdot \sqrt[3]{y.im}\right)} \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)\right) \]
    7. Applied associate-*l*_binary6430.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 \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \color{blue}{\left(\left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right) \cdot \left(\sqrt[3]{y.im} \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)}\right)\right) \]
    8. Simplified30.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 \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right) \cdot \color{blue}{\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot \sqrt[3]{y.im}\right)}\right)\right)\right) \]

    if -7.51275082183554086e133 < y.im < -859914823969486.875 or 5.90848216842628677e93 < y.im

    1. Initial program 41.6

      \[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 \sin \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. Simplified29.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 \sin \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_binary6429.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 \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \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.re around 0 46.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 \mathsf{expm1}\left(\color{blue}{\log \left(1 + \sin \left(\log \left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right) \cdot y.im\right)\right)}\right) \]
    5. Simplified29.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 \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\sin \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)}\right) \]
    6. Taylor expanded in y.im around 0 39.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 \mathsf{expm1}\left(\color{blue}{\log \left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right) \cdot y.im - 0.5 \cdot \left({\log \left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{2} \cdot {y.im}^{2}\right)}\right) \]
    7. Simplified28.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 \mathsf{expm1}\left(\color{blue}{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \left(\left(y.im \cdot y.im\right) \cdot {\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{2}\right) \cdot -0.5\right)}\right) \]

    if -859914823969486.875 < y.im < 5.90848216842628677e93

    1. Initial program 36.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 \sin \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. Simplified9.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -7.512750821835541 \cdot 10^{+133}:\\ \;\;\;\;\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 \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right) \cdot \left(\sqrt[3]{y.im} \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\right)\right)\right)\right)\\ \mathbf{elif}\;y.im \leq -859914823969486.9 \lor \neg \left(y.im \leq 5.908482168426287 \cdot 10^{+93}\right):\\ \;\;\;\;\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 \mathsf{expm1}\left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \left(\left(y.im \cdot y.im\right) \cdot {\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{2}\right) \cdot -0.5\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(\mathsf{fma}\left(\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right), y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right), \sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) - 0.5 \cdot \left({\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{2} \cdot \left(\left(y.im \cdot y.im\right) \cdot \sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022068 
(FPCore (x.re x.im y.re y.im)
  :name "powComplex, imaginary part"
  :precision binary64
  (* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))))