Average Error: 33.2 → 4.9
Time: 11.4s
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 := \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\\ t_1 := \mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(0.5, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(y.im \cdot y.im\right), y.im\right), 1\right)\\ t_2 := \left(\frac{1}{t_1} + \frac{y.re \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)}{t_1}\right) \cdot t_0\\ \mathbf{if}\;y.im \leq -1 \cdot 10^{+168}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y.im \leq 10^{+160}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{1 + \mathsf{log1p}\left(\mathsf{expm1}\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \left(y.im \cdot 0.5\right), y.im\right)\right)\right)} \cdot \log \left(e^{t_0}\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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
         (cos (fma (log (hypot x.re x.im)) y.im (* (atan2 x.im x.re) y.re))))
        (t_1
         (fma
          (atan2 x.im x.re)
          (fma 0.5 (* (atan2 x.im x.re) (* y.im y.im)) y.im)
          1.0))
        (t_2 (* (+ (/ 1.0 t_1) (/ (* y.re (log (hypot x.im x.re))) t_1)) t_0)))
   (if (<= y.im -1e+168)
     t_2
     (if (<= y.im 1e+160)
       (*
        (/
         (pow (hypot x.re x.im) y.re)
         (+
          1.0
          (log1p
           (expm1
            (*
             (atan2 x.im x.re)
             (fma (atan2 x.im x.re) (* y.im (* y.im 0.5)) y.im))))))
        (log (exp t_0)))
       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 = cos(fma(log(hypot(x_46_re, x_46_im)), y_46_im, (atan2(x_46_im, x_46_re) * y_46_re)));
	double t_1 = fma(atan2(x_46_im, x_46_re), fma(0.5, (atan2(x_46_im, x_46_re) * (y_46_im * y_46_im)), y_46_im), 1.0);
	double t_2 = ((1.0 / t_1) + ((y_46_re * log(hypot(x_46_im, x_46_re))) / t_1)) * t_0;
	double tmp;
	if (y_46_im <= -1e+168) {
		tmp = t_2;
	} else if (y_46_im <= 1e+160) {
		tmp = (pow(hypot(x_46_re, x_46_im), y_46_re) / (1.0 + log1p(expm1((atan2(x_46_im, x_46_re) * fma(atan2(x_46_im, x_46_re), (y_46_im * (y_46_im * 0.5)), y_46_im)))))) * log(exp(t_0));
	} else {
		tmp = t_2;
	}
	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 = cos(fma(log(hypot(x_46_re, x_46_im)), y_46_im, Float64(atan(x_46_im, x_46_re) * y_46_re)))
	t_1 = fma(atan(x_46_im, x_46_re), fma(0.5, Float64(atan(x_46_im, x_46_re) * Float64(y_46_im * y_46_im)), y_46_im), 1.0)
	t_2 = Float64(Float64(Float64(1.0 / t_1) + Float64(Float64(y_46_re * log(hypot(x_46_im, x_46_re))) / t_1)) * t_0)
	tmp = 0.0
	if (y_46_im <= -1e+168)
		tmp = t_2;
	elseif (y_46_im <= 1e+160)
		tmp = Float64(Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / Float64(1.0 + log1p(expm1(Float64(atan(x_46_im, x_46_re) * fma(atan(x_46_im, x_46_re), Float64(y_46_im * Float64(y_46_im * 0.5)), y_46_im)))))) * log(exp(t_0)));
	else
		tmp = t_2;
	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[Cos[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[(0.5 * N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision] + y$46$im), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(1.0 / t$95$1), $MachinePrecision] + N[(N[(y$46$re * N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[y$46$im, -1e+168], t$95$2, If[LessEqual[y$46$im, 1e+160], N[(N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[(1.0 + N[Log[1 + N[(Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[(y$46$im * N[(y$46$im * 0.5), $MachinePrecision]), $MachinePrecision] + y$46$im), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$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)
\begin{array}{l}
t_0 := \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\\
t_1 := \mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(0.5, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(y.im \cdot y.im\right), y.im\right), 1\right)\\
t_2 := \left(\frac{1}{t_1} + \frac{y.re \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)}{t_1}\right) \cdot t_0\\
\mathbf{if}\;y.im \leq -1 \cdot 10^{+168}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y.im \leq 10^{+160}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{1 + \mathsf{log1p}\left(\mathsf{expm1}\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \left(y.im \cdot 0.5\right), y.im\right)\right)\right)} \cdot \log \left(e^{t_0}\right)\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error

Derivation

  1. Split input into 2 regimes
  2. if y.im < -9.9999999999999993e167 or 1.00000000000000001e160 < y.im

    1. Initial program 34.8

      \[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. Simplified22.7

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{\tan^{-1}_* \frac{x.im}{x.re}}\right)}^{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 21.5

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\color{blue}{1 + \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + 0.5 \cdot \left({y.im}^{2} \cdot {\tan^{-1}_* \frac{x.im}{x.re}}^{2}\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) \]
    4. Simplified18.1

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\color{blue}{1 + \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(y.im + \left(\left(y.im \cdot y.im\right) \cdot 0.5\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}\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) \]
    5. Taylor expanded in y.re around 0 35.6

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

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

    if -9.9999999999999993e167 < y.im < 1.00000000000000001e160

    1. Initial program 32.8

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

      \[\leadsto \color{blue}{\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(e^{\tan^{-1}_* \frac{x.im}{x.re}}\right)}^{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 10.2

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\color{blue}{1 + \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + 0.5 \cdot \left({y.im}^{2} \cdot {\tan^{-1}_* \frac{x.im}{x.re}}^{2}\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) \]
    4. Simplified10.1

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\color{blue}{1 + \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(y.im + \left(\left(y.im \cdot y.im\right) \cdot 0.5\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}\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) \]
    5. Applied egg-rr4.0

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{1 + \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \left(y.im \cdot 0.5\right), y.im\right)\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) \]
    6. Applied egg-rr4.0

      \[\leadsto \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{1 + \mathsf{log1p}\left(\mathsf{expm1}\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \left(y.im \cdot 0.5\right), y.im\right)\right)\right)} \cdot \color{blue}{\log \left(e^{\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)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -1 \cdot 10^{+168}:\\ \;\;\;\;\left(\frac{1}{\mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(0.5, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(y.im \cdot y.im\right), y.im\right), 1\right)} + \frac{y.re \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)}{\mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(0.5, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(y.im \cdot y.im\right), y.im\right), 1\right)}\right) \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\\ \mathbf{elif}\;y.im \leq 10^{+160}:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{1 + \mathsf{log1p}\left(\mathsf{expm1}\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot \left(y.im \cdot 0.5\right), y.im\right)\right)\right)} \cdot \log \left(e^{\cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{\mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(0.5, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(y.im \cdot y.im\right), y.im\right), 1\right)} + \frac{y.re \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)}{\mathsf{fma}\left(\tan^{-1}_* \frac{x.im}{x.re}, \mathsf{fma}\left(0.5, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(y.im \cdot y.im\right), y.im\right), 1\right)}\right) \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\right)\\ \end{array} \]

Reproduce

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