powComplex, real part

?

Percentage Accurate: 41.0% → 81.3%
Time: 26.3s
Precision: binary64
Cost: 71684

?

\[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 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_2 := e^{t_1 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ t_3 := y.im \cdot \log x.im\\ \mathbf{if}\;x.im \leq 5.4 \cdot 10^{-302}:\\ \;\;\;\;t_2 \cdot \sqrt{{\cos \left(\mathsf{fma}\left(t_1, y.im, t_0\right)\right)}^{2}}\\ \mathbf{elif}\;x.im \leq 2:\\ \;\;\;\;t_2 \cdot \cos t_3\\ \mathbf{elif}\;x.im \leq 5 \cdot 10^{+65}:\\ \;\;\;\;t_2 \cdot \cos t_0\\ \mathbf{else}:\\ \;\;\;\;t_2 \cdot {\left(\sqrt[3]{\cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, t_3\right)\right)}\right)}^{3}\\ \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 (log (hypot x.re x.im)))
        (t_2 (exp (- (* t_1 y.re) (* (atan2 x.im x.re) y.im))))
        (t_3 (* y.im (log x.im))))
   (if (<= x.im 5.4e-302)
     (* t_2 (sqrt (pow (cos (fma t_1 y.im t_0)) 2.0)))
     (if (<= x.im 2.0)
       (* t_2 (cos t_3))
       (if (<= x.im 5e+65)
         (* t_2 (cos t_0))
         (* t_2 (pow (cbrt (cos (fma y.re (atan2 x.im x.re) t_3))) 3.0)))))))
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 = log(hypot(x_46_re, x_46_im));
	double t_2 = exp(((t_1 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im)));
	double t_3 = y_46_im * log(x_46_im);
	double tmp;
	if (x_46_im <= 5.4e-302) {
		tmp = t_2 * sqrt(pow(cos(fma(t_1, y_46_im, t_0)), 2.0));
	} else if (x_46_im <= 2.0) {
		tmp = t_2 * cos(t_3);
	} else if (x_46_im <= 5e+65) {
		tmp = t_2 * cos(t_0);
	} else {
		tmp = t_2 * pow(cbrt(cos(fma(y_46_re, atan2(x_46_im, x_46_re), t_3))), 3.0);
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re))))
end
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(y_46_re * atan(x_46_im, x_46_re))
	t_1 = log(hypot(x_46_re, x_46_im))
	t_2 = exp(Float64(Float64(t_1 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im)))
	t_3 = Float64(y_46_im * log(x_46_im))
	tmp = 0.0
	if (x_46_im <= 5.4e-302)
		tmp = Float64(t_2 * sqrt((cos(fma(t_1, y_46_im, t_0)) ^ 2.0)));
	elseif (x_46_im <= 2.0)
		tmp = Float64(t_2 * cos(t_3));
	elseif (x_46_im <= 5e+65)
		tmp = Float64(t_2 * cos(t_0));
	else
		tmp = Float64(t_2 * (cbrt(cos(fma(y_46_re, atan(x_46_im, x_46_re), t_3))) ^ 3.0));
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(t$95$1 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(y$46$im * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, 5.4e-302], N[(t$95$2 * N[Sqrt[N[Power[N[Cos[N[(t$95$1 * y$46$im + t$95$0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 2.0], N[(t$95$2 * N[Cos[t$95$3], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 5e+65], N[(t$95$2 * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], N[(t$95$2 * N[Power[N[Power[N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]]]]]]]]
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 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_2 := e^{t_1 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\
t_3 := y.im \cdot \log x.im\\
\mathbf{if}\;x.im \leq 5.4 \cdot 10^{-302}:\\
\;\;\;\;t_2 \cdot \sqrt{{\cos \left(\mathsf{fma}\left(t_1, y.im, t_0\right)\right)}^{2}}\\

\mathbf{elif}\;x.im \leq 2:\\
\;\;\;\;t_2 \cdot \cos t_3\\

\mathbf{elif}\;x.im \leq 5 \cdot 10^{+65}:\\
\;\;\;\;t_2 \cdot \cos t_0\\

\mathbf{else}:\\
\;\;\;\;t_2 \cdot {\left(\sqrt[3]{\cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, t_3\right)\right)}\right)}^{3}\\


\end{array}

Local Percentage Accuracy?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Derivation?

  1. Split input into 4 regimes
  2. if x.im < 5.40000000000000011e-302

    1. Initial program 45.4%

      \[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. Simplified81.5%

      \[\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 \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)} \]
      Step-by-step derivation

      [Start]45.4

      \[ 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) \]
    3. Applied egg-rr86.7%

      \[\leadsto 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 \color{blue}{\sqrt{{\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)}^{2}}} \]
      Step-by-step derivation

      [Start]81.5

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

      add-sqr-sqrt [=>]57.3

      \[ 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 \color{blue}{\left(\sqrt{\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 \sqrt{\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)} \]

      sqrt-unprod [=>]86.7

      \[ 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 \color{blue}{\sqrt{\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 \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)}} \]

      pow2 [=>]86.7

      \[ 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 \sqrt{\color{blue}{{\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)}^{2}}} \]

    if 5.40000000000000011e-302 < x.im < 2

    1. Initial program 50.9%

      \[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. Simplified78.4%

      \[\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 \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)} \]
      Step-by-step derivation

      [Start]50.9

      \[ 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) \]
    3. Taylor expanded in x.re around 0 80.1%

      \[\leadsto 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 \color{blue}{\cos \left(\log x.im \cdot y.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)} \]
    4. Taylor expanded in y.re around 0 86.9%

      \[\leadsto 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 \color{blue}{\cos \left(y.im \cdot \log x.im\right)} \]

    if 2 < x.im < 4.99999999999999973e65

    1. Initial program 41.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. Simplified66.7%

      \[\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 \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)} \]
      Step-by-step derivation

      [Start]41.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) \]
    3. Taylor expanded in y.im around 0 91.7%

      \[\leadsto 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 \color{blue}{\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)} \]

    if 4.99999999999999973e65 < x.im

    1. Initial program 23.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. Simplified90.4%

      \[\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 \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)} \]
      Step-by-step derivation

      [Start]23.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) \]
    3. Taylor expanded in x.re around 0 92.3%

      \[\leadsto 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 \color{blue}{\cos \left(\log x.im \cdot y.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)} \]
    4. Applied egg-rr92.3%

      \[\leadsto 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 \color{blue}{{\left(\sqrt[3]{\cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, \log x.im \cdot y.im\right)\right)}\right)}^{3}} \]
      Step-by-step derivation

      [Start]92.3

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

      add-cube-cbrt [=>]92.3

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

      pow3 [=>]92.3

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

      +-commutative [=>]92.3

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

      fma-def [=>]92.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq 5.4 \cdot 10^{-302}:\\ \;\;\;\;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 \sqrt{{\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)}^{2}}\\ \mathbf{elif}\;x.im \leq 2:\\ \;\;\;\;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 \cos \left(y.im \cdot \log x.im\right)\\ \mathbf{elif}\;x.im \leq 5 \cdot 10^{+65}:\\ \;\;\;\;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 \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{else}:\\ \;\;\;\;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(\sqrt[3]{\cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log x.im\right)\right)}\right)}^{3}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy81.3%
