powComplex, real part

?

Percentage Accurate: 39.5% → 80.6%
Time: 24.0s
Precision: binary64
Cost: 157508

?

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

\mathbf{else}:\\
\;\;\;\;e^{y.re \cdot t_4 - t_2} \cdot \cos \left(\mathsf{fma}\left(t_4, y.im, t_0\right)\right)\\


\end{array}

Local Percentage Accuracy vs ?

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.

Herbie found 14 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Bogosity?

Bogosity

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) < +inf.0

    1. Initial program 83.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. Applied egg-rr85.9%

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

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

      add-cube-cbrt [=>]87.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(\color{blue}{\left(\sqrt[3]{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im} \cdot \sqrt[3]{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im}\right) \cdot \sqrt[3]{\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) \]

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

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

      hypot-udef [<=]85.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({\left(\sqrt[3]{y.im \cdot \log \color{blue}{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}}\right)}^{3} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
    3. Applied egg-rr83.1%

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

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

      rem-cbrt-cube [<=]84.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({\color{blue}{\left(\sqrt[3]{{\left(\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}^{3}}\right)}}^{3} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]

      pow1/3 [=>]45.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({\color{blue}{\left({\left({\left(\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}^{3}\right)}^{0.3333333333333333}\right)}}^{3} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]

      cube-mult [=>]45.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({\left({\color{blue}{\left(\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)} \cdot \left(\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)} \cdot \sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)\right)}}^{0.3333333333333333}\right)}^{3} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]

      unpow-prod-down [=>]45.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({\color{blue}{\left({\left(\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}^{0.3333333333333333} \cdot {\left(\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)} \cdot \sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}^{0.3333333333333333}\right)}}^{3} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]

      pow1/3 [<=]83.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({\left(\color{blue}{\sqrt[3]{\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}}} \cdot {\left(\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)} \cdot \sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}^{0.3333333333333333}\right)}^{3} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]

      pow2 [=>]83.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({\left(\sqrt[3]{\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}} \cdot {\color{blue}{\left({\left(\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}^{2}\right)}}^{0.3333333333333333}\right)}^{3} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
    4. Simplified87.1%

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

      [Start]83.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({\left(\sqrt[3]{\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}} \cdot {\left({\left(\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}^{2}\right)}^{0.3333333333333333}\right)}^{3} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]

      unpow1/3 [=>]87.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({\left(\sqrt[3]{\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}} \cdot \color{blue}{\sqrt[3]{{\left(\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}^{2}}}\right)}^{3} + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]

    if +inf.0 < (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re))))

    1. Initial program 0.0%

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

      \[\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]0.0%

      \[ 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. Recombined 2 regimes into one program.
  4. Final simplification82.9%

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

Alternatives

Alternative 1
Accuracy80.6%
Cost157508
\[\begin{array}{l} t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ t_1 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\ t_2 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_3 := e^{t_1 \cdot y.re - t_2}\\ t_4 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_5 := \sqrt[3]{y.im \cdot t_4}\\ \mathbf{if}\;t_3 \cdot \cos \left(t_1 \cdot y.im + t_0\right) \leq \infty:\\ \;\;\;\;t_3 \cdot \cos \left(t_0 + {\left(\sqrt[3]{t_5} \cdot \sqrt[3]{{t_5}^{2}}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot t_4 - t_2} \cdot \cos \left(\mathsf{fma}\left(t_4, y.im, t_0\right)\right)\\ \end{array} \]
Alternative 2
Accuracy80.3%
Cost118980
\[\begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_1 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_2 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ t_3 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\ t_4 := e^{t_3 \cdot y.re - t_0}\\ \mathbf{if}\;t_4 \cdot \cos \left(t_3 \cdot y.im + t_2\right) \leq \infty:\\ \;\;\;\;t_4 \cdot \left(\cos t_2 - \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right) \cdot \sin t_2\right)\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot t_1 - t_0} \cdot \cos \left(\mathsf{fma}\left(t_1, y.im, t_2\right)\right)\\ \end{array} \]
Alternative 3
Accuracy80.4%
Cost118724
\[\begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_2 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ t_3 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\ t_4 := e^{t_3 \cdot y.re - t_1}\\ \mathbf{if}\;t_4 \cdot \cos \left(t_3 \cdot y.im + t_2\right) \leq \infty:\\ \;\;\;\;t_4 \cdot \cos \left(t_2 + {\left(\sqrt[3]{y.im \cdot t_0}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot t_0 - t_1} \cdot \cos \left(\mathsf{fma}\left(t_0, y.im, t_2\right)\right)\\ \end{array} \]
Alternative 4
Accuracy80.6%
Cost58688
\[\begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ e^{y.re \cdot t_0 - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \end{array} \]
Alternative 5
Accuracy76.6%
Cost46348
\[\begin{array}{l} t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ t_1 := \cos t_0\\ t_2 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ \mathbf{if}\;x.re \leq -5.2 \cdot 10^{-36}:\\ \;\;\;\;e^{y.re \cdot \log \left(-x.re\right) - t_2} \cdot \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\\ \mathbf{elif}\;x.re \leq 2.8 \cdot 10^{-301}:\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t_2} \cdot t_1\\ \mathbf{elif}\;x.re \leq 5.7 \cdot 10^{+214}:\\ \;\;\;\;e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) - t_2} \cdot \cos \left(t_0 + y.im \cdot \log x.re\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot e^{y.re \cdot \log x.re - t_2}\\ \end{array} \]
Alternative 6
Accuracy76.0%
Cost46348
\[\begin{array}{l} t_0 := \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\\ t_1 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ t_2 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ \mathbf{if}\;x.re \leq -2 \cdot 10^{-102}:\\ \;\;\;\;e^{y.re \cdot \log \left(-x.re\right) - t_2} \cdot t_0\\ \mathbf{elif}\;x.re \leq 7.2 \cdot 10^{-216}:\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t_2} \cdot t_0\\ \mathbf{elif}\;x.re \leq 1.22 \cdot 10^{+212}:\\ \;\;\;\;e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) - t_2} \cdot \cos \left(t_1 + y.im \cdot \log x.re\right)\\ \mathbf{else}:\\ \;\;\;\;\cos t_1 \cdot e^{y.re \cdot \log x.re - t_2}\\ \end{array} \]
Alternative 7
Accuracy77.2%
Cost45897
\[\begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ \mathbf{if}\;y.re \leq -7.5 \cdot 10^{-30} \lor \neg \left(y.re \leq 1.7 \cdot 10^{-21}\right):\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t_0} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{else}:\\ \;\;\;\;e^{-t_0} \cdot \cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\right)\right)\\ \end{array} \]
Alternative 8
Accuracy73.1%
Cost40144
\[\begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_1 := \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\\ t_2 := t_1 \cdot e^{y.re \cdot \log \left(-x.im\right) - t_0}\\ t_3 := e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t_0} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{if}\;x.im \leq -1.46 \cdot 10^{+150}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x.im \leq -4.4 \cdot 10^{-82}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x.im \leq -6.8 \cdot 10^{-276}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x.im \leq 3 \cdot 10^{-52}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot e^{y.re \cdot \log x.im - t_0}\\ \end{array} \]
Alternative 9
Accuracy70.7%
Cost39892
\[\begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_1 := e^{y.re \cdot \log x.re - t_0}\\ t_2 := \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ t_3 := \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right) \cdot t_1\\ \mathbf{if}\;x.re \leq -2.35 \cdot 10^{-90}:\\ \;\;\;\;t_2 \cdot e^{y.re \cdot \log \left(-x.re\right) - t_0}\\ \mathbf{elif}\;x.re \leq 3.5 \cdot 10^{-304}:\\ \;\;\;\;t_2 \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\ \mathbf{elif}\;x.re \leq 2.3 \cdot 10^{-124}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x.re \leq 21.5:\\ \;\;\;\;t_2 \cdot {\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}^{y.re}\\ \mathbf{elif}\;x.re \leq 3.3 \cdot 10^{+212}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2 \cdot t_1\\ \end{array} \]
Alternative 10
Accuracy73.3%
Cost39496
\[\begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_1 := \cos \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\\ \mathbf{if}\;x.im \leq -9.5 \cdot 10^{-266}:\\ \;\;\;\;t_1 \cdot e^{y.re \cdot \log \left(-x.im\right) - t_0}\\ \mathbf{elif}\;x.im \leq 8.8 \cdot 10^{-21}:\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot e^{y.re \cdot \log x.im - t_0}\\ \end{array} \]
Alternative 11
Accuracy70.0%
Cost33361
\[\begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_1 := \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{if}\;x.re \leq -2.4 \cdot 10^{-89}:\\ \;\;\;\;t_1 \cdot e^{y.re \cdot \log \left(-x.re\right) - t_0}\\ \mathbf{elif}\;x.re \leq 5.3 \cdot 10^{-303}:\\ \;\;\;\;t_1 \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\ \mathbf{elif}\;x.re \leq 4.9 \cdot 10^{-144} \lor \neg \left(x.re \leq 21.5\right):\\ \;\;\;\;t_1 \cdot e^{y.re \cdot \log x.re - t_0}\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot {\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}^{y.re}\\ \end{array} \]
Alternative 12
Accuracy64.9%
Cost33228
\[\begin{array}{l} t_0 := \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ t_1 := t_0 \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\ \mathbf{if}\;x.im \leq -4.5 \cdot 10^{+190}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x.im \leq -3.8 \cdot 10^{+15}:\\ \;\;\;\;t_0 \cdot {\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}^{y.re}\\ \mathbf{elif}\;x.im \leq 1.05 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot e^{y.re \cdot \log x.im - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \end{array} \]
Alternative 13
Accuracy63.0%
Cost26697
\[\begin{array}{l} t_0 := \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{if}\;y.im \leq -110000 \lor \neg \left(y.im \leq 1.4 \cdot 10^{+103}\right):\\ \;\;\;\;t_0 \cdot {\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}^{y.re}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\ \end{array} \]
Alternative 14
Accuracy60.3%
Cost26112
\[\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \]

Reproduce?

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