powComplex, real part

Percentage Accurate: 41.1% → 81.0%
Time: 25.5s
Alternatives: 8
Speedup: 4.0×

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 8 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: 41.1% 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: 81.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ \mathbf{if}\;x.im \leq -1.45 \cdot 10^{-198}:\\ \;\;\;\;e^{\mathsf{fma}\left(t\_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{\mathsf{fma}\left(t\_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}\\ \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 (<= x.im -1.45e-198)
     (*
      (exp (fma t_0 y.re (* (atan2 x.im x.re) (- y.im))))
      (cos (pow (cbrt (fma t_0 y.im (* y.re (atan2 x.im x.re)))) 3.0)))
     (exp
      (*
       y.re
       (- (log (hypot x.im x.re)) (* (atan2 x.im x.re) (/ y.im 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 (x_46_im <= -1.45e-198) {
		tmp = exp(fma(t_0, y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * cos(pow(cbrt(fma(t_0, y_46_im, (y_46_re * atan2(x_46_im, x_46_re)))), 3.0));
	} else {
		tmp = exp((y_46_re * (log(hypot(x_46_im, x_46_re)) - (atan2(x_46_im, x_46_re) * (y_46_im / 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 (x_46_im <= -1.45e-198)
		tmp = Float64(exp(fma(t_0, y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * cos((cbrt(fma(t_0, y_46_im, Float64(y_46_re * atan(x_46_im, x_46_re)))) ^ 3.0)));
	else
		tmp = exp(Float64(y_46_re * Float64(log(hypot(x_46_im, x_46_re)) - Float64(atan(x_46_im, x_46_re) * Float64(y_46_im / 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[x$46$im, -1.45e-198], N[(N[Exp[N[(t$95$0 * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[Power[N[Power[N[(t$95$0 * y$46$im + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(y$46$re * N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
\mathbf{if}\;x.im \leq -1.45 \cdot 10^{-198}:\\
\;\;\;\;e^{\mathsf{fma}\left(t\_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{\mathsf{fma}\left(t\_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\right)}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -1.45e-198

    1. Initial program 44.4%

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
    2. Step-by-step derivation
      1. fma-neg44.4%

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

        \[\leadsto e^{\mathsf{fma}\left(\log \color{blue}{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}, y.re, -\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right)} \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. distribute-rgt-neg-out44.4%

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\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. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine82.5%

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

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

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re}\right) \]
      4. add-cube-cbrt47.2%

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

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

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{\color{blue}{\mathsf{fma}\left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}}\right)}^{3}\right) \]
      7. hypot-define90.1%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{\mathsf{fma}\left(\log \color{blue}{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}, y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\right)}^{3}\right) \]
    6. Applied egg-rr90.1%

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

    if -1.45e-198 < x.im

    1. Initial program 42.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. Add Preprocessing
    3. Taylor expanded in y.im around 0 68.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 \color{blue}{\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)} \]
    4. Taylor expanded in y.re around 0 70.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} \]
    5. Taylor expanded in y.re around inf 70.4%

      \[\leadsto e^{\color{blue}{y.re \cdot \left(\log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)}} \cdot 1 \]
    6. Step-by-step derivation
      1. +-commutative70.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{{x.re}^{2} + {x.im}^{2}}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      2. unpow270.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{x.re \cdot x.re} + {x.im}^{2}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      3. unpow270.4%

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

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

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

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

        \[\leadsto e^{y.re \cdot \left(\log \color{blue}{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)} - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      8. unpow270.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{{x.re}^{2}} + x.im \cdot x.im}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      9. unpow270.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{{x.re}^{2} + \color{blue}{{x.im}^{2}}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      10. +-commutative70.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{{x.im}^{2} + {x.re}^{2}}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      11. unpow270.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{x.im \cdot x.im} + {x.re}^{2}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      12. unpow270.4%

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

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

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

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

      \[\leadsto e^{\color{blue}{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}} \cdot 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.7%

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

Alternative 2: 81.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ \mathbf{if}\;x.im \leq -3 \cdot 10^{-199}:\\ \;\;\;\;e^{\mathsf{fma}\left(t\_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im}\right)}^{2} \cdot \left(t\_0 \cdot \sqrt[3]{y.im}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}\\ \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 (<= x.im -3e-199)
     (*
      (exp (fma t_0 y.re (* (atan2 x.im x.re) (- y.im))))
      (cos (* (pow (cbrt y.im) 2.0) (* t_0 (cbrt y.im)))))
     (exp
      (*
       y.re
       (- (log (hypot x.im x.re)) (* (atan2 x.im x.re) (/ y.im 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 (x_46_im <= -3e-199) {
		tmp = exp(fma(t_0, y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * cos((pow(cbrt(y_46_im), 2.0) * (t_0 * cbrt(y_46_im))));
	} else {
		tmp = exp((y_46_re * (log(hypot(x_46_im, x_46_re)) - (atan2(x_46_im, x_46_re) * (y_46_im / 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 (x_46_im <= -3e-199)
		tmp = Float64(exp(fma(t_0, y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * cos(Float64((cbrt(y_46_im) ^ 2.0) * Float64(t_0 * cbrt(y_46_im)))));
	else
		tmp = exp(Float64(y_46_re * Float64(log(hypot(x_46_im, x_46_re)) - Float64(atan(x_46_im, x_46_re) * Float64(y_46_im / 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[x$46$im, -3e-199], N[(N[Exp[N[(t$95$0 * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[Power[N[Power[y$46$im, 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[(t$95$0 * N[Power[y$46$im, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(y$46$re * N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
\mathbf{if}\;x.im \leq -3 \cdot 10^{-199}:\\
\;\;\;\;e^{\mathsf{fma}\left(t\_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im}\right)}^{2} \cdot \left(t\_0 \cdot \sqrt[3]{y.im}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -2.99999999999999983e-199

    1. Initial program 44.4%

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
    2. Step-by-step derivation
      1. fma-neg44.4%

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

        \[\leadsto e^{\mathsf{fma}\left(\log \color{blue}{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}, y.re, -\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right)} \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. distribute-rgt-neg-out44.4%

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\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. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine82.5%

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

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

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re}\right) \]
      4. add-cube-cbrt47.2%

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

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

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{\color{blue}{\mathsf{fma}\left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}}\right)}^{3}\right) \]
      7. hypot-define90.1%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{\mathsf{fma}\left(\log \color{blue}{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}, y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\right)}^{3}\right) \]
    6. Applied egg-rr90.1%

      \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \color{blue}{\left({\left(\sqrt[3]{\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)}^{3}\right)} \]
    7. Taylor expanded in y.im around inf 45.3%

      \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\color{blue}{\left(\sqrt[3]{y.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)}\right)}}^{3}\right) \]
    8. Step-by-step derivation
      1. +-commutative45.3%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im \cdot \log \left(\sqrt{\color{blue}{{x.re}^{2} + {x.im}^{2}}}\right)}\right)}^{3}\right) \]
      2. unpow245.3%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im \cdot \log \left(\sqrt{\color{blue}{x.re \cdot x.re} + {x.im}^{2}}\right)}\right)}^{3}\right) \]
      3. unpow245.3%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im \cdot \log \left(\sqrt{x.re \cdot x.re + \color{blue}{x.im \cdot x.im}}\right)}\right)}^{3}\right) \]
      4. hypot-undefine88.2%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im \cdot \log \color{blue}{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}}\right)}^{3}\right) \]
    9. Simplified88.2%

      \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\color{blue}{\left(\sqrt[3]{y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)}}^{3}\right) \]
    10. Step-by-step derivation
      1. rem-cube-cbrt85.3%

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

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

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left(\left(\left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right) \cdot \sqrt[3]{y.im}\right) \cdot \log \color{blue}{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}\right) \]
      4. associate-*l*45.3%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \color{blue}{\left(\left(\sqrt[3]{y.im} \cdot \sqrt[3]{y.im}\right) \cdot \left(\sqrt[3]{y.im} \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\right)\right)} \]
      5. pow245.3%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left(\color{blue}{{\left(\sqrt[3]{y.im}\right)}^{2}} \cdot \left(\sqrt[3]{y.im} \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\right)\right) \]
      6. hypot-define89.1%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im}\right)}^{2} \cdot \left(\sqrt[3]{y.im} \cdot \log \color{blue}{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}\right)\right) \]
    11. Applied egg-rr89.1%

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

    if -2.99999999999999983e-199 < x.im

    1. Initial program 42.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. Add Preprocessing
    3. Taylor expanded in y.im around 0 68.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 \color{blue}{\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)} \]
    4. Taylor expanded in y.re around 0 70.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} \]
    5. Taylor expanded in y.re around inf 70.4%

      \[\leadsto e^{\color{blue}{y.re \cdot \left(\log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)}} \cdot 1 \]
    6. Step-by-step derivation
      1. +-commutative70.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{{x.re}^{2} + {x.im}^{2}}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      2. unpow270.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{x.re \cdot x.re} + {x.im}^{2}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      3. unpow270.4%

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

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

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

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

        \[\leadsto e^{y.re \cdot \left(\log \color{blue}{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)} - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      8. unpow270.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{{x.re}^{2}} + x.im \cdot x.im}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      9. unpow270.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{{x.re}^{2} + \color{blue}{{x.im}^{2}}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      10. +-commutative70.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{{x.im}^{2} + {x.re}^{2}}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      11. unpow270.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{x.im \cdot x.im} + {x.re}^{2}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      12. unpow270.4%

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

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

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

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

      \[\leadsto e^{\color{blue}{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}} \cdot 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -3 \cdot 10^{-199}:\\ \;\;\;\;e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im}\right)}^{2} \cdot \left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot \sqrt[3]{y.im}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 82.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ \mathbf{if}\;x.im \leq -4 \cdot 10^{-198}:\\ \;\;\;\;e^{\mathsf{fma}\left(t\_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{t\_0 \cdot y.im}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}\\ \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 (<= x.im -4e-198)
     (*
      (exp (fma t_0 y.re (* (atan2 x.im x.re) (- y.im))))
      (cos (pow (cbrt (* t_0 y.im)) 3.0)))
     (exp
      (*
       y.re
       (- (log (hypot x.im x.re)) (* (atan2 x.im x.re) (/ y.im 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 (x_46_im <= -4e-198) {
		tmp = exp(fma(t_0, y_46_re, (atan2(x_46_im, x_46_re) * -y_46_im))) * cos(pow(cbrt((t_0 * y_46_im)), 3.0));
	} else {
		tmp = exp((y_46_re * (log(hypot(x_46_im, x_46_re)) - (atan2(x_46_im, x_46_re) * (y_46_im / 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 (x_46_im <= -4e-198)
		tmp = Float64(exp(fma(t_0, y_46_re, Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))) * cos((cbrt(Float64(t_0 * y_46_im)) ^ 3.0)));
	else
		tmp = exp(Float64(y_46_re * Float64(log(hypot(x_46_im, x_46_re)) - Float64(atan(x_46_im, x_46_re) * Float64(y_46_im / 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[x$46$im, -4e-198], N[(N[Exp[N[(t$95$0 * y$46$re + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[Power[N[Power[N[(t$95$0 * y$46$im), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(y$46$re * N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
\mathbf{if}\;x.im \leq -4 \cdot 10^{-198}:\\
\;\;\;\;e^{\mathsf{fma}\left(t\_0, y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{t\_0 \cdot y.im}\right)}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.9999999999999996e-198

    1. Initial program 44.4%

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
    2. Step-by-step derivation
      1. fma-neg44.4%

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

        \[\leadsto e^{\mathsf{fma}\left(\log \color{blue}{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}, y.re, -\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right)} \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. distribute-rgt-neg-out44.4%

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\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. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine82.5%

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

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

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re}\right) \]
      4. add-cube-cbrt47.2%

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

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

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{\color{blue}{\mathsf{fma}\left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}}\right)}^{3}\right) \]
      7. hypot-define90.1%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{\mathsf{fma}\left(\log \color{blue}{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}, y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\right)}^{3}\right) \]
    6. Applied egg-rr90.1%

      \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \color{blue}{\left({\left(\sqrt[3]{\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)}^{3}\right)} \]
    7. Taylor expanded in y.im around inf 45.3%

      \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\color{blue}{\left(\sqrt[3]{y.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)}\right)}}^{3}\right) \]
    8. Step-by-step derivation
      1. +-commutative45.3%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im \cdot \log \left(\sqrt{\color{blue}{{x.re}^{2} + {x.im}^{2}}}\right)}\right)}^{3}\right) \]
      2. unpow245.3%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im \cdot \log \left(\sqrt{\color{blue}{x.re \cdot x.re} + {x.im}^{2}}\right)}\right)}^{3}\right) \]
      3. unpow245.3%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im \cdot \log \left(\sqrt{x.re \cdot x.re + \color{blue}{x.im \cdot x.im}}\right)}\right)}^{3}\right) \]
      4. hypot-undefine88.2%

        \[\leadsto e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{y.im \cdot \log \color{blue}{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}}\right)}^{3}\right) \]
    9. Simplified88.2%

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

    if -3.9999999999999996e-198 < x.im

    1. Initial program 42.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. Add Preprocessing
    3. Taylor expanded in y.im around 0 68.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 \color{blue}{\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)} \]
    4. Taylor expanded in y.re around 0 70.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} \]
    5. Taylor expanded in y.re around inf 70.4%

      \[\leadsto e^{\color{blue}{y.re \cdot \left(\log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)}} \cdot 1 \]
    6. Step-by-step derivation
      1. +-commutative70.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{{x.re}^{2} + {x.im}^{2}}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      2. unpow270.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{x.re \cdot x.re} + {x.im}^{2}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      3. unpow270.4%

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

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

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

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

        \[\leadsto e^{y.re \cdot \left(\log \color{blue}{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)} - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      8. unpow270.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{{x.re}^{2}} + x.im \cdot x.im}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      9. unpow270.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{{x.re}^{2} + \color{blue}{{x.im}^{2}}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      10. +-commutative70.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{{x.im}^{2} + {x.re}^{2}}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      11. unpow270.4%

        \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{x.im \cdot x.im} + {x.re}^{2}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
      12. unpow270.4%

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

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

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

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

      \[\leadsto e^{\color{blue}{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}} \cdot 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -4 \cdot 10^{-198}:\\ \;\;\;\;e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)\right)} \cdot \cos \left({\left(\sqrt[3]{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.im}\right)}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 81.5% accurate, 2.0× speedup?

\[\begin{array}{l} \\ e^{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (exp
  (* y.re (- (log (hypot x.im x.re)) (* (atan2 x.im x.re) (/ y.im y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return exp((y_46_re * (log(hypot(x_46_im, x_46_re)) - (atan2(x_46_im, x_46_re) * (y_46_im / y_46_re)))));
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return Math.exp((y_46_re * (Math.log(Math.hypot(x_46_im, x_46_re)) - (Math.atan2(x_46_im, x_46_re) * (y_46_im / y_46_re)))));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return math.exp((y_46_re * (math.log(math.hypot(x_46_im, x_46_re)) - (math.atan2(x_46_im, x_46_re) * (y_46_im / y_46_re)))))
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return exp(Float64(y_46_re * Float64(log(hypot(x_46_im, x_46_re)) - Float64(atan(x_46_im, x_46_re) * Float64(y_46_im / y_46_re)))))
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = exp((y_46_re * (log(hypot(x_46_im, x_46_re)) - (atan2(x_46_im, x_46_re) * (y_46_im / y_46_re)))));
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(y$46$re * N[(N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[(y$46$im / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
e^{y.re \cdot \left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot \frac{y.im}{y.re}\right)}
\end{array}
Derivation
  1. Initial program 43.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. Add Preprocessing
  3. Taylor expanded in y.im around 0 68.2%

    \[\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)} \]
  4. Taylor expanded in y.re around 0 69.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 \color{blue}{1} \]
  5. Taylor expanded in y.re around inf 69.1%

    \[\leadsto e^{\color{blue}{y.re \cdot \left(\log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)}} \cdot 1 \]
  6. Step-by-step derivation
    1. +-commutative69.1%

      \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{{x.re}^{2} + {x.im}^{2}}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
    2. unpow269.1%

      \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{x.re \cdot x.re} + {x.im}^{2}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
    3. unpow269.1%

      \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{x.re \cdot x.re + \color{blue}{x.im \cdot x.im}}\right) + -1 \cdot \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
    4. hypot-undefine84.6%

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

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

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

      \[\leadsto e^{y.re \cdot \left(\log \color{blue}{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)} - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
    8. unpow269.1%

      \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{{x.re}^{2}} + x.im \cdot x.im}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
    9. unpow269.1%

      \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{{x.re}^{2} + \color{blue}{{x.im}^{2}}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
    10. +-commutative69.1%

      \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{{x.im}^{2} + {x.re}^{2}}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
    11. unpow269.1%

      \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{\color{blue}{x.im \cdot x.im} + {x.re}^{2}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
    12. unpow269.1%

      \[\leadsto e^{y.re \cdot \left(\log \left(\sqrt{x.im \cdot x.im + \color{blue}{x.re \cdot x.re}}\right) - \frac{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}{y.re}\right)} \cdot 1 \]
    13. hypot-define84.6%

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

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

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

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

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

Alternative 5: 76.8% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y.re \leq -5.8 \cdot 10^{+19} \lor \neg \left(y.re \leq 2.2\right):\\ \;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}\\ \mathbf{else}:\\ \;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (or (<= y.re -5.8e+19) (not (<= y.re 2.2)))
   (exp (* (log (hypot x.re x.im)) y.re))
   (exp (* (atan2 x.im x.re) (- y.im)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if ((y_46_re <= -5.8e+19) || !(y_46_re <= 2.2)) {
		tmp = exp((log(hypot(x_46_re, x_46_im)) * y_46_re));
	} else {
		tmp = exp((atan2(x_46_im, x_46_re) * -y_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 tmp;
	if ((y_46_re <= -5.8e+19) || !(y_46_re <= 2.2)) {
		tmp = Math.exp((Math.log(Math.hypot(x_46_re, x_46_im)) * y_46_re));
	} else {
		tmp = Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	tmp = 0
	if (y_46_re <= -5.8e+19) or not (y_46_re <= 2.2):
		tmp = math.exp((math.log(math.hypot(x_46_re, x_46_im)) * y_46_re))
	else:
		tmp = math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im))
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 0.0
	if ((y_46_re <= -5.8e+19) || !(y_46_re <= 2.2))
		tmp = exp(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re));
	else
		tmp = exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)));
	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 <= -5.8e+19) || ~((y_46_re <= 2.2)))
		tmp = exp((log(hypot(x_46_re, x_46_im)) * y_46_re));
	else
		tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im));
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[y$46$re, -5.8e+19], N[Not[LessEqual[y$46$re, 2.2]], $MachinePrecision]], N[Exp[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y.re \leq -5.8 \cdot 10^{+19} \lor \neg \left(y.re \leq 2.2\right):\\
\;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y.re < -5.8e19 or 2.2000000000000002 < y.re

    1. Initial program 41.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. Add Preprocessing
    3. Taylor expanded in y.im around 0 78.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 \color{blue}{\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)} \]
    4. Taylor expanded in y.re around 0 81.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 \color{blue}{1} \]
    5. Taylor expanded in y.re around inf 78.2%

      \[\leadsto e^{\color{blue}{y.re \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)}} \cdot 1 \]
    6. Step-by-step derivation
      1. +-commutative78.2%

        \[\leadsto e^{y.re \cdot \log \left(\sqrt{\color{blue}{{x.re}^{2} + {x.im}^{2}}}\right)} \cdot 1 \]
      2. unpow278.2%

        \[\leadsto e^{y.re \cdot \log \left(\sqrt{\color{blue}{x.re \cdot x.re} + {x.im}^{2}}\right)} \cdot 1 \]
      3. unpow278.2%

        \[\leadsto e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + \color{blue}{x.im \cdot x.im}}\right)} \cdot 1 \]
      4. hypot-undefine78.2%

        \[\leadsto e^{y.re \cdot \log \color{blue}{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}} \cdot 1 \]
    7. Simplified78.2%

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

    if -5.8e19 < y.re < 2.2000000000000002

    1. Initial program 45.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. Add Preprocessing
    3. Taylor expanded in y.im around 0 56.0%

      \[\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)} \]
    4. Taylor expanded in y.re around 0 55.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} \]
    5. Taylor expanded in y.re around 0 83.4%

      \[\leadsto e^{\color{blue}{-1 \cdot \left(y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}} \cdot 1 \]
    6. Step-by-step derivation
      1. mul-1-neg83.4%

        \[\leadsto e^{\color{blue}{-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \cdot 1 \]
      2. *-commutative83.4%

        \[\leadsto e^{-\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot 1 \]
      3. distribute-rgt-neg-in83.4%

        \[\leadsto e^{\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}} \cdot 1 \]
    7. Simplified83.4%

      \[\leadsto e^{\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}} \cdot 1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -5.8 \cdot 10^{+19} \lor \neg \left(y.re \leq 2.2\right):\\ \;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}\\ \mathbf{else}:\\ \;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 52.6% accurate, 4.0× speedup?

\[\begin{array}{l} \\ e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (exp (* (atan2 x.im x.re) (- y.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return exp((atan2(x_46_im, x_46_re) * -y_46_im));
}
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 = exp((atan2(x_46im, x_46re) * -y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im)))
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im));
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}
\end{array}
Derivation
  1. Initial program 43.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. Add Preprocessing
  3. Taylor expanded in y.im around 0 68.2%

    \[\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)} \]
  4. Taylor expanded in y.re around 0 69.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 \color{blue}{1} \]
  5. Taylor expanded in y.re around 0 56.0%

    \[\leadsto e^{\color{blue}{-1 \cdot \left(y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}} \cdot 1 \]
  6. Step-by-step derivation
    1. mul-1-neg56.0%

      \[\leadsto e^{\color{blue}{-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \cdot 1 \]
    2. *-commutative56.0%

      \[\leadsto e^{-\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot 1 \]
    3. distribute-rgt-neg-in56.0%

      \[\leadsto e^{\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}} \cdot 1 \]
  7. Simplified56.0%

    \[\leadsto e^{\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}} \cdot 1 \]
  8. Final simplification56.0%

    \[\leadsto e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)} \]
  9. Add Preprocessing

Alternative 7: 29.1% accurate, 4.1× speedup?

\[\begin{array}{l} \\ e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (exp (* (atan2 x.im x.re) y.im)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return exp((atan2(x_46_im, x_46_re) * y_46_im));
}
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 = exp((atan2(x_46im, x_46re) * y_46im))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return Math.exp((Math.atan2(x_46_im, x_46_re) * y_46_im));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return math.exp((math.atan2(x_46_im, x_46_re) * y_46_im))
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return exp(Float64(atan(x_46_im, x_46_re) * y_46_im))
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = exp((atan2(x_46_im, x_46_re) * y_46_im));
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}
\end{array}
Derivation
  1. Initial program 43.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. Add Preprocessing
  3. Taylor expanded in y.im around 0 68.2%

    \[\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)} \]
  4. Taylor expanded in y.re around 0 69.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 \color{blue}{1} \]
  5. Taylor expanded in y.re around 0 56.0%

    \[\leadsto e^{\color{blue}{-1 \cdot \left(y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}} \cdot 1 \]
  6. Step-by-step derivation
    1. mul-1-neg56.0%

      \[\leadsto e^{\color{blue}{-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \cdot 1 \]
    2. *-commutative56.0%

      \[\leadsto e^{-\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot 1 \]
    3. distribute-rgt-neg-in56.0%

      \[\leadsto e^{\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}} \cdot 1 \]
  7. Simplified56.0%

    \[\leadsto e^{\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}} \cdot 1 \]
  8. Step-by-step derivation
    1. add-sqr-sqrt27.4%

      \[\leadsto e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \color{blue}{\left(\sqrt{-y.im} \cdot \sqrt{-y.im}\right)}} \cdot 1 \]
    2. sqrt-unprod41.3%

      \[\leadsto e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \color{blue}{\sqrt{\left(-y.im\right) \cdot \left(-y.im\right)}}} \cdot 1 \]
    3. sqr-neg41.3%

      \[\leadsto e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \sqrt{\color{blue}{y.im \cdot y.im}}} \cdot 1 \]
    4. sqrt-unprod14.0%

      \[\leadsto e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \color{blue}{\left(\sqrt{y.im} \cdot \sqrt{y.im}\right)}} \cdot 1 \]
    5. add-sqr-sqrt26.1%

      \[\leadsto e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \color{blue}{y.im}} \cdot 1 \]
    6. add-log-exp26.2%

      \[\leadsto e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \color{blue}{\log \left(e^{y.im}\right)}} \cdot 1 \]
    7. log-pow26.3%

      \[\leadsto e^{\color{blue}{\log \left({\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}\right)}} \cdot 1 \]
    8. *-un-lft-identity26.3%

      \[\leadsto e^{\log \color{blue}{\left(1 \cdot {\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}\right)}} \cdot 1 \]
    9. log-prod26.3%

      \[\leadsto e^{\color{blue}{\log 1 + \log \left({\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}\right)}} \cdot 1 \]
    10. metadata-eval26.3%

      \[\leadsto e^{\color{blue}{0} + \log \left({\left(e^{y.im}\right)}^{\tan^{-1}_* \frac{x.im}{x.re}}\right)} \cdot 1 \]
    11. pow-exp26.1%

      \[\leadsto e^{0 + \log \color{blue}{\left(e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}\right)}} \cdot 1 \]
    12. rem-log-exp26.1%

      \[\leadsto e^{0 + \color{blue}{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \cdot 1 \]
  9. Applied egg-rr26.1%

    \[\leadsto e^{\color{blue}{0 + y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \cdot 1 \]
  10. Step-by-step derivation
    1. +-lft-identity26.1%

      \[\leadsto e^{\color{blue}{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \cdot 1 \]
  11. Simplified26.1%

    \[\leadsto e^{\color{blue}{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \cdot 1 \]
  12. Final simplification26.1%

    \[\leadsto e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \]
  13. Add Preprocessing

Alternative 8: 25.7% accurate, 7.8× speedup?

\[\begin{array}{l} \\ 1 - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (- 1.0 (* (atan2 x.im x.re) y.im)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return 1.0 - (atan2(x_46_im, x_46_re) * y_46_im);
}
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 = 1.0d0 - (atan2(x_46im, x_46re) * y_46im)
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return 1.0 - (Math.atan2(x_46_im, x_46_re) * y_46_im);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return 1.0 - (math.atan2(x_46_im, x_46_re) * y_46_im)
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(1.0 - Float64(atan(x_46_im, x_46_re) * y_46_im))
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 1.0 - (atan2(x_46_im, x_46_re) * y_46_im);
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(1.0 - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im
\end{array}
Derivation
  1. Initial program 43.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. Add Preprocessing
  3. Taylor expanded in y.im around 0 68.2%

    \[\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)} \]
  4. Taylor expanded in y.re around 0 69.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 \color{blue}{1} \]
  5. Taylor expanded in y.re around 0 56.0%

    \[\leadsto e^{\color{blue}{-1 \cdot \left(y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}} \cdot 1 \]
  6. Step-by-step derivation
    1. mul-1-neg56.0%

      \[\leadsto e^{\color{blue}{-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \cdot 1 \]
    2. *-commutative56.0%

      \[\leadsto e^{-\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot 1 \]
    3. distribute-rgt-neg-in56.0%

      \[\leadsto e^{\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}} \cdot 1 \]
  7. Simplified56.0%

    \[\leadsto e^{\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)}} \cdot 1 \]
  8. Taylor expanded in y.im around 0 21.2%

    \[\leadsto \color{blue}{\left(1 + -1 \cdot \left(y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)} \cdot 1 \]
  9. Step-by-step derivation
    1. mul-1-neg21.2%

      \[\leadsto \left(1 + \color{blue}{\left(-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\right) \cdot 1 \]
  10. Simplified21.2%

    \[\leadsto \color{blue}{\left(1 + \left(-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)} \cdot 1 \]
  11. Final simplification21.2%

    \[\leadsto 1 - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im \]
  12. Add Preprocessing

Reproduce

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