Cost65484
\[\begin{array}{l} t_0 := 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}\\ t_1 := y.im \cdot \log x.im\\ \mathbf{if}\;x.im \leq -5 \cdot 10^{-310}:\\ \;\;\;\;t_0 \cdot \sqrt{{\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)}^{2}}\\ \mathbf{elif}\;x.im \leq 82:\\ \;\;\;\;t_0 \cdot \cos t_1\\ \mathbf{elif}\;x.im \leq 10^{+60}:\\ \;\;\;\;t_0 \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot {\left(\sqrt[3]{\cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, t_1\right)\right)}\right)}^{3}\\ \end{array} \]
Alternative 2
Accuracy81.3%
Cost58692
\[\begin{array}{l} t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ t_1 := 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}\\ t_2 := y.im \cdot \log x.im\\ \mathbf{if}\;x.im \leq -5 \cdot 10^{-310}:\\ \;\;\;\;t_1 \cdot \sqrt{{\cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)}^{2}}\\ \mathbf{elif}\;x.im \leq 1000:\\ \;\;\;\;t_1 \cdot \cos t_2\\ \mathbf{elif}\;x.im \leq 2.8 \cdot 10^{+63}:\\ \;\;\;\;t_1 \cdot \cos t_0\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \cos \left(t_0 + t_2\right)\\ \end{array} \]
Alternative 3
Accuracy81.3%
Cost46348
\[\begin{array}{l} t_0 := y.im \cdot \log x.im\\ t_1 := 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}\\ t_2 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ \mathbf{if}\;x.im \leq 6 \cdot 10^{-309}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x.im \leq 20:\\ \;\;\;\;t_1 \cdot \cos t_0\\ \mathbf{elif}\;x.im \leq 6 \cdot 10^{+61}:\\ \;\;\;\;t_1 \cdot \cos t_2\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \cos \left(t_2 + t_0\right)\\ \end{array} \]
Alternative 4
Accuracy81.3%
Cost39560
\[\begin{array}{l} t_0 := 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}\\ \mathbf{if}\;x.im \leq 10^{-308}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x.im \leq 2:\\ \;\;\;\;t_0 \cdot \cos \left(y.im \cdot \log x.im\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \end{array} \]
Alternative 5
Accuracy81.3%
Cost39496
\[\begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_1 := e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - t_0}\\ \mathbf{if}\;x.im \leq -5 \cdot 10^{-310}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x.im \leq 1600:\\ \;\;\;\;t_1 \cdot \cos \left(y.im \cdot \log x.im\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.im - t_0}\\ \end{array} \]
Alternative 6
Accuracy81.0%
Cost32964
\[\begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ \mathbf{if}\;x.im \leq 2:\\ \;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - t_0}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.im - t_0}\\ \end{array} \]
Alternative 7
Accuracy75.4%
Cost26376
\[\begin{array}{l} \mathbf{if}\;y.re \leq -3.3 \cdot 10^{-10}:\\ \;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\ \mathbf{elif}\;y.re \leq 1.62 \cdot 10^{-9}:\\ \;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\\ \end{array} \]
Alternative 8
Accuracy81.6%
Cost26176
\[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} \]
Alternative 9
Accuracy77.0%
Cost13385
\[\begin{array}{l} \mathbf{if}\;y.re \leq -9 \cdot 10^{-10} \lor \neg \left(y.re \leq 6.8 \cdot 10^{-11}\right):\\ \;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\ \mathbf{else}:\\ \;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\ \end{array} \]
Alternative 10
Accuracy52.4%
Cost13120
\[e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)} \]
Alternative 11
Accuracy26.3%
Cost6784
\[1 - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im \]
Alternative 12
Accuracy26.2%
Cost64
\[1 \]

Error

Reproduce?

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