powComplex, real part

Percentage Accurate: 40.1% → 80.4%
Time: 11.1s
Alternatives: 8
Speedup: N/A×

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)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    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}

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: 40.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)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x_46re, x_46im, y_46re, y_46im)
use fmin_fmax_functions
    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: 80.4% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_1 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\\ t_2 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\ t_3 := e^{t\_2 \cdot y.re - t\_0}\\ t_4 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ \mathbf{if}\;t\_3 \cdot \cos \left(t\_2 \cdot y.im + t\_1\right) \leq -\infty:\\ \;\;\;\;t\_3 \cdot \left(\sin \left(0.5 \cdot \pi\right) - \left(-y.im\right) \cdot \left(\sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right) \cdot \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;e^{t\_4 \cdot y.re - t\_0} \cdot \sin \left(\mathsf{fma}\left(t\_4, y.im, t\_1\right) + \frac{\pi}{2}\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (* (atan2 x.im x.re) y.im))
        (t_1 (* (atan2 x.im x.re) y.re))
        (t_2 (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
        (t_3 (exp (- (* t_2 y.re) t_0)))
        (t_4 (log (hypot x.re x.im))))
   (if (<= (* t_3 (cos (+ (* t_2 y.im) t_1))) (- INFINITY))
     (*
      t_3
      (-
       (sin (* 0.5 PI))
       (*
        (- y.im)
        (*
         (sin (fma 0.5 PI (/ PI 2.0)))
         (log (pow (fma x.im x.im (* x.re x.re)) 0.5))))))
     (* (exp (- (* t_4 y.re) t_0)) (sin (+ (fma t_4 y.im t_1) (/ PI 2.0)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = atan2(x_46_im, x_46_re) * y_46_im;
	double t_1 = atan2(x_46_im, x_46_re) * y_46_re;
	double t_2 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
	double t_3 = exp(((t_2 * y_46_re) - t_0));
	double t_4 = log(hypot(x_46_re, x_46_im));
	double tmp;
	if ((t_3 * cos(((t_2 * y_46_im) + t_1))) <= -((double) INFINITY)) {
		tmp = t_3 * (sin((0.5 * ((double) M_PI))) - (-y_46_im * (sin(fma(0.5, ((double) M_PI), (((double) M_PI) / 2.0))) * log(pow(fma(x_46_im, x_46_im, (x_46_re * x_46_re)), 0.5)))));
	} else {
		tmp = exp(((t_4 * y_46_re) - t_0)) * sin((fma(t_4, y_46_im, t_1) + (((double) M_PI) / 2.0)));
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(atan(x_46_im, x_46_re) * y_46_im)
	t_1 = Float64(atan(x_46_im, x_46_re) * y_46_re)
	t_2 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im))))
	t_3 = exp(Float64(Float64(t_2 * y_46_re) - t_0))
	t_4 = log(hypot(x_46_re, x_46_im))
	tmp = 0.0
	if (Float64(t_3 * cos(Float64(Float64(t_2 * y_46_im) + t_1))) <= Float64(-Inf))
		tmp = Float64(t_3 * Float64(sin(Float64(0.5 * pi)) - Float64(Float64(-y_46_im) * Float64(sin(fma(0.5, pi, Float64(pi / 2.0))) * log((fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)) ^ 0.5))))));
	else
		tmp = Float64(exp(Float64(Float64(t_4 * y_46_re) - t_0)) * sin(Float64(fma(t_4, y_46_im, t_1) + Float64(pi / 2.0))));
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]}, Block[{t$95$2 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Exp[N[(N[(t$95$2 * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$3 * N[Cos[N[(N[(t$95$2 * y$46$im), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(t$95$3 * N[(N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision] - N[((-y$46$im) * N[(N[Sin[N[(0.5 * Pi + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[N[Power[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(t$95$4 * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(N[(t$95$4 * y$46$im + t$95$1), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
t_1 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\\
t_2 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
t_3 := e^{t\_2 \cdot y.re - t\_0}\\
t_4 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
\mathbf{if}\;t\_3 \cdot \cos \left(t\_2 \cdot y.im + t\_1\right) \leq -\infty:\\
\;\;\;\;t\_3 \cdot \left(\sin \left(0.5 \cdot \pi\right) - \left(-y.im\right) \cdot \left(\sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right) \cdot \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;e^{t\_4 \cdot y.re - t\_0} \cdot \sin \left(\mathsf{fma}\left(t\_4, y.im, t\_1\right) + \frac{\pi}{2}\right)\\


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

    1. Initial program 47.5%

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
    2. Taylor expanded in y.re around 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.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)} \]
    3. Step-by-step derivation
      1. sin-+PI/2-revN/A

        \[\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 \sin \left(y.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
      2. lower-sin.f64N/A

        \[\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 \sin \left(y.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
      3. lower-fma.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      4. lower-log.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      5. pow1/2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left({x.im}^{2} + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      6. lower-pow.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left({x.im}^{2} + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      7. pow2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(x.im \cdot x.im + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      8. lower-fma.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, {x.re}^{2}\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      9. pow2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      10. lift-*.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      11. lower-/.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      12. lower-PI.f6452.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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right), \frac{\pi}{2}\right)\right) \]
    4. Applied rewrites52.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}{\sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right), \frac{\pi}{2}\right)\right)} \]
    5. Taylor expanded in y.im around 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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) + \color{blue}{y.im \cdot \left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. fp-cancel-sign-sub-invN/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)}\right) \]
      2. lower--.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)}\right) \]
      3. lower-sin.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \left(\color{blue}{\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)} \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)\right) \]
      4. lower-*.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \left(\cos \color{blue}{\left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)} \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)\right) \]
      5. lift-PI.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \pi\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)\right) \]
      6. lower-*.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \pi\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)}\right)\right) \]
      7. lift-neg.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \pi\right) - \left(-y.im\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \color{blue}{\left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)}\right)\right) \]
      8. lower-*.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \pi\right) - \left(-y.im\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)\right) \]
    7. Applied rewrites56.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 \left(\sin \left(0.5 \cdot \pi\right) - \color{blue}{\left(-y.im\right) \cdot \left(\sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right) \cdot \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right)\right)}\right) \]

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

    1. Initial program 39.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. Applied rewrites75.4%

      \[\leadsto \color{blue}{\frac{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right)} \]
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      2. lift-exp.f64N/A

        \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{e^{\color{blue}{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      4. lift-log.f64N/A

        \[\leadsto \frac{e^{\color{blue}{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)} \cdot y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      5. lift-hypot.f64N/A

        \[\leadsto \frac{e^{\log \color{blue}{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)} \cdot y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      6. lift-exp.f64N/A

        \[\leadsto \frac{e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re}}{\color{blue}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      7. div-expN/A

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

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

Alternative 2: 73.7% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ \mathbf{if}\;x.im \leq -2.6 \cdot 10^{-267}:\\ \;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - t\_0} \cdot \sin \left(\mathsf{fma}\left(\log \left(-1 \cdot x.im\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right)\\ \mathbf{elif}\;x.im \leq 1.35 \cdot 10^{+50}:\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t\_0} \cdot \sin \left(0.5 \cdot \pi\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (* (atan2 x.im x.re) y.im)))
   (if (<= x.im -2.6e-267)
     (*
      (exp (- (* (log (hypot x.re x.im)) y.re) t_0))
      (sin
       (+
        (fma (log (* -1.0 x.im)) y.im (* (atan2 x.im x.re) y.re))
        (/ PI 2.0))))
     (if (<= x.im 1.35e+50)
       (*
        (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) t_0))
        (sin (* 0.5 PI)))
       (*
        (cos (fma y.im (log x.im) (* y.re (atan2 x.im x.re))))
        (/ (exp (* y.re (log x.im))) (exp (* y.im (atan2 x.im x.re)))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = atan2(x_46_im, x_46_re) * y_46_im;
	double tmp;
	if (x_46_im <= -2.6e-267) {
		tmp = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - t_0)) * sin((fma(log((-1.0 * x_46_im)), y_46_im, (atan2(x_46_im, x_46_re) * y_46_re)) + (((double) M_PI) / 2.0)));
	} else if (x_46_im <= 1.35e+50) {
		tmp = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - t_0)) * sin((0.5 * ((double) M_PI)));
	} else {
		tmp = cos(fma(y_46_im, log(x_46_im), (y_46_re * atan2(x_46_im, x_46_re)))) * (exp((y_46_re * log(x_46_im))) / exp((y_46_im * atan2(x_46_im, x_46_re))));
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(atan(x_46_im, x_46_re) * y_46_im)
	tmp = 0.0
	if (x_46_im <= -2.6e-267)
		tmp = Float64(exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - t_0)) * sin(Float64(fma(log(Float64(-1.0 * x_46_im)), y_46_im, Float64(atan(x_46_im, x_46_re) * y_46_re)) + Float64(pi / 2.0))));
	elseif (x_46_im <= 1.35e+50)
		tmp = Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - t_0)) * sin(Float64(0.5 * pi)));
	else
		tmp = Float64(cos(fma(y_46_im, log(x_46_im), Float64(y_46_re * atan(x_46_im, x_46_re)))) * Float64(exp(Float64(y_46_re * log(x_46_im))) / exp(Float64(y_46_im * atan(x_46_im, x_46_re)))));
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]}, If[LessEqual[x$46$im, -2.6e-267], N[(N[Exp[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(N[(N[Log[N[(-1.0 * x$46$im), $MachinePrecision]], $MachinePrecision] * y$46$im + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 1.35e+50], N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Exp[N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
\mathbf{if}\;x.im \leq -2.6 \cdot 10^{-267}:\\
\;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - t\_0} \cdot \sin \left(\mathsf{fma}\left(\log \left(-1 \cdot x.im\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right)\\

\mathbf{elif}\;x.im \leq 1.35 \cdot 10^{+50}:\\
\;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t\_0} \cdot \sin \left(0.5 \cdot \pi\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -2.6000000000000001e-267

    1. Initial program 40.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. Applied rewrites72.5%

      \[\leadsto \color{blue}{\frac{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right)} \]
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      2. lift-exp.f64N/A

        \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{e^{\color{blue}{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      4. lift-log.f64N/A

        \[\leadsto \frac{e^{\color{blue}{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)} \cdot y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      5. lift-hypot.f64N/A

        \[\leadsto \frac{e^{\log \color{blue}{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)} \cdot y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      6. lift-exp.f64N/A

        \[\leadsto \frac{e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re}}{\color{blue}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      7. div-expN/A

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

      \[\leadsto \color{blue}{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
    5. Taylor expanded in x.im around -inf

      \[\leadsto e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\mathsf{fma}\left(\log \color{blue}{\left(-1 \cdot x.im\right)}, y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
    6. Step-by-step derivation
      1. lower-*.f6478.9

        \[\leadsto e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\mathsf{fma}\left(\log \left(-1 \cdot \color{blue}{x.im}\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
    7. Applied rewrites78.9%

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

    if -2.6000000000000001e-267 < x.im < 1.35e50

    1. Initial program 50.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. Taylor expanded in y.re around 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.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)} \]
    3. Step-by-step derivation
      1. sin-+PI/2-revN/A

        \[\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 \sin \left(y.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
      2. lower-sin.f64N/A

        \[\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 \sin \left(y.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
      3. lower-fma.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      4. lower-log.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      5. pow1/2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left({x.im}^{2} + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      6. lower-pow.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left({x.im}^{2} + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      7. pow2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(x.im \cdot x.im + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      8. lower-fma.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, {x.re}^{2}\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      9. pow2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      10. lift-*.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      11. lower-/.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      12. lower-PI.f6450.3

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right), \frac{\pi}{2}\right)\right) \]
    4. Applied rewrites50.3%

      \[\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}{\sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right), \frac{\pi}{2}\right)\right)} \]
    5. Taylor expanded in y.im around 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 \sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\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 \sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \]
      2. lift-PI.f6467.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 \sin \left(0.5 \cdot \pi\right) \]
    7. Applied rewrites67.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 \sin \left(0.5 \cdot \pi\right) \]

    if 1.35e50 < x.im

    1. Initial program 23.2%

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
    2. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{\cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \color{blue}{e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      2. lower-cos.f64N/A

        \[\leadsto \cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{\color{blue}{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      3. lower-fma.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{\color{blue}{y.re \cdot \log x.im} - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      4. lower-log.f64N/A

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

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      6. lift-atan2.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      7. exp-diffN/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      8. lower-/.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      9. lower-exp.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{\color{blue}{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      10. lower-*.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{\color{blue}{y.im} \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      11. lower-log.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      12. lower-exp.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    4. Applied rewrites72.3%

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

Alternative 3: 73.1% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_1 := \mathsf{fma}\left(0.5, \pi, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ t_2 := \sin t\_1\\ t_3 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\ t_4 := e^{t\_3 \cdot y.re - t\_0}\\ t_5 := \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\ \mathbf{if}\;t\_4 \cdot \cos \left(t\_3 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \leq 0.9:\\ \;\;\;\;t\_4 \cdot \left(\sin \left(0.5 \cdot \pi\right) - \left(-y.im\right) \cdot \left(\sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right) \cdot \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - t\_0} \cdot \left(t\_2 - \left(-y.im\right) \cdot \mathsf{fma}\left(-0.5, y.im \cdot \left(\left(t\_5 \cdot t\_5\right) \cdot t\_2\right), \cos t\_1 \cdot t\_5\right)\right)\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (let* ((t_0 (* (atan2 x.im x.re) y.im))
        (t_1 (fma 0.5 PI (* y.re (atan2 x.im x.re))))
        (t_2 (sin t_1))
        (t_3 (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
        (t_4 (exp (- (* t_3 y.re) t_0)))
        (t_5 (log (hypot x.im x.re))))
   (if (<= (* t_4 (cos (+ (* t_3 y.im) (* (atan2 x.im x.re) y.re)))) 0.9)
     (*
      t_4
      (-
       (sin (* 0.5 PI))
       (*
        (- y.im)
        (*
         (sin (fma 0.5 PI (/ PI 2.0)))
         (log (pow (fma x.im x.im (* x.re x.re)) 0.5))))))
     (*
      (exp (- (* (log (hypot x.re x.im)) y.re) t_0))
      (-
       t_2
       (*
        (- y.im)
        (fma -0.5 (* y.im (* (* t_5 t_5) t_2)) (* (cos t_1) t_5))))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = atan2(x_46_im, x_46_re) * y_46_im;
	double t_1 = fma(0.5, ((double) M_PI), (y_46_re * atan2(x_46_im, x_46_re)));
	double t_2 = sin(t_1);
	double t_3 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
	double t_4 = exp(((t_3 * y_46_re) - t_0));
	double t_5 = log(hypot(x_46_im, x_46_re));
	double tmp;
	if ((t_4 * cos(((t_3 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)))) <= 0.9) {
		tmp = t_4 * (sin((0.5 * ((double) M_PI))) - (-y_46_im * (sin(fma(0.5, ((double) M_PI), (((double) M_PI) / 2.0))) * log(pow(fma(x_46_im, x_46_im, (x_46_re * x_46_re)), 0.5)))));
	} else {
		tmp = exp(((log(hypot(x_46_re, x_46_im)) * y_46_re) - t_0)) * (t_2 - (-y_46_im * fma(-0.5, (y_46_im * ((t_5 * t_5) * t_2)), (cos(t_1) * t_5))));
	}
	return tmp;
}
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(atan(x_46_im, x_46_re) * y_46_im)
	t_1 = fma(0.5, pi, Float64(y_46_re * atan(x_46_im, x_46_re)))
	t_2 = sin(t_1)
	t_3 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im))))
	t_4 = exp(Float64(Float64(t_3 * y_46_re) - t_0))
	t_5 = log(hypot(x_46_im, x_46_re))
	tmp = 0.0
	if (Float64(t_4 * cos(Float64(Float64(t_3 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) <= 0.9)
		tmp = Float64(t_4 * Float64(sin(Float64(0.5 * pi)) - Float64(Float64(-y_46_im) * Float64(sin(fma(0.5, pi, Float64(pi / 2.0))) * log((fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)) ^ 0.5))))));
	else
		tmp = Float64(exp(Float64(Float64(log(hypot(x_46_re, x_46_im)) * y_46_re) - t_0)) * Float64(t_2 - Float64(Float64(-y_46_im) * fma(-0.5, Float64(y_46_im * Float64(Float64(t_5 * t_5) * t_2)), Float64(cos(t_1) * t_5)))));
	end
	return tmp
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * Pi + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Exp[N[(N[(t$95$3 * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Log[N[Sqrt[x$46$im ^ 2 + x$46$re ^ 2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$4 * N[Cos[N[(N[(t$95$3 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.9], N[(t$95$4 * N[(N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision] - N[((-y$46$im) * N[(N[Sin[N[(0.5 * Pi + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[N[Power[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[(t$95$2 - N[((-y$46$im) * N[(-0.5 * N[(y$46$im * N[(N[(t$95$5 * t$95$5), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[t$95$1], $MachinePrecision] * t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
t_1 := \mathsf{fma}\left(0.5, \pi, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
t_2 := \sin t\_1\\
t_3 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
t_4 := e^{t\_3 \cdot y.re - t\_0}\\
t_5 := \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\\
\mathbf{if}\;t\_4 \cdot \cos \left(t\_3 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \leq 0.9:\\
\;\;\;\;t\_4 \cdot \left(\sin \left(0.5 \cdot \pi\right) - \left(-y.im\right) \cdot \left(\sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right) \cdot \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - t\_0} \cdot \left(t\_2 - \left(-y.im\right) \cdot \mathsf{fma}\left(-0.5, y.im \cdot \left(\left(t\_5 \cdot t\_5\right) \cdot t\_2\right), \cos t\_1 \cdot t\_5\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) < 0.900000000000000022

    1. Initial program 78.3%

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
    2. Taylor expanded in y.re around 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.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)} \]
    3. Step-by-step derivation
      1. sin-+PI/2-revN/A

        \[\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 \sin \left(y.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
      2. lower-sin.f64N/A

        \[\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 \sin \left(y.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
      3. lower-fma.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      4. lower-log.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      5. pow1/2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left({x.im}^{2} + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      6. lower-pow.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left({x.im}^{2} + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      7. pow2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(x.im \cdot x.im + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      8. lower-fma.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, {x.re}^{2}\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      9. pow2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      10. lift-*.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      11. lower-/.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      12. lower-PI.f6479.6

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right), \frac{\pi}{2}\right)\right) \]
    4. Applied rewrites79.6%

      \[\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}{\sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right), \frac{\pi}{2}\right)\right)} \]
    5. Taylor expanded in y.im around 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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) + \color{blue}{y.im \cdot \left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. fp-cancel-sign-sub-invN/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)}\right) \]
      2. lower--.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)}\right) \]
      3. lower-sin.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \left(\color{blue}{\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)} \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)\right) \]
      4. lower-*.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \left(\cos \color{blue}{\left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)} \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)\right) \]
      5. lift-PI.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \pi\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)\right) \]
      6. lower-*.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \pi\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)}\right)\right) \]
      7. lift-neg.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \pi\right) - \left(-y.im\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \color{blue}{\left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)}\right)\right) \]
      8. lower-*.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \pi\right) - \left(-y.im\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)\right) \]
    7. Applied rewrites80.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 \left(\sin \left(0.5 \cdot \pi\right) - \color{blue}{\left(-y.im\right) \cdot \left(\sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right) \cdot \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right)\right)}\right) \]

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

    1. Initial program 25.0%

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

      \[\leadsto \color{blue}{\frac{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right)} \]
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      2. lift-exp.f64N/A

        \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{e^{\color{blue}{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re}}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      4. lift-log.f64N/A

        \[\leadsto \frac{e^{\color{blue}{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)} \cdot y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      5. lift-hypot.f64N/A

        \[\leadsto \frac{e^{\log \color{blue}{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)} \cdot y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      6. lift-exp.f64N/A

        \[\leadsto \frac{e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re}}{\color{blue}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
      7. div-expN/A

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

      \[\leadsto \color{blue}{e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) + \frac{\pi}{2}\right) \]
    5. Taylor expanded in y.im around 0

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

      \[\leadsto e^{\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \color{blue}{\left(\sin \left(\mathsf{fma}\left(0.5, \pi, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) - \left(-y.im\right) \cdot \mathsf{fma}\left(-0.5, y.im \cdot \left(\left(\log \left(\mathsf{hypot}\left(x.im, x.re\right)\right) \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right) \cdot \sin \left(\mathsf{fma}\left(0.5, \pi, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)\right), \cos \left(\mathsf{fma}\left(0.5, \pi, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \log \left(\mathsf{hypot}\left(x.im, x.re\right)\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 66.7% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ \mathbf{if}\;x.im \leq -4.8 \cdot 10^{+169}:\\ \;\;\;\;\sin \left(\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.im}\right)}^{y.im}\right), t\_0\right) + \frac{\pi}{2}\right) \cdot e^{\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.im}\right)}^{y.re}\right), \left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\ \mathbf{elif}\;x.im \leq 1.35 \cdot 10^{+50}:\\ \;\;\;\;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 \sin \left(0.5 \cdot \pi\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.im, t\_0\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.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))))
   (if (<= x.im -4.8e+169)
     (*
      (sin (+ (fma -1.0 (log (pow (/ -1.0 x.im) y.im)) t_0) (/ PI 2.0)))
      (exp
       (fma
        -1.0
        (log (pow (/ -1.0 x.im) y.re))
        (* (- y.im) (atan2 x.im x.re)))))
     (if (<= x.im 1.35e+50)
       (*
        (exp
         (-
          (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
          (* (atan2 x.im x.re) y.im)))
        (sin (* 0.5 PI)))
       (*
        (cos (fma y.im (log x.im) t_0))
        (/ (exp (* y.re (log x.im))) (exp (* y.im (atan2 x.im x.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 tmp;
	if (x_46_im <= -4.8e+169) {
		tmp = sin((fma(-1.0, log(pow((-1.0 / x_46_im), y_46_im)), t_0) + (((double) M_PI) / 2.0))) * exp(fma(-1.0, log(pow((-1.0 / x_46_im), y_46_re)), (-y_46_im * atan2(x_46_im, x_46_re))));
	} else if (x_46_im <= 1.35e+50) {
		tmp = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * sin((0.5 * ((double) M_PI)));
	} else {
		tmp = cos(fma(y_46_im, log(x_46_im), t_0)) * (exp((y_46_re * log(x_46_im))) / exp((y_46_im * atan2(x_46_im, x_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))
	tmp = 0.0
	if (x_46_im <= -4.8e+169)
		tmp = Float64(sin(Float64(fma(-1.0, log((Float64(-1.0 / x_46_im) ^ y_46_im)), t_0) + Float64(pi / 2.0))) * exp(fma(-1.0, log((Float64(-1.0 / x_46_im) ^ y_46_re)), Float64(Float64(-y_46_im) * atan(x_46_im, x_46_re)))));
	elseif (x_46_im <= 1.35e+50)
		tmp = Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * sin(Float64(0.5 * pi)));
	else
		tmp = Float64(cos(fma(y_46_im, log(x_46_im), t_0)) * Float64(exp(Float64(y_46_re * log(x_46_im))) / exp(Float64(y_46_im * atan(x_46_im, x_46_re)))));
	end
	return 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]}, If[LessEqual[x$46$im, -4.8e+169], N[(N[Sin[N[(N[(-1.0 * N[Log[N[Power[N[(-1.0 / x$46$im), $MachinePrecision], y$46$im], $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(-1.0 * N[Log[N[Power[N[(-1.0 / x$46$im), $MachinePrecision], y$46$re], $MachinePrecision]], $MachinePrecision] + N[((-y$46$im) * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 1.35e+50], N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] * N[(N[Exp[N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.im \leq -4.8 \cdot 10^{+169}:\\
\;\;\;\;\sin \left(\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.im}\right)}^{y.im}\right), t\_0\right) + \frac{\pi}{2}\right) \cdot e^{\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.im}\right)}^{y.re}\right), \left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\

\mathbf{elif}\;x.im \leq 1.35 \cdot 10^{+50}:\\
\;\;\;\;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 \sin \left(0.5 \cdot \pi\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.im < -4.7999999999999997e169

    1. Initial program 0.0%

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
    2. Taylor expanded in x.im around -inf

      \[\leadsto \color{blue}{\cos \left(-1 \cdot \left(y.im \cdot \log \left(\frac{-1}{x.im}\right)\right) + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.im}\right)\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

    if -4.7999999999999997e169 < x.im < 1.35e50

    1. Initial program 51.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. Taylor expanded in y.re around 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.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)} \]
    3. Step-by-step derivation
      1. sin-+PI/2-revN/A

        \[\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 \sin \left(y.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
      2. lower-sin.f64N/A

        \[\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 \sin \left(y.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
      3. lower-fma.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      4. lower-log.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      5. pow1/2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left({x.im}^{2} + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      6. lower-pow.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left({x.im}^{2} + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      7. pow2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(x.im \cdot x.im + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      8. lower-fma.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, {x.re}^{2}\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      9. pow2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      10. lift-*.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      11. lower-/.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      12. lower-PI.f6452.3

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right), \frac{\pi}{2}\right)\right) \]
    4. Applied rewrites52.3%

      \[\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}{\sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right), \frac{\pi}{2}\right)\right)} \]
    5. Taylor expanded in y.im around 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 \sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\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 \sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \]
      2. lift-PI.f6468.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 \sin \left(0.5 \cdot \pi\right) \]
    7. Applied rewrites68.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 \sin \left(0.5 \cdot \pi\right) \]

    if 1.35e50 < x.im

    1. Initial program 23.2%

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
    2. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{\cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \color{blue}{e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      2. lower-cos.f64N/A

        \[\leadsto \cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{\color{blue}{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      3. lower-fma.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{\color{blue}{y.re \cdot \log x.im} - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      4. lower-log.f64N/A

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

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      6. lift-atan2.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      7. exp-diffN/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      8. lower-/.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      9. lower-exp.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{\color{blue}{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      10. lower-*.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{\color{blue}{y.im} \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      11. lower-log.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      12. lower-exp.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    4. Applied rewrites72.3%

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

Alternative 5: 60.6% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ \mathbf{if}\;x.re \leq -1.9 \cdot 10^{+145}:\\ \;\;\;\;\sin \left(\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.re}\right)}^{y.im}\right), t\_0\right) + \frac{\pi}{2}\right) \cdot e^{\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.re}\right)}^{y.re}\right), \left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\ \mathbf{elif}\;x.re \leq 6.5 \cdot 10^{-9}:\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(\sin \left(0.5 \cdot \pi\right) - \left(-y.im\right) \cdot \left(\sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right) \cdot \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.re, t\_0\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.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))))
   (if (<= x.re -1.9e+145)
     (*
      (sin (+ (fma -1.0 (log (pow (/ -1.0 x.re) y.im)) t_0) (/ PI 2.0)))
      (exp
       (fma
        -1.0
        (log (pow (/ -1.0 x.re) y.re))
        (* (- y.im) (atan2 x.im x.re)))))
     (if (<= x.re 6.5e-9)
       (*
        (exp
         (-
          (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
          (* (atan2 x.im x.re) y.im)))
        (-
         (sin (* 0.5 PI))
         (*
          (- y.im)
          (*
           (sin (fma 0.5 PI (/ PI 2.0)))
           (log (pow (fma x.im x.im (* x.re x.re)) 0.5))))))
       (*
        (cos (fma y.im (log x.re) t_0))
        (/ (exp (* y.re (log x.re))) (exp (* y.im (atan2 x.im x.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 tmp;
	if (x_46_re <= -1.9e+145) {
		tmp = sin((fma(-1.0, log(pow((-1.0 / x_46_re), y_46_im)), t_0) + (((double) M_PI) / 2.0))) * exp(fma(-1.0, log(pow((-1.0 / x_46_re), y_46_re)), (-y_46_im * atan2(x_46_im, x_46_re))));
	} else if (x_46_re <= 6.5e-9) {
		tmp = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * (sin((0.5 * ((double) M_PI))) - (-y_46_im * (sin(fma(0.5, ((double) M_PI), (((double) M_PI) / 2.0))) * log(pow(fma(x_46_im, x_46_im, (x_46_re * x_46_re)), 0.5)))));
	} else {
		tmp = cos(fma(y_46_im, log(x_46_re), t_0)) * (exp((y_46_re * log(x_46_re))) / exp((y_46_im * atan2(x_46_im, x_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))
	tmp = 0.0
	if (x_46_re <= -1.9e+145)
		tmp = Float64(sin(Float64(fma(-1.0, log((Float64(-1.0 / x_46_re) ^ y_46_im)), t_0) + Float64(pi / 2.0))) * exp(fma(-1.0, log((Float64(-1.0 / x_46_re) ^ y_46_re)), Float64(Float64(-y_46_im) * atan(x_46_im, x_46_re)))));
	elseif (x_46_re <= 6.5e-9)
		tmp = Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * Float64(sin(Float64(0.5 * pi)) - Float64(Float64(-y_46_im) * Float64(sin(fma(0.5, pi, Float64(pi / 2.0))) * log((fma(x_46_im, x_46_im, Float64(x_46_re * x_46_re)) ^ 0.5))))));
	else
		tmp = Float64(cos(fma(y_46_im, log(x_46_re), t_0)) * Float64(exp(Float64(y_46_re * log(x_46_re))) / exp(Float64(y_46_im * atan(x_46_im, x_46_re)))));
	end
	return 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]}, If[LessEqual[x$46$re, -1.9e+145], N[(N[Sin[N[(N[(-1.0 * N[Log[N[Power[N[(-1.0 / x$46$re), $MachinePrecision], y$46$im], $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(-1.0 * N[Log[N[Power[N[(-1.0 / x$46$re), $MachinePrecision], y$46$re], $MachinePrecision]], $MachinePrecision] + N[((-y$46$im) * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 6.5e-9], N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision] - N[((-y$46$im) * N[(N[Sin[N[(0.5 * Pi + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Log[N[Power[N[(x$46$im * x$46$im + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$re], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] * N[(N[Exp[N[(y$46$re * N[Log[x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.re \leq -1.9 \cdot 10^{+145}:\\
\;\;\;\;\sin \left(\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.re}\right)}^{y.im}\right), t\_0\right) + \frac{\pi}{2}\right) \cdot e^{\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.re}\right)}^{y.re}\right), \left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\

\mathbf{elif}\;x.re \leq 6.5 \cdot 10^{-9}:\\
\;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(\sin \left(0.5 \cdot \pi\right) - \left(-y.im\right) \cdot \left(\sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right) \cdot \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x.re < -1.90000000000000006e145

    1. Initial program 2.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. Taylor expanded in x.re around -inf

      \[\leadsto \color{blue}{\cos \left(-1 \cdot \left(y.im \cdot \log \left(\frac{-1}{x.re}\right)\right) + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.re}\right)\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

    if -1.90000000000000006e145 < x.re < 6.5000000000000003e-9

    1. Initial program 53.5%

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
    2. Taylor expanded in y.re around 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.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)} \]
    3. Step-by-step derivation
      1. sin-+PI/2-revN/A

        \[\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 \sin \left(y.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
      2. lower-sin.f64N/A

        \[\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 \sin \left(y.im \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
      3. lower-fma.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      4. lower-log.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      5. pow1/2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left({x.im}^{2} + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      6. lower-pow.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left({x.im}^{2} + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      7. pow2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(x.im \cdot x.im + {x.re}^{2}\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      8. lower-fma.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, {x.re}^{2}\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      9. pow2N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      10. lift-*.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      11. lower-/.f64N/A

        \[\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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{\frac{1}{2}}\right), \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \]
      12. lower-PI.f6453.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 \sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right), \frac{\pi}{2}\right)\right) \]
    4. Applied rewrites53.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}{\sin \left(\mathsf{fma}\left(y.im, \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right), \frac{\pi}{2}\right)\right)} \]
    5. Taylor expanded in y.im around 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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) + \color{blue}{y.im \cdot \left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)}\right) \]
    6. Step-by-step derivation
      1. fp-cancel-sign-sub-invN/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)}\right) \]
      2. lower--.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \color{blue}{\left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)}\right) \]
      3. lower-sin.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \left(\color{blue}{\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)} \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)\right) \]
      4. lower-*.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \left(\cos \color{blue}{\left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)} \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)\right) \]
      5. lift-PI.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \pi\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)\right) \]
      6. lower-*.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \pi\right) - \left(\mathsf{neg}\left(y.im\right)\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)}\right)\right) \]
      7. lift-neg.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \pi\right) - \left(-y.im\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \color{blue}{\left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)}\right)\right) \]
      8. lower-*.f64N/A

        \[\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 \left(\sin \left(\frac{1}{2} \cdot \pi\right) - \left(-y.im\right) \cdot \left(\cos \left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\sqrt{{x.im}^{2} + {x.re}^{2}}\right)\right)\right) \]
    7. Applied rewrites59.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 \left(\sin \left(0.5 \cdot \pi\right) - \color{blue}{\left(-y.im\right) \cdot \left(\sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right) \cdot \log \left({\left(\mathsf{fma}\left(x.im, x.im, x.re \cdot x.re\right)\right)}^{0.5}\right)\right)}\right) \]

    if 6.5000000000000003e-9 < x.re

    1. Initial program 29.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. Taylor expanded in x.im around 0

      \[\leadsto \color{blue}{\cos \left(y.im \cdot \log x.re + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \cos \left(y.im \cdot \log x.re + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \color{blue}{e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      2. lower-cos.f64N/A

        \[\leadsto \cos \left(y.im \cdot \log x.re + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{\color{blue}{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      3. lower-fma.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{\color{blue}{y.re \cdot \log x.re} - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      4. lower-log.f64N/A

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

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      6. lift-atan2.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      7. exp-diffN/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      8. lower-/.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      9. lower-exp.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{e^{\color{blue}{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      10. lower-*.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{e^{\color{blue}{y.im} \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      11. lower-log.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      12. lower-exp.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    4. Applied rewrites72.9%

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

Alternative 6: 50.3% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\ \mathbf{if}\;x.im \leq -2 \cdot 10^{-308}:\\ \;\;\;\;\sin \left(\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.im}\right)}^{y.im}\right), t\_0\right) + \frac{\pi}{2}\right) \cdot e^{\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.im}\right)}^{y.re}\right), \left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.im, t\_0\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.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))))
   (if (<= x.im -2e-308)
     (*
      (sin (+ (fma -1.0 (log (pow (/ -1.0 x.im) y.im)) t_0) (/ PI 2.0)))
      (exp
       (fma
        -1.0
        (log (pow (/ -1.0 x.im) y.re))
        (* (- y.im) (atan2 x.im x.re)))))
     (*
      (cos (fma y.im (log x.im) t_0))
      (/ (exp (* y.re (log x.im))) (exp (* y.im (atan2 x.im x.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 tmp;
	if (x_46_im <= -2e-308) {
		tmp = sin((fma(-1.0, log(pow((-1.0 / x_46_im), y_46_im)), t_0) + (((double) M_PI) / 2.0))) * exp(fma(-1.0, log(pow((-1.0 / x_46_im), y_46_re)), (-y_46_im * atan2(x_46_im, x_46_re))));
	} else {
		tmp = cos(fma(y_46_im, log(x_46_im), t_0)) * (exp((y_46_re * log(x_46_im))) / exp((y_46_im * atan2(x_46_im, x_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))
	tmp = 0.0
	if (x_46_im <= -2e-308)
		tmp = Float64(sin(Float64(fma(-1.0, log((Float64(-1.0 / x_46_im) ^ y_46_im)), t_0) + Float64(pi / 2.0))) * exp(fma(-1.0, log((Float64(-1.0 / x_46_im) ^ y_46_re)), Float64(Float64(-y_46_im) * atan(x_46_im, x_46_re)))));
	else
		tmp = Float64(cos(fma(y_46_im, log(x_46_im), t_0)) * Float64(exp(Float64(y_46_re * log(x_46_im))) / exp(Float64(y_46_im * atan(x_46_im, x_46_re)))));
	end
	return 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]}, If[LessEqual[x$46$im, -2e-308], N[(N[Sin[N[(N[(-1.0 * N[Log[N[Power[N[(-1.0 / x$46$im), $MachinePrecision], y$46$im], $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(-1.0 * N[Log[N[Power[N[(-1.0 / x$46$im), $MachinePrecision], y$46$re], $MachinePrecision]], $MachinePrecision] + N[((-y$46$im) * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(y$46$im * N[Log[x$46$im], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] * N[(N[Exp[N[(y$46$re * N[Log[x$46$im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(y$46$im * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
\mathbf{if}\;x.im \leq -2 \cdot 10^{-308}:\\
\;\;\;\;\sin \left(\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.im}\right)}^{y.im}\right), t\_0\right) + \frac{\pi}{2}\right) \cdot e^{\mathsf{fma}\left(-1, \log \left({\left(\frac{-1}{x.im}\right)}^{y.re}\right), \left(-y.im\right) \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\\

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


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

    1. Initial program 40.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. Taylor expanded in x.im around -inf

      \[\leadsto \color{blue}{\cos \left(-1 \cdot \left(y.im \cdot \log \left(\frac{-1}{x.im}\right)\right) + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{-1 \cdot \left(y.re \cdot \log \left(\frac{-1}{x.im}\right)\right) - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

    if -1.9999999999999998e-308 < x.im

    1. Initial program 39.7%

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
    2. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{\cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \color{blue}{e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      2. lower-cos.f64N/A

        \[\leadsto \cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{\color{blue}{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      3. lower-fma.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{\color{blue}{y.re \cdot \log x.im} - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      4. lower-log.f64N/A

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

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      6. lift-atan2.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      7. exp-diffN/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      8. lower-/.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      9. lower-exp.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{\color{blue}{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      10. lower-*.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{\color{blue}{y.im} \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      11. lower-log.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      12. lower-exp.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    4. Applied rewrites62.7%

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

Alternative 7: 48.6% accurate, N/A× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\cos \left(\mathsf{fma}\left(y.im, \log x.re, t\_1\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.re < 1.69999999999999999e-282

    1. Initial program 40.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. Taylor expanded in x.re around 0

      \[\leadsto \color{blue}{\cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \color{blue}{e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      2. lower-cos.f64N/A

        \[\leadsto \cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{\color{blue}{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      3. lower-fma.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{\color{blue}{y.re \cdot \log x.im} - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      4. lower-log.f64N/A

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

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      6. lift-atan2.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      7. exp-diffN/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      8. lower-/.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      9. lower-exp.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{\color{blue}{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      10. lower-*.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{\color{blue}{y.im} \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      11. lower-log.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      12. lower-exp.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    4. Applied rewrites31.9%

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

    if 1.69999999999999999e-282 < x.re

    1. Initial program 39.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. Taylor expanded in x.im around 0

      \[\leadsto \color{blue}{\cos \left(y.im \cdot \log x.re + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \cos \left(y.im \cdot \log x.re + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \color{blue}{e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      2. lower-cos.f64N/A

        \[\leadsto \cos \left(y.im \cdot \log x.re + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{\color{blue}{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      3. lower-fma.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{\color{blue}{y.re \cdot \log x.re} - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      4. lower-log.f64N/A

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

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      6. lift-atan2.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.re - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
      7. exp-diffN/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      8. lower-/.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      9. lower-exp.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{e^{\color{blue}{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
      10. lower-*.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{e^{\color{blue}{y.im} \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      11. lower-log.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
      12. lower-exp.f64N/A

        \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.re, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.re}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    4. Applied rewrites67.0%

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

Alternative 8: 31.3% accurate, N/A× speedup?

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

\\
\cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}
\end{array}
Derivation
  1. Initial program 40.1%

    \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \]
  2. Taylor expanded in x.re around 0

    \[\leadsto \color{blue}{\cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot \color{blue}{e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    2. lower-cos.f64N/A

      \[\leadsto \cos \left(y.im \cdot \log x.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{\color{blue}{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    3. lower-fma.f64N/A

      \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{\color{blue}{y.re \cdot \log x.im} - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
    4. lower-log.f64N/A

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

      \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
    6. lift-atan2.f64N/A

      \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot e^{y.re \cdot \log x.im - y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}} \]
    7. exp-diffN/A

      \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
    8. lower-/.f64N/A

      \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{\color{blue}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
    9. lower-exp.f64N/A

      \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{\color{blue}{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}}} \]
    10. lower-*.f64N/A

      \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{\color{blue}{y.im} \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    11. lower-log.f64N/A

      \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
    12. lower-exp.f64N/A

      \[\leadsto \cos \left(\mathsf{fma}\left(y.im, \log x.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot \frac{e^{y.re \cdot \log x.im}}{e^{y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}}} \]
  4. Applied rewrites31.3%

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

Reproduce

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