Average Error: 33.0 → 3.4
Time: 22.3s
Precision: binary64
Cost: 123080
\[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 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := {e}^{\left(t_0 \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\ t_2 := \sqrt[3]{e^{e^{\tan^{-1}_* \frac{x.im}{x.re}}}}\\ \mathbf{if}\;y.im \leq -10000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.im \leq 100000:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(\log \left({t_2}^{2}\right) + \log t_2\right)}^{y.im}} \cdot \cos \left(\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (log (hypot x.re x.im)))
        (t_1 (pow E (- (* t_0 y.re) (* y.im (atan2 x.im x.re)))))
        (t_2 (cbrt (exp (exp (atan2 x.im x.re))))))
   (if (<= y.im -10000000000.0)
     t_1
     (if (<= y.im 100000.0)
       (*
        (/
         (pow (hypot x.re x.im) y.re)
         (pow (+ (log (pow t_2 2.0)) (log t_2)) y.im))
        (cos (fma t_0 y.im (* y.re (atan2 x.im x.re)))))
       t_1))))
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 = log(hypot(x_46_re, x_46_im));
	double t_1 = pow(((double) M_E), ((t_0 * y_46_re) - (y_46_im * atan2(x_46_im, x_46_re))));
	double t_2 = cbrt(exp(exp(atan2(x_46_im, x_46_re))));
	double tmp;
	if (y_46_im <= -10000000000.0) {
		tmp = t_1;
	} else if (y_46_im <= 100000.0) {
		tmp = (pow(hypot(x_46_re, x_46_im), y_46_re) / pow((log(pow(t_2, 2.0)) + log(t_2)), y_46_im)) * cos(fma(t_0, y_46_im, (y_46_re * atan2(x_46_im, x_46_re))));
	} else {
		tmp = t_1;
	}
	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 = log(hypot(x_46_re, x_46_im))
	t_1 = exp(1) ^ Float64(Float64(t_0 * y_46_re) - Float64(y_46_im * atan(x_46_im, x_46_re)))
	t_2 = cbrt(exp(exp(atan(x_46_im, x_46_re))))
	tmp = 0.0
	if (y_46_im <= -10000000000.0)
		tmp = t_1;
	elseif (y_46_im <= 100000.0)
		tmp = Float64(Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / (Float64(log((t_2 ^ 2.0)) + log(t_2)) ^ y_46_im)) * cos(fma(t_0, y_46_im, Float64(y_46_re * atan(x_46_im, x_46_re)))));
	else
		tmp = t_1;
	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[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[E, N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Exp[N[Exp[N[ArcTan[x$46$im / x$46$re], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[y$46$im, -10000000000.0], t$95$1, If[LessEqual[y$46$im, 100000.0], N[(N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[Power[N[(N[Log[N[Power[t$95$2, 2.0], $MachinePrecision]], $MachinePrecision] + N[Log[t$95$2], $MachinePrecision]), $MachinePrecision], y$46$im], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(t$95$0 * y$46$im + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$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)
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := {e}^{\left(t_0 \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\
t_2 := \sqrt[3]{e^{e^{\tan^{-1}_* \frac{x.im}{x.re}}}}\\
\mathbf{if}\;y.im \leq -10000000000:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y.im \leq 100000:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\left(\log \left({t_2}^{2}\right) + \log t_2\right)}^{y.im}} \cdot \cos \left(\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Derivation

  1. Split input into 2 regimes
  2. if y.im < -1e10 or 1e5 < y.im

    1. Initial program 35.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 in y.im around 0 17.4

      \[\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}{\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)} \]
    3. Taylor expanded in y.re around 0 17.4

      \[\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} \]
    4. Applied egg-rr7.8

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

    if -1e10 < y.im < 1e5

    1. Initial program 31.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(\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. Simplified0.3

      \[\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. Applied egg-rr0.3

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

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

Alternatives

Alternative 1
Error3.4
Cost78024
\[\begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := {e}^{\left(t_0 \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\ \mathbf{if}\;y.im \leq -10000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.im \leq 100000:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{{\log \left(e^{e^{\tan^{-1}_* \frac{x.im}{x.re}}}\right)}^{y.im}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error3.4
Cost71816
\[\begin{array}{l} t_0 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ t_1 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_2 := {e}^{\left(t_1 \cdot y.re - t_0\right)}\\ \mathbf{if}\;y.im \leq -10000000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y.im \leq 100000:\\ \;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{e^{t_0}} \cdot \log \left(1 + \mathsf{expm1}\left(\cos \left(\mathsf{fma}\left(t_1, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error3.4
Cost71752
\[\begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := {e}^{\left(t_0 \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\ \mathbf{if}\;y.im \leq -10000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.im \leq 100000:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\sqrt[3]{{\left(e^{\tan^{-1}_* \frac{x.im}{x.re}}\right)}^{\left(y.im \cdot 3\right)}}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error3.4
Cost65224
\[\begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := {e}^{\left(t_0 \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\ \mathbf{if}\;y.im \leq -10000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.im \leq 100000:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \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}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error3.4
Cost58888
\[\begin{array}{l} t_0 := y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ t_1 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_2 := {e}^{\left(t_1 \cdot y.re - t_0\right)}\\ \mathbf{if}\;y.im \leq -10000000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y.im \leq 100000:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(t_1, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{e^{t_0}}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error3.6
Cost52232
\[\begin{array}{l} t_0 := {e}^{\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\ \mathbf{if}\;y.im \leq -10000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.im \leq 100000:\\ \;\;\;\;\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(y.im \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error4.2
Cost39168
\[{e}^{\left(3 \cdot \left(0.3333333333333333 \cdot \mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, y.im \cdot \left(-\tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right)\right)} \]
Alternative 8
Error4.2
Cost32576
\[{e}^{\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)} \]
Alternative 9
Error6.1
Cost26760
\[\begin{array}{l} t_0 := e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{if}\;y.re \leq -8.028392562145345 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 1.02 \cdot 10^{+21}:\\ \;\;\;\;e^{y.im \cdot \left(-\tan^{-1}_* \frac{x.im}{x.re}\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error8.1
Cost26440
\[\begin{array}{l} \mathbf{if}\;y.re \leq -1.25 \cdot 10^{-8}:\\ \;\;\;\;{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\ \mathbf{elif}\;y.re \leq 1.2 \cdot 10^{+100}:\\ \;\;\;\;e^{y.im \cdot \left(-\tan^{-1}_* \frac{x.im}{x.re}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(e^{\tan^{-1}_* \frac{x.im}{x.re}}\right)}^{\left(-y.im\right)}}{{\left(\frac{-1}{x.im}\right)}^{y.re}}\\ \end{array} \]
Alternative 11
Error7.2
Cost20104
\[\begin{array}{l} t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\ \mathbf{if}\;y.re \leq -1.25 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 1.02 \cdot 10^{+21}:\\ \;\;\;\;e^{y.im \cdot \left(-\tan^{-1}_* \frac{x.im}{x.re}\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(1 - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \end{array} \]
Alternative 12
Error7.2
Cost13384
\[\begin{array}{l} t_0 := {\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re}\\ \mathbf{if}\;y.re \leq -1.25 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 1.02 \cdot 10^{+21}:\\ \;\;\;\;e^{y.im \cdot \left(-\tan^{-1}_* \frac{x.im}{x.re}\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 13
Error17.1
Cost12992
\[{\left(\mathsf{hypot}\left(x.im, x.re\right)\right)}^{y.re} \]
Alternative 14
Error38.9
Cost6912
\[\frac{1}{1 + y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]

Error

Reproduce

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