Average Error: 33.2 → 9.4
Time: 8.8s
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} \mathbf{if}\;x.re \leq -2.735720302949935 \cdot 10^{-91}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{elif}\;x.re \leq -7.186062824055305 \cdot 10^{-152}:\\ \;\;\;\;\sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \left(\sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}}\right)\\ \mathbf{elif}\;x.re \leq -1.471412046702 \cdot 10^{-311}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \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}
\mathbf{if}\;x.re \leq -2.735720302949935 \cdot 10^{-91}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\

\mathbf{elif}\;x.re \leq -7.186062824055305 \cdot 10^{-152}:\\
\;\;\;\;\sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \left(\sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}}\right)\\

\mathbf{elif}\;x.re \leq -1.471412046702 \cdot 10^{-311}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\

\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\

\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
 (if (<= x.re -2.735720302949935e-91)
   (exp (- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im)))
   (if (<= x.re -7.186062824055305e-152)
     (*
      (cbrt
       (/
        (pow (sqrt (+ (pow x.re 2.0) (pow x.im 2.0))) y.re)
        (exp (* (atan2 x.im x.re) y.im))))
      (*
       (cbrt
        (/
         (pow (sqrt (+ (pow x.re 2.0) (pow x.im 2.0))) y.re)
         (exp (* (atan2 x.im x.re) y.im))))
       (cbrt
        (/
         (pow (sqrt (+ (pow x.re 2.0) (pow x.im 2.0))) y.re)
         (exp (* (atan2 x.im x.re) y.im))))))
     (if (<= x.re -1.471412046702e-311)
       (exp (- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im)))
       (exp (- (* y.re (log x.re)) (* (atan2 x.im x.re) y.im)))))))
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 tmp;
	if (x_46_re <= -2.735720302949935e-91) {
		tmp = exp((log(-x_46_re) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im));
	} else if (x_46_re <= -7.186062824055305e-152) {
		tmp = cbrt(pow(sqrt(pow(x_46_re, 2.0) + pow(x_46_im, 2.0)), y_46_re) / exp(atan2(x_46_im, x_46_re) * y_46_im)) * (cbrt(pow(sqrt(pow(x_46_re, 2.0) + pow(x_46_im, 2.0)), y_46_re) / exp(atan2(x_46_im, x_46_re) * y_46_im)) * cbrt(pow(sqrt(pow(x_46_re, 2.0) + pow(x_46_im, 2.0)), y_46_re) / exp(atan2(x_46_im, x_46_re) * y_46_im)));
	} else if (x_46_re <= -1.471412046702e-311) {
		tmp = exp((log(-x_46_re) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im));
	} else {
		tmp = exp((y_46_re * log(x_46_re)) - (atan2(x_46_im, x_46_re) * y_46_im));
	}
	return tmp;
}

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if x.re < -2.735720302949935e-91 or -7.1860628240553052e-152 < x.re < -1.471412046702e-311

    1. Initial program 33.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 \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. Taylor expanded around 0 18.7

      \[\leadsto 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 \color{blue}{1}\]
    3. Taylor expanded around -inf 5.7

      \[\leadsto e^{\log \color{blue}{\left(-1 \cdot x.re\right)} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\]
    4. Simplified5.7

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

    if -2.735720302949935e-91 < x.re < -7.1860628240553052e-152

    1. Initial program 15.2

      \[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. Taylor expanded around 0 8.6

      \[\leadsto 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 \color{blue}{1}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt_binary648.7

      \[\leadsto \color{blue}{\left(\left(\sqrt[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 \sqrt[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}}\right) \cdot \sqrt[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}}\right)} \cdot 1\]
    5. Simplified15.4

      \[\leadsto \left(\color{blue}{\left(\sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}}\right)} \cdot \sqrt[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}}\right) \cdot 1\]
    6. Simplified15.4

      \[\leadsto \left(\left(\sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}}\right) \cdot \color{blue}{\sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}}}\right) \cdot 1\]

    if -1.471412046702e-311 < x.re

    1. Initial program 34.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. Taylor expanded around 0 21.8

      \[\leadsto 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 \color{blue}{1}\]
    3. Taylor expanded around inf 11.9

      \[\leadsto e^{\log \color{blue}{x.re} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -2.735720302949935 \cdot 10^{-91}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{elif}\;x.re \leq -7.186062824055305 \cdot 10^{-152}:\\ \;\;\;\;\sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \left(\sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \sqrt[3]{\frac{{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}}\right)\\ \mathbf{elif}\;x.re \leq -1.471412046702 \cdot 10^{-311}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \end{array}\]

Reproduce

herbie shell --seed 2020260 
(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)))))