powComplex, real part

Percentage Accurate: 40.7% → 82.1%
Time: 27.5s
Alternatives: 12
Speedup: 3.9×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\ e^{t_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
   (*
    (exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
    (cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
	return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    t_0 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
    code = exp(((t_0 * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((t_0 * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
	return Math.exp(((t_0 * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((t_0 * y_46_im) + (Math.atan2(x_46_im, x_46_re) * y_46_re)));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))
	return math.exp(((t_0 * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((t_0 * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im))))
	return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_0 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re))))
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
	tmp = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(t$95$0 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{t_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

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.

Accuracy vs Speed?

Herbie found 12 alternatives:

AlternativeAccuracySpeedup
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.

Initial Program: 40.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\ e^{t_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
   (*
    (exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
    (cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
	return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    t_0 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
    code = exp(((t_0 * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((t_0 * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
	return Math.exp(((t_0 * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((t_0 * y_46_im) + (Math.atan2(x_46_im, x_46_re) * y_46_re)));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))))
	return math.exp(((t_0 * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((t_0 * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im))))
	return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_0 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re))))
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
	tmp = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(t$95$0 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{t_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
\end{array}

Alternative 1: 82.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := \cos \left(\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\\ t_2 := e^{y.re \cdot t_0 - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{if}\;y.im \leq -5 \cdot 10^{+63}:\\ \;\;\;\;t_2 \cdot t_1\\ \mathbf{else}:\\ \;\;\;\;t_2 \cdot \sqrt{{t_1}^{2}}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (log (hypot x.re x.im)))
        (t_1 (cos (fma t_0 y.im (* y.re (atan2 x.im x.re)))))
        (t_2 (exp (- (* y.re t_0) (* y.im (atan2 x.im x.re))))))
   (if (<= y.im -5e+63) (* t_2 t_1) (* t_2 (sqrt (pow t_1 2.0))))))
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 = cos(fma(t_0, y_46_im, (y_46_re * atan2(x_46_im, x_46_re))));
	double t_2 = exp(((y_46_re * t_0) - (y_46_im * atan2(x_46_im, x_46_re))));
	double tmp;
	if (y_46_im <= -5e+63) {
		tmp = t_2 * t_1;
	} else {
		tmp = t_2 * sqrt(pow(t_1, 2.0));
	}
	return tmp;
}
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 = cos(fma(t_0, y_46_im, Float64(y_46_re * atan(x_46_im, x_46_re))))
	t_2 = exp(Float64(Float64(y_46_re * t_0) - Float64(y_46_im * atan(x_46_im, x_46_re))))
	tmp = 0.0
	if (y_46_im <= -5e+63)
		tmp = Float64(t_2 * t_1);
	else
		tmp = Float64(t_2 * sqrt((t_1 ^ 2.0)));
	end
	return tmp
end
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[Cos[N[(t$95$0 * y$46$im + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(y$46$re * t$95$0), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$im, -5e+63], N[(t$95$2 * t$95$1), $MachinePrecision], N[(t$95$2 * N[Sqrt[N[Power[t$95$1, 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := \cos \left(\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\\
t_2 := e^{y.re \cdot t_0 - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{if}\;y.im \leq -5 \cdot 10^{+63}:\\
\;\;\;\;t_2 \cdot t_1\\

\mathbf{else}:\\
\;\;\;\;t_2 \cdot \sqrt{{t_1}^{2}}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 2: 80.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ \mathbf{if}\;y.re \leq 9.5 \cdot 10^{+134}:\\ \;\;\;\;e^{y.re \cdot t_0 - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (log (hypot x.re x.im))))
   (if (<= y.re 9.5e+134)
     (*
      (exp (- (* y.re t_0) (* y.im (atan2 x.im x.re))))
      (cos (fma t_0 y.im (* y.re (atan2 x.im x.re)))))
     (pow (sqrt (+ (pow x.re 2.0) (pow x.im 2.0))) y.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 tmp;
	if (y_46_re <= 9.5e+134) {
		tmp = exp(((y_46_re * t_0) - (y_46_im * atan2(x_46_im, x_46_re)))) * cos(fma(t_0, y_46_im, (y_46_re * atan2(x_46_im, x_46_re))));
	} else {
		tmp = pow(sqrt((pow(x_46_re, 2.0) + pow(x_46_im, 2.0))), y_46_re);
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = log(hypot(x_46_re, x_46_im))
	tmp = 0.0
	if (y_46_re <= 9.5e+134)
		tmp = Float64(exp(Float64(Float64(y_46_re * t_0) - Float64(y_46_im * atan(x_46_im, x_46_re)))) * cos(fma(t_0, y_46_im, Float64(y_46_re * atan(x_46_im, x_46_re)))));
	else
		tmp = sqrt(Float64((x_46_re ^ 2.0) + (x_46_im ^ 2.0))) ^ y_46_re;
	end
	return tmp
end
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]}, If[LessEqual[y$46$re, 9.5e+134], N[(N[Exp[N[(N[(y$46$re * t$95$0), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $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], N[Power[N[Sqrt[N[(N[Power[x$46$re, 2.0], $MachinePrecision] + N[Power[x$46$im, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
\mathbf{if}\;y.re \leq 9.5 \cdot 10^{+134}:\\
\;\;\;\;e^{y.re \cdot t_0 - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 3: 80.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := e^{y.re \cdot t_0 - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{if}\;y.re \leq -7.5 \cdot 10^{-77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq 5.8 \cdot 10^{-16}:\\ \;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)} \cdot \cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot t_0\right)\right)\\ \mathbf{elif}\;y.re \leq 4.3 \cdot 10^{+135}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (log (hypot x.re x.im)))
        (t_1
         (*
          (exp (- (* y.re t_0) (* y.im (atan2 x.im x.re))))
          (cos (* y.re (atan2 x.im x.re))))))
   (if (<= y.re -7.5e-77)
     t_1
     (if (<= y.re 5.8e-16)
       (*
        (exp (* (atan2 x.im x.re) (- y.im)))
        (cos (fma y.re (atan2 x.im x.re) (* y.im t_0))))
       (if (<= y.re 4.3e+135)
         t_1
         (pow (sqrt (+ (pow x.re 2.0) (pow x.im 2.0))) y.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 = exp(((y_46_re * t_0) - (y_46_im * atan2(x_46_im, x_46_re)))) * cos((y_46_re * atan2(x_46_im, x_46_re)));
	double tmp;
	if (y_46_re <= -7.5e-77) {
		tmp = t_1;
	} else if (y_46_re <= 5.8e-16) {
		tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)) * cos(fma(y_46_re, atan2(x_46_im, x_46_re), (y_46_im * t_0)));
	} else if (y_46_re <= 4.3e+135) {
		tmp = t_1;
	} else {
		tmp = pow(sqrt((pow(x_46_re, 2.0) + pow(x_46_im, 2.0))), y_46_re);
	}
	return tmp;
}
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 = Float64(exp(Float64(Float64(y_46_re * t_0) - Float64(y_46_im * atan(x_46_im, x_46_re)))) * cos(Float64(y_46_re * atan(x_46_im, x_46_re))))
	tmp = 0.0
	if (y_46_re <= -7.5e-77)
		tmp = t_1;
	elseif (y_46_re <= 5.8e-16)
		tmp = Float64(exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))) * cos(fma(y_46_re, atan(x_46_im, x_46_re), Float64(y_46_im * t_0))));
	elseif (y_46_re <= 4.3e+135)
		tmp = t_1;
	else
		tmp = sqrt(Float64((x_46_re ^ 2.0) + (x_46_im ^ 2.0))) ^ y_46_re;
	end
	return tmp
end
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[(N[Exp[N[(N[(y$46$re * t$95$0), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, -7.5e-77], t$95$1, If[LessEqual[y$46$re, 5.8e-16], N[(N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision] + N[(y$46$im * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 4.3e+135], t$95$1, N[Power[N[Sqrt[N[(N[Power[x$46$re, 2.0], $MachinePrecision] + N[Power[x$46$im, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
t_1 := e^{y.re \cdot t_0 - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\mathbf{if}\;y.re \leq -7.5 \cdot 10^{-77}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y.re \leq 5.8 \cdot 10^{-16}:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)} \cdot \cos \left(\mathsf{fma}\left(y.re, \tan^{-1}_* \frac{x.im}{x.re}, y.im \cdot t_0\right)\right)\\

\mathbf{elif}\;y.re \leq 4.3 \cdot 10^{+135}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 4: 80.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\ \mathbf{if}\;x.im \leq -5 \cdot 10^{-309}:\\ \;\;\;\;t_0 \cdot \cos \left(\log \left(\frac{-1}{x.im}\right) \cdot \left(-y.im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im \cdot \log x.im\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0
         (exp
          (- (* y.re (log (hypot x.re x.im))) (* y.im (atan2 x.im x.re))))))
   (if (<= x.im -5e-309)
     (* t_0 (cos (* (log (/ -1.0 x.im)) (- y.im))))
     (* t_0 (cos (+ (* y.re (atan2 x.im x.re)) (* y.im (log x.im))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = exp(((y_46_re * log(hypot(x_46_re, x_46_im))) - (y_46_im * atan2(x_46_im, x_46_re))));
	double tmp;
	if (x_46_im <= -5e-309) {
		tmp = t_0 * cos((log((-1.0 / x_46_im)) * -y_46_im));
	} else {
		tmp = t_0 * cos(((y_46_re * atan2(x_46_im, x_46_re)) + (y_46_im * log(x_46_im))));
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = Math.exp(((y_46_re * Math.log(Math.hypot(x_46_re, x_46_im))) - (y_46_im * Math.atan2(x_46_im, x_46_re))));
	double tmp;
	if (x_46_im <= -5e-309) {
		tmp = t_0 * Math.cos((Math.log((-1.0 / x_46_im)) * -y_46_im));
	} else {
		tmp = t_0 * Math.cos(((y_46_re * Math.atan2(x_46_im, x_46_re)) + (y_46_im * Math.log(x_46_im))));
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = math.exp(((y_46_re * math.log(math.hypot(x_46_re, x_46_im))) - (y_46_im * math.atan2(x_46_im, x_46_re))))
	tmp = 0
	if x_46_im <= -5e-309:
		tmp = t_0 * math.cos((math.log((-1.0 / x_46_im)) * -y_46_im))
	else:
		tmp = t_0 * math.cos(((y_46_re * math.atan2(x_46_im, x_46_re)) + (y_46_im * math.log(x_46_im))))
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = exp(Float64(Float64(y_46_re * log(hypot(x_46_re, x_46_im))) - Float64(y_46_im * atan(x_46_im, x_46_re))))
	tmp = 0.0
	if (x_46_im <= -5e-309)
		tmp = Float64(t_0 * cos(Float64(log(Float64(-1.0 / x_46_im)) * Float64(-y_46_im))));
	else
		tmp = Float64(t_0 * cos(Float64(Float64(y_46_re * atan(x_46_im, x_46_re)) + Float64(y_46_im * log(x_46_im)))));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = exp(((y_46_re * log(hypot(x_46_re, x_46_im))) - (y_46_im * atan2(x_46_im, x_46_re))));
	tmp = 0.0;
	if (x_46_im <= -5e-309)
		tmp = t_0 * cos((log((-1.0 / x_46_im)) * -y_46_im));
	else
		tmp = t_0 * cos(((y_46_re * atan2(x_46_im, x_46_re)) + (y_46_im * log(x_46_im))));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Exp[N[(N[(y$46$re * N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$46$im, -5e-309], N[(t$95$0 * N[Cos[N[(N[Log[N[(-1.0 / x$46$im), $MachinePrecision]], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Cos[N[(N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision] + N[(y$46$im * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\\
\mathbf{if}\;x.im \leq -5 \cdot 10^{-309}:\\
\;\;\;\;t_0 \cdot \cos \left(\log \left(\frac{-1}{x.im}\right) \cdot \left(-y.im\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re} + y.im \cdot \log x.im\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 5: 78.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ t_1 := e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos t_0\\ \mathbf{if}\;y.re \leq 3.2 \cdot 10^{-193}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq 1.6 \cdot 10^{-150}:\\ \;\;\;\;\cos \left(t_0 + y.im \cdot \log x.im\right) \cdot e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\ \mathbf{elif}\;y.re \leq 7 \cdot 10^{+134}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (* y.re (atan2 x.im x.re)))
        (t_1
         (*
          (exp (- (* y.re (log (hypot x.re x.im))) (* y.im (atan2 x.im x.re))))
          (cos t_0))))
   (if (<= y.re 3.2e-193)
     t_1
     (if (<= y.re 1.6e-150)
       (*
        (cos (+ t_0 (* y.im (log x.im))))
        (exp (* (atan2 x.im x.re) (- y.im))))
       (if (<= y.re 7e+134)
         t_1
         (pow (sqrt (+ (pow x.re 2.0) (pow x.im 2.0))) y.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 = exp(((y_46_re * log(hypot(x_46_re, x_46_im))) - (y_46_im * atan2(x_46_im, x_46_re)))) * cos(t_0);
	double tmp;
	if (y_46_re <= 3.2e-193) {
		tmp = t_1;
	} else if (y_46_re <= 1.6e-150) {
		tmp = cos((t_0 + (y_46_im * log(x_46_im)))) * exp((atan2(x_46_im, x_46_re) * -y_46_im));
	} else if (y_46_re <= 7e+134) {
		tmp = t_1;
	} else {
		tmp = pow(sqrt((pow(x_46_re, 2.0) + pow(x_46_im, 2.0))), y_46_re);
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = y_46_re * Math.atan2(x_46_im, x_46_re);
	double t_1 = Math.exp(((y_46_re * Math.log(Math.hypot(x_46_re, x_46_im))) - (y_46_im * Math.atan2(x_46_im, x_46_re)))) * Math.cos(t_0);
	double tmp;
	if (y_46_re <= 3.2e-193) {
		tmp = t_1;
	} else if (y_46_re <= 1.6e-150) {
		tmp = Math.cos((t_0 + (y_46_im * Math.log(x_46_im)))) * Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
	} else if (y_46_re <= 7e+134) {
		tmp = t_1;
	} else {
		tmp = Math.pow(Math.sqrt((Math.pow(x_46_re, 2.0) + Math.pow(x_46_im, 2.0))), y_46_re);
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = y_46_re * math.atan2(x_46_im, x_46_re)
	t_1 = math.exp(((y_46_re * math.log(math.hypot(x_46_re, x_46_im))) - (y_46_im * math.atan2(x_46_im, x_46_re)))) * math.cos(t_0)
	tmp = 0
	if y_46_re <= 3.2e-193:
		tmp = t_1
	elif y_46_re <= 1.6e-150:
		tmp = math.cos((t_0 + (y_46_im * math.log(x_46_im)))) * math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im))
	elif y_46_re <= 7e+134:
		tmp = t_1
	else:
		tmp = math.pow(math.sqrt((math.pow(x_46_re, 2.0) + math.pow(x_46_im, 2.0))), y_46_re)
	return tmp
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 = Float64(exp(Float64(Float64(y_46_re * log(hypot(x_46_re, x_46_im))) - Float64(y_46_im * atan(x_46_im, x_46_re)))) * cos(t_0))
	tmp = 0.0
	if (y_46_re <= 3.2e-193)
		tmp = t_1;
	elseif (y_46_re <= 1.6e-150)
		tmp = Float64(cos(Float64(t_0 + Float64(y_46_im * log(x_46_im)))) * exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))));
	elseif (y_46_re <= 7e+134)
		tmp = t_1;
	else
		tmp = sqrt(Float64((x_46_re ^ 2.0) + (x_46_im ^ 2.0))) ^ y_46_re;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = y_46_re * atan2(x_46_im, x_46_re);
	t_1 = exp(((y_46_re * log(hypot(x_46_re, x_46_im))) - (y_46_im * atan2(x_46_im, x_46_re)))) * cos(t_0);
	tmp = 0.0;
	if (y_46_re <= 3.2e-193)
		tmp = t_1;
	elseif (y_46_re <= 1.6e-150)
		tmp = cos((t_0 + (y_46_im * log(x_46_im)))) * exp((atan2(x_46_im, x_46_re) * -y_46_im));
	elseif (y_46_re <= 7e+134)
		tmp = t_1;
	else
		tmp = sqrt(((x_46_re ^ 2.0) + (x_46_im ^ 2.0))) ^ y_46_re;
	end
	tmp_2 = tmp;
end
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[(N[Exp[N[(N[(y$46$re * N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$46$re, 3.2e-193], t$95$1, If[LessEqual[y$46$re, 1.6e-150], N[(N[Cos[N[(t$95$0 + N[(y$46$im * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 7e+134], t$95$1, N[Power[N[Sqrt[N[(N[Power[x$46$re, 2.0], $MachinePrecision] + N[Power[x$46$im, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := e^{y.re \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \cdot \cos t_0\\
\mathbf{if}\;y.re \leq 3.2 \cdot 10^{-193}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;y.re \leq 7 \cdot 10^{+134}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 6: 58.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ t_1 := \cos t_0\\ \mathbf{if}\;y.re \leq -6.2 \cdot 10^{-5}:\\ \;\;\;\;t_1 \cdot {\log \left(e^{\mathsf{hypot}\left(x.re, x.im\right)}\right)}^{y.re}\\ \mathbf{elif}\;y.re \leq -6.5 \cdot 10^{-251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq 3.7 \cdot 10^{-63}:\\ \;\;\;\;\cos \left(t_0 + y.im \cdot \log x.im\right) \cdot e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (* y.re (atan2 x.im x.re))) (t_1 (cos t_0)))
   (if (<= y.re -6.2e-5)
     (* t_1 (pow (log (exp (hypot x.re x.im))) y.re))
     (if (<= y.re -6.5e-251)
       t_1
       (if (<= y.re 3.7e-63)
         (*
          (cos (+ t_0 (* y.im (log x.im))))
          (exp (* (atan2 x.im x.re) (- y.im))))
         (pow (sqrt (+ (pow x.re 2.0) (pow x.im 2.0))) y.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 = cos(t_0);
	double tmp;
	if (y_46_re <= -6.2e-5) {
		tmp = t_1 * pow(log(exp(hypot(x_46_re, x_46_im))), y_46_re);
	} else if (y_46_re <= -6.5e-251) {
		tmp = t_1;
	} else if (y_46_re <= 3.7e-63) {
		tmp = cos((t_0 + (y_46_im * log(x_46_im)))) * exp((atan2(x_46_im, x_46_re) * -y_46_im));
	} else {
		tmp = pow(sqrt((pow(x_46_re, 2.0) + pow(x_46_im, 2.0))), y_46_re);
	}
	return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = y_46_re * Math.atan2(x_46_im, x_46_re);
	double t_1 = Math.cos(t_0);
	double tmp;
	if (y_46_re <= -6.2e-5) {
		tmp = t_1 * Math.pow(Math.log(Math.exp(Math.hypot(x_46_re, x_46_im))), y_46_re);
	} else if (y_46_re <= -6.5e-251) {
		tmp = t_1;
	} else if (y_46_re <= 3.7e-63) {
		tmp = Math.cos((t_0 + (y_46_im * Math.log(x_46_im)))) * Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
	} else {
		tmp = Math.pow(Math.sqrt((Math.pow(x_46_re, 2.0) + Math.pow(x_46_im, 2.0))), y_46_re);
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = y_46_re * math.atan2(x_46_im, x_46_re)
	t_1 = math.cos(t_0)
	tmp = 0
	if y_46_re <= -6.2e-5:
		tmp = t_1 * math.pow(math.log(math.exp(math.hypot(x_46_re, x_46_im))), y_46_re)
	elif y_46_re <= -6.5e-251:
		tmp = t_1
	elif y_46_re <= 3.7e-63:
		tmp = math.cos((t_0 + (y_46_im * math.log(x_46_im)))) * math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im))
	else:
		tmp = math.pow(math.sqrt((math.pow(x_46_re, 2.0) + math.pow(x_46_im, 2.0))), y_46_re)
	return tmp
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 = cos(t_0)
	tmp = 0.0
	if (y_46_re <= -6.2e-5)
		tmp = Float64(t_1 * (log(exp(hypot(x_46_re, x_46_im))) ^ y_46_re));
	elseif (y_46_re <= -6.5e-251)
		tmp = t_1;
	elseif (y_46_re <= 3.7e-63)
		tmp = Float64(cos(Float64(t_0 + Float64(y_46_im * log(x_46_im)))) * exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))));
	else
		tmp = sqrt(Float64((x_46_re ^ 2.0) + (x_46_im ^ 2.0))) ^ y_46_re;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = y_46_re * atan2(x_46_im, x_46_re);
	t_1 = cos(t_0);
	tmp = 0.0;
	if (y_46_re <= -6.2e-5)
		tmp = t_1 * (log(exp(hypot(x_46_re, x_46_im))) ^ y_46_re);
	elseif (y_46_re <= -6.5e-251)
		tmp = t_1;
	elseif (y_46_re <= 3.7e-63)
		tmp = cos((t_0 + (y_46_im * log(x_46_im)))) * exp((atan2(x_46_im, x_46_re) * -y_46_im));
	else
		tmp = sqrt(((x_46_re ^ 2.0) + (x_46_im ^ 2.0))) ^ y_46_re;
	end
	tmp_2 = tmp;
end
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[Cos[t$95$0], $MachinePrecision]}, If[LessEqual[y$46$re, -6.2e-5], N[(t$95$1 * N[Power[N[Log[N[Exp[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, -6.5e-251], t$95$1, If[LessEqual[y$46$re, 3.7e-63], N[(N[Cos[N[(t$95$0 + N[(y$46$im * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[Sqrt[N[(N[Power[x$46$re, 2.0], $MachinePrecision] + N[Power[x$46$im, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := \cos t_0\\
\mathbf{if}\;y.re \leq -6.2 \cdot 10^{-5}:\\
\;\;\;\;t_1 \cdot {\log \left(e^{\mathsf{hypot}\left(x.re, x.im\right)}\right)}^{y.re}\\

\mathbf{elif}\;y.re \leq -6.5 \cdot 10^{-251}:\\
\;\;\;\;t_1\\

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

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 7: 59.1% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ t_1 := {\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}\\ \mathbf{if}\;y.re \leq -5.5 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq -3.3 \cdot 10^{-251}:\\ \;\;\;\;\cos t_0\\ \mathbf{elif}\;y.re \leq 2.7 \cdot 10^{-63}:\\ \;\;\;\;\cos \left(t_0 + y.im \cdot \log x.im\right) \cdot e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (* y.re (atan2 x.im x.re)))
        (t_1 (pow (sqrt (+ (pow x.re 2.0) (pow x.im 2.0))) y.re)))
   (if (<= y.re -5.5e-11)
     t_1
     (if (<= y.re -3.3e-251)
       (cos t_0)
       (if (<= y.re 2.7e-63)
         (*
          (cos (+ t_0 (* y.im (log x.im))))
          (exp (* (atan2 x.im x.re) (- y.im))))
         t_1)))))
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 = pow(sqrt((pow(x_46_re, 2.0) + pow(x_46_im, 2.0))), y_46_re);
	double tmp;
	if (y_46_re <= -5.5e-11) {
		tmp = t_1;
	} else if (y_46_re <= -3.3e-251) {
		tmp = cos(t_0);
	} else if (y_46_re <= 2.7e-63) {
		tmp = cos((t_0 + (y_46_im * log(x_46_im)))) * exp((atan2(x_46_im, x_46_re) * -y_46_im));
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y_46re * atan2(x_46im, x_46re)
    t_1 = sqrt(((x_46re ** 2.0d0) + (x_46im ** 2.0d0))) ** y_46re
    if (y_46re <= (-5.5d-11)) then
        tmp = t_1
    else if (y_46re <= (-3.3d-251)) then
        tmp = cos(t_0)
    else if (y_46re <= 2.7d-63) then
        tmp = cos((t_0 + (y_46im * log(x_46im)))) * exp((atan2(x_46im, x_46re) * -y_46im))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = y_46_re * Math.atan2(x_46_im, x_46_re);
	double t_1 = Math.pow(Math.sqrt((Math.pow(x_46_re, 2.0) + Math.pow(x_46_im, 2.0))), y_46_re);
	double tmp;
	if (y_46_re <= -5.5e-11) {
		tmp = t_1;
	} else if (y_46_re <= -3.3e-251) {
		tmp = Math.cos(t_0);
	} else if (y_46_re <= 2.7e-63) {
		tmp = Math.cos((t_0 + (y_46_im * Math.log(x_46_im)))) * Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = y_46_re * math.atan2(x_46_im, x_46_re)
	t_1 = math.pow(math.sqrt((math.pow(x_46_re, 2.0) + math.pow(x_46_im, 2.0))), y_46_re)
	tmp = 0
	if y_46_re <= -5.5e-11:
		tmp = t_1
	elif y_46_re <= -3.3e-251:
		tmp = math.cos(t_0)
	elif y_46_re <= 2.7e-63:
		tmp = math.cos((t_0 + (y_46_im * math.log(x_46_im)))) * math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im))
	else:
		tmp = t_1
	return tmp
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 = sqrt(Float64((x_46_re ^ 2.0) + (x_46_im ^ 2.0))) ^ y_46_re
	tmp = 0.0
	if (y_46_re <= -5.5e-11)
		tmp = t_1;
	elseif (y_46_re <= -3.3e-251)
		tmp = cos(t_0);
	elseif (y_46_re <= 2.7e-63)
		tmp = Float64(cos(Float64(t_0 + Float64(y_46_im * log(x_46_im)))) * exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = y_46_re * atan2(x_46_im, x_46_re);
	t_1 = sqrt(((x_46_re ^ 2.0) + (x_46_im ^ 2.0))) ^ y_46_re;
	tmp = 0.0;
	if (y_46_re <= -5.5e-11)
		tmp = t_1;
	elseif (y_46_re <= -3.3e-251)
		tmp = cos(t_0);
	elseif (y_46_re <= 2.7e-63)
		tmp = cos((t_0 + (y_46_im * log(x_46_im)))) * exp((atan2(x_46_im, x_46_re) * -y_46_im));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
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[Power[N[Sqrt[N[(N[Power[x$46$re, 2.0], $MachinePrecision] + N[Power[x$46$im, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision]}, If[LessEqual[y$46$re, -5.5e-11], t$95$1, If[LessEqual[y$46$re, -3.3e-251], N[Cos[t$95$0], $MachinePrecision], If[LessEqual[y$46$re, 2.7e-63], N[(N[Cos[N[(t$95$0 + N[(y$46$im * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := {\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -5.5 \cdot 10^{-11}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y.re \leq -3.3 \cdot 10^{-251}:\\
\;\;\;\;\cos t_0\\

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

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


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 8: 61.1% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -9.2 \cdot 10^{-11} \lor \neg \left(y.re \leq -1.6 \cdot 10^{-244}\right) \land \left(y.re \leq -5 \cdot 10^{-307} \lor \neg \left(y.re \leq 1.96 \cdot 10^{-10}\right)\right):\\ \;\;\;\;{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (or (<= y.re -9.2e-11)
         (and (not (<= y.re -1.6e-244))
              (or (<= y.re -5e-307) (not (<= y.re 1.96e-10)))))
   (pow (sqrt (+ (pow x.re 2.0) (pow x.im 2.0))) y.re)
   (cos (* y.re (atan2 x.im x.re)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_re <= -9.2e-11) || (!(y_46_re <= -1.6e-244) && ((y_46_re <= -5e-307) || !(y_46_re <= 1.96e-10)))) {
		tmp = pow(sqrt((pow(x_46_re, 2.0) + pow(x_46_im, 2.0))), y_46_re);
	} else {
		tmp = cos((y_46_re * atan2(x_46_im, x_46_re)));
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: tmp
    if ((y_46re <= (-9.2d-11)) .or. (.not. (y_46re <= (-1.6d-244))) .and. (y_46re <= (-5d-307)) .or. (.not. (y_46re <= 1.96d-10))) then
        tmp = sqrt(((x_46re ** 2.0d0) + (x_46im ** 2.0d0))) ** y_46re
    else
        tmp = cos((y_46re * atan2(x_46im, x_46re)))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_re <= -9.2e-11) || (!(y_46_re <= -1.6e-244) && ((y_46_re <= -5e-307) || !(y_46_re <= 1.96e-10)))) {
		tmp = Math.pow(Math.sqrt((Math.pow(x_46_re, 2.0) + Math.pow(x_46_im, 2.0))), y_46_re);
	} else {
		tmp = Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re)));
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if (y_46_re <= -9.2e-11) or (not (y_46_re <= -1.6e-244) and ((y_46_re <= -5e-307) or not (y_46_re <= 1.96e-10))):
		tmp = math.pow(math.sqrt((math.pow(x_46_re, 2.0) + math.pow(x_46_im, 2.0))), y_46_re)
	else:
		tmp = math.cos((y_46_re * math.atan2(x_46_im, x_46_re)))
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if ((y_46_re <= -9.2e-11) || (!(y_46_re <= -1.6e-244) && ((y_46_re <= -5e-307) || !(y_46_re <= 1.96e-10))))
		tmp = sqrt(Float64((x_46_re ^ 2.0) + (x_46_im ^ 2.0))) ^ y_46_re;
	else
		tmp = cos(Float64(y_46_re * atan(x_46_im, x_46_re)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if ((y_46_re <= -9.2e-11) || (~((y_46_re <= -1.6e-244)) && ((y_46_re <= -5e-307) || ~((y_46_re <= 1.96e-10)))))
		tmp = sqrt(((x_46_re ^ 2.0) + (x_46_im ^ 2.0))) ^ y_46_re;
	else
		tmp = cos((y_46_re * atan2(x_46_im, x_46_re)));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -9.2e-11], And[N[Not[LessEqual[y$46$re, -1.6e-244]], $MachinePrecision], Or[LessEqual[y$46$re, -5e-307], N[Not[LessEqual[y$46$re, 1.96e-10]], $MachinePrecision]]]], N[Power[N[Sqrt[N[(N[Power[x$46$re, 2.0], $MachinePrecision] + N[Power[x$46$im, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], y$46$re], $MachinePrecision], N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -9.2 \cdot 10^{-11} \lor \neg \left(y.re \leq -1.6 \cdot 10^{-244}\right) \land \left(y.re \leq -5 \cdot 10^{-307} \lor \neg \left(y.re \leq 1.96 \cdot 10^{-10}\right)\right):\\
\;\;\;\;{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re}\\

\mathbf{else}:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 9: 57.6% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ t_1 := {\left(x.re + 0.5 \cdot \frac{{x.im}^{2}}{x.re}\right)}^{y.re}\\ \mathbf{if}\;y.re \leq -1.1 \cdot 10^{-9}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq 8.2 \cdot 10^{-19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 5 \cdot 10^{+103}:\\ \;\;\;\;t_0 \cdot {x.im}^{y.re}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (cos (* y.re (atan2 x.im x.re))))
        (t_1 (pow (+ x.re (* 0.5 (/ (pow x.im 2.0) x.re))) y.re)))
   (if (<= y.re -1.1e-9)
     t_1
     (if (<= y.re 8.2e-19)
       t_0
       (if (<= y.re 5e+103) (* t_0 (pow x.im y.re)) t_1)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = cos((y_46_re * atan2(x_46_im, x_46_re)));
	double t_1 = pow((x_46_re + (0.5 * (pow(x_46_im, 2.0) / x_46_re))), y_46_re);
	double tmp;
	if (y_46_re <= -1.1e-9) {
		tmp = t_1;
	} else if (y_46_re <= 8.2e-19) {
		tmp = t_0;
	} else if (y_46_re <= 5e+103) {
		tmp = t_0 * pow(x_46_im, y_46_re);
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = cos((y_46re * atan2(x_46im, x_46re)))
    t_1 = (x_46re + (0.5d0 * ((x_46im ** 2.0d0) / x_46re))) ** y_46re
    if (y_46re <= (-1.1d-9)) then
        tmp = t_1
    else if (y_46re <= 8.2d-19) then
        tmp = t_0
    else if (y_46re <= 5d+103) then
        tmp = t_0 * (x_46im ** y_46re)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re)));
	double t_1 = Math.pow((x_46_re + (0.5 * (Math.pow(x_46_im, 2.0) / x_46_re))), y_46_re);
	double tmp;
	if (y_46_re <= -1.1e-9) {
		tmp = t_1;
	} else if (y_46_re <= 8.2e-19) {
		tmp = t_0;
	} else if (y_46_re <= 5e+103) {
		tmp = t_0 * Math.pow(x_46_im, y_46_re);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = math.cos((y_46_re * math.atan2(x_46_im, x_46_re)))
	t_1 = math.pow((x_46_re + (0.5 * (math.pow(x_46_im, 2.0) / x_46_re))), y_46_re)
	tmp = 0
	if y_46_re <= -1.1e-9:
		tmp = t_1
	elif y_46_re <= 8.2e-19:
		tmp = t_0
	elif y_46_re <= 5e+103:
		tmp = t_0 * math.pow(x_46_im, y_46_re)
	else:
		tmp = t_1
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = cos(Float64(y_46_re * atan(x_46_im, x_46_re)))
	t_1 = Float64(x_46_re + Float64(0.5 * Float64((x_46_im ^ 2.0) / x_46_re))) ^ y_46_re
	tmp = 0.0
	if (y_46_re <= -1.1e-9)
		tmp = t_1;
	elseif (y_46_re <= 8.2e-19)
		tmp = t_0;
	elseif (y_46_re <= 5e+103)
		tmp = Float64(t_0 * (x_46_im ^ y_46_re));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = cos((y_46_re * atan2(x_46_im, x_46_re)));
	t_1 = (x_46_re + (0.5 * ((x_46_im ^ 2.0) / x_46_re))) ^ y_46_re;
	tmp = 0.0;
	if (y_46_re <= -1.1e-9)
		tmp = t_1;
	elseif (y_46_re <= 8.2e-19)
		tmp = t_0;
	elseif (y_46_re <= 5e+103)
		tmp = t_0 * (x_46_im ^ y_46_re);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(x$46$re + N[(0.5 * N[(N[Power[x$46$im, 2.0], $MachinePrecision] / x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], y$46$re], $MachinePrecision]}, If[LessEqual[y$46$re, -1.1e-9], t$95$1, If[LessEqual[y$46$re, 8.2e-19], t$95$0, If[LessEqual[y$46$re, 5e+103], N[(t$95$0 * N[Power[x$46$im, y$46$re], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
t_1 := {\left(x.re + 0.5 \cdot \frac{{x.im}^{2}}{x.re}\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -1.1 \cdot 10^{-9}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y.re \leq 8.2 \cdot 10^{-19}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y.re \leq 5 \cdot 10^{+103}:\\
\;\;\;\;t_0 \cdot {x.im}^{y.re}\\

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


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 10: 58.4% accurate, 3.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(x.re + 0.5 \cdot \frac{{x.im}^{2}}{x.re}\right)}^{y.re}\\ \mathbf{if}\;y.re \leq -1.96 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 8.2 \cdot 10^{-19}:\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{elif}\;y.re \leq 6.3 \cdot 10^{+103}:\\ \;\;\;\;{x.im}^{y.re}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (pow (+ x.re (* 0.5 (/ (pow x.im 2.0) x.re))) y.re)))
   (if (<= y.re -1.96e-7)
     t_0
     (if (<= y.re 8.2e-19)
       (cos (* y.re (atan2 x.im x.re)))
       (if (<= y.re 6.3e+103) (pow x.im y.re) t_0)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = pow((x_46_re + (0.5 * (pow(x_46_im, 2.0) / x_46_re))), y_46_re);
	double tmp;
	if (y_46_re <= -1.96e-7) {
		tmp = t_0;
	} else if (y_46_re <= 8.2e-19) {
		tmp = cos((y_46_re * atan2(x_46_im, x_46_re)));
	} else if (y_46_re <= 6.3e+103) {
		tmp = pow(x_46_im, y_46_re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x_46re + (0.5d0 * ((x_46im ** 2.0d0) / x_46re))) ** y_46re
    if (y_46re <= (-1.96d-7)) then
        tmp = t_0
    else if (y_46re <= 8.2d-19) then
        tmp = cos((y_46re * atan2(x_46im, x_46re)))
    else if (y_46re <= 6.3d+103) then
        tmp = x_46im ** y_46re
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = Math.pow((x_46_re + (0.5 * (Math.pow(x_46_im, 2.0) / x_46_re))), y_46_re);
	double tmp;
	if (y_46_re <= -1.96e-7) {
		tmp = t_0;
	} else if (y_46_re <= 8.2e-19) {
		tmp = Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re)));
	} else if (y_46_re <= 6.3e+103) {
		tmp = Math.pow(x_46_im, y_46_re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = math.pow((x_46_re + (0.5 * (math.pow(x_46_im, 2.0) / x_46_re))), y_46_re)
	tmp = 0
	if y_46_re <= -1.96e-7:
		tmp = t_0
	elif y_46_re <= 8.2e-19:
		tmp = math.cos((y_46_re * math.atan2(x_46_im, x_46_re)))
	elif y_46_re <= 6.3e+103:
		tmp = math.pow(x_46_im, y_46_re)
	else:
		tmp = t_0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(x_46_re + Float64(0.5 * Float64((x_46_im ^ 2.0) / x_46_re))) ^ y_46_re
	tmp = 0.0
	if (y_46_re <= -1.96e-7)
		tmp = t_0;
	elseif (y_46_re <= 8.2e-19)
		tmp = cos(Float64(y_46_re * atan(x_46_im, x_46_re)));
	elseif (y_46_re <= 6.3e+103)
		tmp = x_46_im ^ y_46_re;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = (x_46_re + (0.5 * ((x_46_im ^ 2.0) / x_46_re))) ^ y_46_re;
	tmp = 0.0;
	if (y_46_re <= -1.96e-7)
		tmp = t_0;
	elseif (y_46_re <= 8.2e-19)
		tmp = cos((y_46_re * atan2(x_46_im, x_46_re)));
	elseif (y_46_re <= 6.3e+103)
		tmp = x_46_im ^ y_46_re;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Power[N[(x$46$re + N[(0.5 * N[(N[Power[x$46$im, 2.0], $MachinePrecision] / x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], y$46$re], $MachinePrecision]}, If[LessEqual[y$46$re, -1.96e-7], t$95$0, If[LessEqual[y$46$re, 8.2e-19], N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[y$46$re, 6.3e+103], N[Power[x$46$im, y$46$re], $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(x.re + 0.5 \cdot \frac{{x.im}^{2}}{x.re}\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -1.96 \cdot 10^{-7}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y.re \leq 8.2 \cdot 10^{-19}:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\

\mathbf{elif}\;y.re \leq 6.3 \cdot 10^{+103}:\\
\;\;\;\;{x.im}^{y.re}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 11: 51.9% accurate, 3.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -0.46 \lor \neg \left(y.re \leq 8.2 \cdot 10^{-19}\right):\\ \;\;\;\;{x.im}^{y.re}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (or (<= y.re -0.46) (not (<= y.re 8.2e-19)))
   (pow x.im y.re)
   (cos (* y.re (atan2 x.im x.re)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_re <= -0.46) || !(y_46_re <= 8.2e-19)) {
		tmp = pow(x_46_im, y_46_re);
	} else {
		tmp = cos((y_46_re * atan2(x_46_im, x_46_re)));
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: tmp
    if ((y_46re <= (-0.46d0)) .or. (.not. (y_46re <= 8.2d-19))) then
        tmp = x_46im ** y_46re
    else
        tmp = cos((y_46re * atan2(x_46im, x_46re)))
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_re <= -0.46) || !(y_46_re <= 8.2e-19)) {
		tmp = Math.pow(x_46_im, y_46_re);
	} else {
		tmp = Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re)));
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if (y_46_re <= -0.46) or not (y_46_re <= 8.2e-19):
		tmp = math.pow(x_46_im, y_46_re)
	else:
		tmp = math.cos((y_46_re * math.atan2(x_46_im, x_46_re)))
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if ((y_46_re <= -0.46) || !(y_46_re <= 8.2e-19))
		tmp = x_46_im ^ y_46_re;
	else
		tmp = cos(Float64(y_46_re * atan(x_46_im, x_46_re)));
	end
	return tmp
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0;
	if ((y_46_re <= -0.46) || ~((y_46_re <= 8.2e-19)))
		tmp = x_46_im ^ y_46_re;
	else
		tmp = cos((y_46_re * atan2(x_46_im, x_46_re)));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -0.46], N[Not[LessEqual[y$46$re, 8.2e-19]], $MachinePrecision]], N[Power[x$46$im, y$46$re], $MachinePrecision], N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -0.46 \lor \neg \left(y.re \leq 8.2 \cdot 10^{-19}\right):\\
\;\;\;\;{x.im}^{y.re}\\

\mathbf{else}:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 12: 40.2% accurate, 8.1× speedup?

\[\begin{array}{l} \\ {x.im}^{y.re} \end{array} \]
(FPCore (x.re x.im y.re y.im) :precision binary64 (pow x.im y.re))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return pow(x_46_im, y_46_re);
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    code = x_46im ** y_46re
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return Math.pow(x_46_im, y_46_re);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return math.pow(x_46_im, y_46_re)
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return x_46_im ^ y_46_re
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = x_46_im ^ y_46_re;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Power[x$46$im, y$46$re], $MachinePrecision]
\begin{array}{l}

\\
{x.im}^{y.re}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Reproduce

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