math.sin on complex, imaginary part

Percentage Accurate: 54.4% → 99.3%
Time: 13.9s
Alternatives: 18
Speedup: 17.2×

Specification

?
\[\begin{array}{l} \\ \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
	return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im):
	return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 18 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: 54.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
	return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im):
	return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}

Alternative 1: 99.3% accurate, 0.6× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := e^{0 - im\_m} - e^{im\_m}\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;t\_0 \cdot \left(0.5 \cdot \cos re\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\right)\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (- (exp (- 0.0 im_m)) (exp im_m))))
   (*
    im_s
    (if (<= t_0 (- INFINITY))
      (* t_0 (* 0.5 (cos re)))
      (* (cos re) (* im_m (+ -1.0 (* (* im_m im_m) -0.16666666666666666))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = exp((0.0 - im_m)) - exp(im_m);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = t_0 * (0.5 * cos(re));
	} else {
		tmp = cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = Math.exp((0.0 - im_m)) - Math.exp(im_m);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = t_0 * (0.5 * Math.cos(re));
	} else {
		tmp = Math.cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = math.exp((0.0 - im_m)) - math.exp(im_m)
	tmp = 0
	if t_0 <= -math.inf:
		tmp = t_0 * (0.5 * math.cos(re))
	else:
		tmp = math.cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(exp(Float64(0.0 - im_m)) - exp(im_m))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(t_0 * Float64(0.5 * cos(re)));
	else
		tmp = Float64(cos(re) * Float64(im_m * Float64(-1.0 + Float64(Float64(im_m * im_m) * -0.16666666666666666))));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	t_0 = exp((0.0 - im_m)) - exp(im_m);
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = t_0 * (0.5 * cos(re));
	else
		tmp = cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(N[Exp[N[(0.0 - im$95$m), $MachinePrecision]], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[t$95$0, (-Infinity)], N[(t$95$0 * N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(-1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := e^{0 - im\_m} - e^{im\_m}\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_0 \cdot \left(0.5 \cdot \cos re\right)\\

\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\right)\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im)) < -inf.0

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing

    if -inf.0 < (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))

    1. Initial program 32.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified95.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in im around 0

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right) + \color{blue}{-1 \cdot \cos re}\right) \]
      2. *-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \left(\cos re \cdot {im}^{2}\right) + -1 \cdot \cos re\right) \]
      3. associate-*r*N/A

        \[\leadsto im \cdot \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2} + \color{blue}{-1} \cdot \cos re\right) \]
      4. distribute-lft-inN/A

        \[\leadsto im \cdot \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right) + \color{blue}{im \cdot \left(-1 \cdot \cos re\right)} \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right) \cdot im + \color{blue}{im} \cdot \left(-1 \cdot \cos re\right) \]
      6. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{6} \cdot \left(\cos re \cdot {im}^{2}\right)\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      7. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      8. associate-*r*N/A

        \[\leadsto \left(\left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \cos re\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      9. associate-*l*N/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(\cos re \cdot im\right) + \color{blue}{im} \cdot \left(-1 \cdot \cos re\right) \]
      10. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + im \cdot \left(-1 \cdot \cos re\right) \]
      11. mul-1-negN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + im \cdot \left(\mathsf{neg}\left(\cos re\right)\right) \]
      12. distribute-rgt-neg-inN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + \left(\mathsf{neg}\left(im \cdot \cos re\right)\right) \]
      13. mul-1-negN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + -1 \cdot \color{blue}{\left(im \cdot \cos re\right)} \]
      14. distribute-rgt-outN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \color{blue}{\left(\frac{-1}{6} \cdot {im}^{2} + -1\right)} \]
      15. metadata-evalN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \left(\frac{-1}{6} \cdot {im}^{2} + \left(\mathsf{neg}\left(1\right)\right)\right) \]
      16. sub-negN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \left(\frac{-1}{6} \cdot {im}^{2} - \color{blue}{1}\right) \]
    8. Simplified90.5%

      \[\leadsto \color{blue}{\left(im \cdot \cos re\right) \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot \color{blue}{\left(im \cdot \cos re\right)} \]
      2. associate-*r*N/A

        \[\leadsto \left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot im\right) \cdot \color{blue}{\cos re} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot im\right), \color{blue}{\cos re}\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right), im\right), \cos \color{blue}{re}\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \left(\left(im \cdot im\right) \cdot \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      8. cos-lowering-cos.f6490.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right), im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    10. Applied egg-rr90.5%

      \[\leadsto \color{blue}{\left(\left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right) \cdot im\right) \cdot \cos re} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{0 - im} - e^{im} \leq -\infty:\\ \;\;\;\;\left(e^{0 - im} - e^{im}\right) \cdot \left(0.5 \cdot \cos re\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(im \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 97.9% accurate, 1.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 0.031:\\ \;\;\;\;\cos re \cdot \left(im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im\_m \leq 3.35 \cdot 10^{+44}:\\ \;\;\;\;\left(e^{0 - im\_m} - e^{im\_m}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im\_m \cdot \left(-2 + \left(im\_m \cdot im\_m\right) \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 0.031)
    (* (cos re) (* im_m (+ -1.0 (* (* im_m im_m) -0.16666666666666666))))
    (if (<= im_m 3.35e+44)
      (* (- (exp (- 0.0 im_m)) (exp im_m)) (+ 0.5 (* -0.25 (* re re))))
      (*
       (* 0.5 (cos re))
       (*
        im_m
        (+
         -2.0
         (*
          (* im_m im_m)
          (+
           -0.3333333333333333
           (*
            im_m
            (*
             im_m
             (+
              -0.016666666666666666
              (* (* im_m im_m) -0.0003968253968253968)))))))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 0.031) {
		tmp = cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	} else if (im_m <= 3.35e+44) {
		tmp = (exp((0.0 - im_m)) - exp(im_m)) * (0.5 + (-0.25 * (re * re)));
	} else {
		tmp = (0.5 * cos(re)) * (im_m * (-2.0 + ((im_m * im_m) * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))));
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 0.031d0) then
        tmp = cos(re) * (im_m * ((-1.0d0) + ((im_m * im_m) * (-0.16666666666666666d0))))
    else if (im_m <= 3.35d+44) then
        tmp = (exp((0.0d0 - im_m)) - exp(im_m)) * (0.5d0 + ((-0.25d0) * (re * re)))
    else
        tmp = (0.5d0 * cos(re)) * (im_m * ((-2.0d0) + ((im_m * im_m) * ((-0.3333333333333333d0) + (im_m * (im_m * ((-0.016666666666666666d0) + ((im_m * im_m) * (-0.0003968253968253968d0)))))))))
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 0.031) {
		tmp = Math.cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	} else if (im_m <= 3.35e+44) {
		tmp = (Math.exp((0.0 - im_m)) - Math.exp(im_m)) * (0.5 + (-0.25 * (re * re)));
	} else {
		tmp = (0.5 * Math.cos(re)) * (im_m * (-2.0 + ((im_m * im_m) * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 0.031:
		tmp = math.cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)))
	elif im_m <= 3.35e+44:
		tmp = (math.exp((0.0 - im_m)) - math.exp(im_m)) * (0.5 + (-0.25 * (re * re)))
	else:
		tmp = (0.5 * math.cos(re)) * (im_m * (-2.0 + ((im_m * im_m) * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 0.031)
		tmp = Float64(cos(re) * Float64(im_m * Float64(-1.0 + Float64(Float64(im_m * im_m) * -0.16666666666666666))));
	elseif (im_m <= 3.35e+44)
		tmp = Float64(Float64(exp(Float64(0.0 - im_m)) - exp(im_m)) * Float64(0.5 + Float64(-0.25 * Float64(re * re))));
	else
		tmp = Float64(Float64(0.5 * cos(re)) * Float64(im_m * Float64(-2.0 + Float64(Float64(im_m * im_m) * Float64(-0.3333333333333333 + Float64(im_m * Float64(im_m * Float64(-0.016666666666666666 + Float64(Float64(im_m * im_m) * -0.0003968253968253968)))))))));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 0.031)
		tmp = cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	elseif (im_m <= 3.35e+44)
		tmp = (exp((0.0 - im_m)) - exp(im_m)) * (0.5 + (-0.25 * (re * re)));
	else
		tmp = (0.5 * cos(re)) * (im_m * (-2.0 + ((im_m * im_m) * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))));
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 0.031], N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(-1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 3.35e+44], N[(N[(N[Exp[N[(0.0 - im$95$m), $MachinePrecision]], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(im$95$m * N[(-2.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(-0.3333333333333333 + N[(im$95$m * N[(im$95$m * N[(-0.016666666666666666 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 0.031:\\
\;\;\;\;\cos re \cdot \left(im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\right)\\

\mathbf{elif}\;im\_m \leq 3.35 \cdot 10^{+44}:\\
\;\;\;\;\left(e^{0 - im\_m} - e^{im\_m}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im\_m \cdot \left(-2 + \left(im\_m \cdot im\_m\right) \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 0.031

    1. Initial program 32.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified95.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in im around 0

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right) + \color{blue}{-1 \cdot \cos re}\right) \]
      2. *-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \left(\cos re \cdot {im}^{2}\right) + -1 \cdot \cos re\right) \]
      3. associate-*r*N/A

        \[\leadsto im \cdot \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2} + \color{blue}{-1} \cdot \cos re\right) \]
      4. distribute-lft-inN/A

        \[\leadsto im \cdot \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right) + \color{blue}{im \cdot \left(-1 \cdot \cos re\right)} \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right) \cdot im + \color{blue}{im} \cdot \left(-1 \cdot \cos re\right) \]
      6. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{6} \cdot \left(\cos re \cdot {im}^{2}\right)\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      7. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      8. associate-*r*N/A

        \[\leadsto \left(\left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \cos re\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      9. associate-*l*N/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(\cos re \cdot im\right) + \color{blue}{im} \cdot \left(-1 \cdot \cos re\right) \]
      10. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + im \cdot \left(-1 \cdot \cos re\right) \]
      11. mul-1-negN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + im \cdot \left(\mathsf{neg}\left(\cos re\right)\right) \]
      12. distribute-rgt-neg-inN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + \left(\mathsf{neg}\left(im \cdot \cos re\right)\right) \]
      13. mul-1-negN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + -1 \cdot \color{blue}{\left(im \cdot \cos re\right)} \]
      14. distribute-rgt-outN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \color{blue}{\left(\frac{-1}{6} \cdot {im}^{2} + -1\right)} \]
      15. metadata-evalN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \left(\frac{-1}{6} \cdot {im}^{2} + \left(\mathsf{neg}\left(1\right)\right)\right) \]
      16. sub-negN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \left(\frac{-1}{6} \cdot {im}^{2} - \color{blue}{1}\right) \]
    8. Simplified90.5%

      \[\leadsto \color{blue}{\left(im \cdot \cos re\right) \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot \color{blue}{\left(im \cdot \cos re\right)} \]
      2. associate-*r*N/A

        \[\leadsto \left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot im\right) \cdot \color{blue}{\cos re} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot im\right), \color{blue}{\cos re}\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right), im\right), \cos \color{blue}{re}\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \left(\left(im \cdot im\right) \cdot \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      8. cos-lowering-cos.f6490.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right), im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    10. Applied egg-rr90.5%

      \[\leadsto \color{blue}{\left(\left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right) \cdot im\right) \cdot \cos re} \]

    if 0.031 < im < 3.35000000000000018e44

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0

      \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left({re}^{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)\right) + \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) + \color{blue}{\frac{-1}{4} \cdot \left({re}^{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)\right)} \]
      2. associate-*r*N/A

        \[\leadsto \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) + \left(\frac{-1}{4} \cdot {re}^{2}\right) \cdot \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
      3. distribute-rgt-outN/A

        \[\leadsto \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right), \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\left(e^{\mathsf{neg}\left(im\right)}\right), \left(e^{im}\right)\right), \left(\color{blue}{\frac{1}{2}} + \frac{-1}{4} \cdot {re}^{2}\right)\right) \]
      6. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{exp.f64}\left(\left(\mathsf{neg}\left(im\right)\right)\right), \left(e^{im}\right)\right), \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right) \]
      7. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{exp.f64}\left(\left(0 - im\right)\right), \left(e^{im}\right)\right), \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, im\right)\right), \left(e^{im}\right)\right), \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right) \]
      9. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, im\right)\right), \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, im\right)\right), \mathsf{exp.f64}\left(im\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{-1}{4} \cdot {re}^{2}\right)}\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, im\right)\right), \mathsf{exp.f64}\left(im\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \color{blue}{\left({re}^{2}\right)}\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, im\right)\right), \mathsf{exp.f64}\left(im\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left(re \cdot \color{blue}{re}\right)\right)\right)\right) \]
      13. *-lowering-*.f6487.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, im\right)\right), \mathsf{exp.f64}\left(im\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right)\right) \]
    5. Simplified87.5%

      \[\leadsto \color{blue}{\left(e^{0 - im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]

    if 3.35000000000000018e44 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification92.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.031:\\ \;\;\;\;\cos re \cdot \left(im \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 3.35 \cdot 10^{+44}:\\ \;\;\;\;\left(e^{0 - im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 96.0% accurate, 2.3× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := -0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\\ t_1 := im\_m \cdot \left(im\_m \cdot t\_0\right)\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 680:\\ \;\;\;\;\cos re \cdot \left(im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im\_m \leq 3.35 \cdot 10^{+44}:\\ \;\;\;\;\frac{\left(im\_m \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(4 - t\_1 \cdot t\_1\right)}{-2 - t\_1}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im\_m \cdot \left(-2 + \left(im\_m \cdot im\_m\right) \cdot t\_0\right)\right)\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0
         (+
          -0.3333333333333333
          (*
           im_m
           (*
            im_m
            (+
             -0.016666666666666666
             (* (* im_m im_m) -0.0003968253968253968))))))
        (t_1 (* im_m (* im_m t_0))))
   (*
    im_s
    (if (<= im_m 680.0)
      (* (cos re) (* im_m (+ -1.0 (* (* im_m im_m) -0.16666666666666666))))
      (if (<= im_m 3.35e+44)
        (/
         (* (* im_m (+ 0.5 (* re (* re -0.25)))) (- 4.0 (* t_1 t_1)))
         (- -2.0 t_1))
        (* (* 0.5 (cos re)) (* im_m (+ -2.0 (* (* im_m im_m) t_0)))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = -0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))));
	double t_1 = im_m * (im_m * t_0);
	double tmp;
	if (im_m <= 680.0) {
		tmp = cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	} else if (im_m <= 3.35e+44) {
		tmp = ((im_m * (0.5 + (re * (re * -0.25)))) * (4.0 - (t_1 * t_1))) / (-2.0 - t_1);
	} else {
		tmp = (0.5 * cos(re)) * (im_m * (-2.0 + ((im_m * im_m) * t_0)));
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (-0.3333333333333333d0) + (im_m * (im_m * ((-0.016666666666666666d0) + ((im_m * im_m) * (-0.0003968253968253968d0)))))
    t_1 = im_m * (im_m * t_0)
    if (im_m <= 680.0d0) then
        tmp = cos(re) * (im_m * ((-1.0d0) + ((im_m * im_m) * (-0.16666666666666666d0))))
    else if (im_m <= 3.35d+44) then
        tmp = ((im_m * (0.5d0 + (re * (re * (-0.25d0))))) * (4.0d0 - (t_1 * t_1))) / ((-2.0d0) - t_1)
    else
        tmp = (0.5d0 * cos(re)) * (im_m * ((-2.0d0) + ((im_m * im_m) * t_0)))
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = -0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))));
	double t_1 = im_m * (im_m * t_0);
	double tmp;
	if (im_m <= 680.0) {
		tmp = Math.cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	} else if (im_m <= 3.35e+44) {
		tmp = ((im_m * (0.5 + (re * (re * -0.25)))) * (4.0 - (t_1 * t_1))) / (-2.0 - t_1);
	} else {
		tmp = (0.5 * Math.cos(re)) * (im_m * (-2.0 + ((im_m * im_m) * t_0)));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = -0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))
	t_1 = im_m * (im_m * t_0)
	tmp = 0
	if im_m <= 680.0:
		tmp = math.cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)))
	elif im_m <= 3.35e+44:
		tmp = ((im_m * (0.5 + (re * (re * -0.25)))) * (4.0 - (t_1 * t_1))) / (-2.0 - t_1)
	else:
		tmp = (0.5 * math.cos(re)) * (im_m * (-2.0 + ((im_m * im_m) * t_0)))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(-0.3333333333333333 + Float64(im_m * Float64(im_m * Float64(-0.016666666666666666 + Float64(Float64(im_m * im_m) * -0.0003968253968253968)))))
	t_1 = Float64(im_m * Float64(im_m * t_0))
	tmp = 0.0
	if (im_m <= 680.0)
		tmp = Float64(cos(re) * Float64(im_m * Float64(-1.0 + Float64(Float64(im_m * im_m) * -0.16666666666666666))));
	elseif (im_m <= 3.35e+44)
		tmp = Float64(Float64(Float64(im_m * Float64(0.5 + Float64(re * Float64(re * -0.25)))) * Float64(4.0 - Float64(t_1 * t_1))) / Float64(-2.0 - t_1));
	else
		tmp = Float64(Float64(0.5 * cos(re)) * Float64(im_m * Float64(-2.0 + Float64(Float64(im_m * im_m) * t_0))));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	t_0 = -0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))));
	t_1 = im_m * (im_m * t_0);
	tmp = 0.0;
	if (im_m <= 680.0)
		tmp = cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	elseif (im_m <= 3.35e+44)
		tmp = ((im_m * (0.5 + (re * (re * -0.25)))) * (4.0 - (t_1 * t_1))) / (-2.0 - t_1);
	else
		tmp = (0.5 * cos(re)) * (im_m * (-2.0 + ((im_m * im_m) * t_0)));
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(-0.3333333333333333 + N[(im$95$m * N[(im$95$m * N[(-0.016666666666666666 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(im$95$m * N[(im$95$m * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 680.0], N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(-1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 3.35e+44], N[(N[(N[(im$95$m * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(4.0 - N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-2.0 - t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(im$95$m * N[(-2.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := -0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\\
t_1 := im\_m \cdot \left(im\_m \cdot t\_0\right)\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 680:\\
\;\;\;\;\cos re \cdot \left(im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\right)\\

\mathbf{elif}\;im\_m \leq 3.35 \cdot 10^{+44}:\\
\;\;\;\;\frac{\left(im\_m \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(4 - t\_1 \cdot t\_1\right)}{-2 - t\_1}\\

\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im\_m \cdot \left(-2 + \left(im\_m \cdot im\_m\right) \cdot t\_0\right)\right)\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 680

    1. Initial program 32.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified95.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in im around 0

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right) + \color{blue}{-1 \cdot \cos re}\right) \]
      2. *-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \left(\cos re \cdot {im}^{2}\right) + -1 \cdot \cos re\right) \]
      3. associate-*r*N/A

        \[\leadsto im \cdot \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2} + \color{blue}{-1} \cdot \cos re\right) \]
      4. distribute-lft-inN/A

        \[\leadsto im \cdot \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right) + \color{blue}{im \cdot \left(-1 \cdot \cos re\right)} \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right) \cdot im + \color{blue}{im} \cdot \left(-1 \cdot \cos re\right) \]
      6. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{6} \cdot \left(\cos re \cdot {im}^{2}\right)\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      7. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      8. associate-*r*N/A

        \[\leadsto \left(\left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \cos re\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      9. associate-*l*N/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(\cos re \cdot im\right) + \color{blue}{im} \cdot \left(-1 \cdot \cos re\right) \]
      10. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + im \cdot \left(-1 \cdot \cos re\right) \]
      11. mul-1-negN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + im \cdot \left(\mathsf{neg}\left(\cos re\right)\right) \]
      12. distribute-rgt-neg-inN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + \left(\mathsf{neg}\left(im \cdot \cos re\right)\right) \]
      13. mul-1-negN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + -1 \cdot \color{blue}{\left(im \cdot \cos re\right)} \]
      14. distribute-rgt-outN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \color{blue}{\left(\frac{-1}{6} \cdot {im}^{2} + -1\right)} \]
      15. metadata-evalN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \left(\frac{-1}{6} \cdot {im}^{2} + \left(\mathsf{neg}\left(1\right)\right)\right) \]
      16. sub-negN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \left(\frac{-1}{6} \cdot {im}^{2} - \color{blue}{1}\right) \]
    8. Simplified90.5%

      \[\leadsto \color{blue}{\left(im \cdot \cos re\right) \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot \color{blue}{\left(im \cdot \cos re\right)} \]
      2. associate-*r*N/A

        \[\leadsto \left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot im\right) \cdot \color{blue}{\cos re} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot im\right), \color{blue}{\cos re}\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right), im\right), \cos \color{blue}{re}\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \left(\left(im \cdot im\right) \cdot \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      8. cos-lowering-cos.f6490.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right), im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    10. Applied egg-rr90.5%

      \[\leadsto \color{blue}{\left(\left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right) \cdot im\right) \cdot \cos re} \]

    if 680 < im < 3.35000000000000018e44

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified5.4%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in re around 0

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{4} \cdot {re}^{2}\right)\right), \mathsf{*.f64}\left(\color{blue}{im}, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left({re}^{2}\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left(re \cdot re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6452.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified52.7%

      \[\leadsto \color{blue}{\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(\left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot im\right) \cdot \color{blue}{\left(-2 + \left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)} \]
      2. flip-+N/A

        \[\leadsto \left(\left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot im\right) \cdot \frac{-2 \cdot -2 - \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)}{\color{blue}{-2 - \left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)}} \]
      3. associate-*r/N/A

        \[\leadsto \frac{\left(\left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot im\right) \cdot \left(-2 \cdot -2 - \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)\right)}{\color{blue}{-2 - \left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(\left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot im\right) \cdot \left(-2 \cdot -2 - \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)\right)\right), \color{blue}{\left(-2 - \left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)}\right) \]
    10. Applied egg-rr87.6%

      \[\leadsto \color{blue}{\frac{\left(im \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(4 - \left(im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right)}{-2 - im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)}} \]

    if 3.35000000000000018e44 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification92.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 680:\\ \;\;\;\;\cos re \cdot \left(im \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 3.35 \cdot 10^{+44}:\\ \;\;\;\;\frac{\left(im \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(4 - \left(im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right)}{-2 - im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 94.1% accurate, 2.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 550:\\ \;\;\;\;\cos re \cdot \left(im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im\_m \leq 8.6 \cdot 10^{+51}:\\ \;\;\;\;\frac{\left(im\_m \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(4 - t\_0 \cdot t\_0\right)}{-2 - t\_0}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im\_m \cdot \left(-2 + \left(im\_m \cdot im\_m\right) \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot -0.016666666666666666\right)\right)\right)\right)\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0
         (*
          im_m
          (*
           im_m
           (+
            -0.3333333333333333
            (*
             im_m
             (*
              im_m
              (+
               -0.016666666666666666
               (* (* im_m im_m) -0.0003968253968253968)))))))))
   (*
    im_s
    (if (<= im_m 550.0)
      (* (cos re) (* im_m (+ -1.0 (* (* im_m im_m) -0.16666666666666666))))
      (if (<= im_m 8.6e+51)
        (/
         (* (* im_m (+ 0.5 (* re (* re -0.25)))) (- 4.0 (* t_0 t_0)))
         (- -2.0 t_0))
        (*
         (* 0.5 (cos re))
         (*
          im_m
          (+
           -2.0
           (*
            (* im_m im_m)
            (+
             -0.3333333333333333
             (* im_m (* im_m -0.016666666666666666))))))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))));
	double tmp;
	if (im_m <= 550.0) {
		tmp = cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	} else if (im_m <= 8.6e+51) {
		tmp = ((im_m * (0.5 + (re * (re * -0.25)))) * (4.0 - (t_0 * t_0))) / (-2.0 - t_0);
	} else {
		tmp = (0.5 * cos(re)) * (im_m * (-2.0 + ((im_m * im_m) * (-0.3333333333333333 + (im_m * (im_m * -0.016666666666666666))))));
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = im_m * (im_m * ((-0.3333333333333333d0) + (im_m * (im_m * ((-0.016666666666666666d0) + ((im_m * im_m) * (-0.0003968253968253968d0)))))))
    if (im_m <= 550.0d0) then
        tmp = cos(re) * (im_m * ((-1.0d0) + ((im_m * im_m) * (-0.16666666666666666d0))))
    else if (im_m <= 8.6d+51) then
        tmp = ((im_m * (0.5d0 + (re * (re * (-0.25d0))))) * (4.0d0 - (t_0 * t_0))) / ((-2.0d0) - t_0)
    else
        tmp = (0.5d0 * cos(re)) * (im_m * ((-2.0d0) + ((im_m * im_m) * ((-0.3333333333333333d0) + (im_m * (im_m * (-0.016666666666666666d0)))))))
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))));
	double tmp;
	if (im_m <= 550.0) {
		tmp = Math.cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	} else if (im_m <= 8.6e+51) {
		tmp = ((im_m * (0.5 + (re * (re * -0.25)))) * (4.0 - (t_0 * t_0))) / (-2.0 - t_0);
	} else {
		tmp = (0.5 * Math.cos(re)) * (im_m * (-2.0 + ((im_m * im_m) * (-0.3333333333333333 + (im_m * (im_m * -0.016666666666666666))))));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))
	tmp = 0
	if im_m <= 550.0:
		tmp = math.cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)))
	elif im_m <= 8.6e+51:
		tmp = ((im_m * (0.5 + (re * (re * -0.25)))) * (4.0 - (t_0 * t_0))) / (-2.0 - t_0)
	else:
		tmp = (0.5 * math.cos(re)) * (im_m * (-2.0 + ((im_m * im_m) * (-0.3333333333333333 + (im_m * (im_m * -0.016666666666666666))))))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(im_m * Float64(im_m * Float64(-0.3333333333333333 + Float64(im_m * Float64(im_m * Float64(-0.016666666666666666 + Float64(Float64(im_m * im_m) * -0.0003968253968253968)))))))
	tmp = 0.0
	if (im_m <= 550.0)
		tmp = Float64(cos(re) * Float64(im_m * Float64(-1.0 + Float64(Float64(im_m * im_m) * -0.16666666666666666))));
	elseif (im_m <= 8.6e+51)
		tmp = Float64(Float64(Float64(im_m * Float64(0.5 + Float64(re * Float64(re * -0.25)))) * Float64(4.0 - Float64(t_0 * t_0))) / Float64(-2.0 - t_0));
	else
		tmp = Float64(Float64(0.5 * cos(re)) * Float64(im_m * Float64(-2.0 + Float64(Float64(im_m * im_m) * Float64(-0.3333333333333333 + Float64(im_m * Float64(im_m * -0.016666666666666666)))))));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	t_0 = im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))));
	tmp = 0.0;
	if (im_m <= 550.0)
		tmp = cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	elseif (im_m <= 8.6e+51)
		tmp = ((im_m * (0.5 + (re * (re * -0.25)))) * (4.0 - (t_0 * t_0))) / (-2.0 - t_0);
	else
		tmp = (0.5 * cos(re)) * (im_m * (-2.0 + ((im_m * im_m) * (-0.3333333333333333 + (im_m * (im_m * -0.016666666666666666))))));
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(im$95$m * N[(im$95$m * N[(-0.3333333333333333 + N[(im$95$m * N[(im$95$m * N[(-0.016666666666666666 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 550.0], N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(-1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 8.6e+51], N[(N[(N[(im$95$m * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(4.0 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-2.0 - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(im$95$m * N[(-2.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(-0.3333333333333333 + N[(im$95$m * N[(im$95$m * -0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 550:\\
\;\;\;\;\cos re \cdot \left(im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\right)\\

\mathbf{elif}\;im\_m \leq 8.6 \cdot 10^{+51}:\\
\;\;\;\;\frac{\left(im\_m \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(4 - t\_0 \cdot t\_0\right)}{-2 - t\_0}\\

\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im\_m \cdot \left(-2 + \left(im\_m \cdot im\_m\right) \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot -0.016666666666666666\right)\right)\right)\right)\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 550

    1. Initial program 32.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified95.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in im around 0

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right) + \color{blue}{-1 \cdot \cos re}\right) \]
      2. *-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \left(\cos re \cdot {im}^{2}\right) + -1 \cdot \cos re\right) \]
      3. associate-*r*N/A

        \[\leadsto im \cdot \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2} + \color{blue}{-1} \cdot \cos re\right) \]
      4. distribute-lft-inN/A

        \[\leadsto im \cdot \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right) + \color{blue}{im \cdot \left(-1 \cdot \cos re\right)} \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right) \cdot im + \color{blue}{im} \cdot \left(-1 \cdot \cos re\right) \]
      6. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{6} \cdot \left(\cos re \cdot {im}^{2}\right)\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      7. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      8. associate-*r*N/A

        \[\leadsto \left(\left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \cos re\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      9. associate-*l*N/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(\cos re \cdot im\right) + \color{blue}{im} \cdot \left(-1 \cdot \cos re\right) \]
      10. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + im \cdot \left(-1 \cdot \cos re\right) \]
      11. mul-1-negN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + im \cdot \left(\mathsf{neg}\left(\cos re\right)\right) \]
      12. distribute-rgt-neg-inN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + \left(\mathsf{neg}\left(im \cdot \cos re\right)\right) \]
      13. mul-1-negN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + -1 \cdot \color{blue}{\left(im \cdot \cos re\right)} \]
      14. distribute-rgt-outN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \color{blue}{\left(\frac{-1}{6} \cdot {im}^{2} + -1\right)} \]
      15. metadata-evalN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \left(\frac{-1}{6} \cdot {im}^{2} + \left(\mathsf{neg}\left(1\right)\right)\right) \]
      16. sub-negN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \left(\frac{-1}{6} \cdot {im}^{2} - \color{blue}{1}\right) \]
    8. Simplified90.5%

      \[\leadsto \color{blue}{\left(im \cdot \cos re\right) \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot \color{blue}{\left(im \cdot \cos re\right)} \]
      2. associate-*r*N/A

        \[\leadsto \left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot im\right) \cdot \color{blue}{\cos re} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot im\right), \color{blue}{\cos re}\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right), im\right), \cos \color{blue}{re}\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \left(\left(im \cdot im\right) \cdot \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      8. cos-lowering-cos.f6490.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right), im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    10. Applied egg-rr90.5%

      \[\leadsto \color{blue}{\left(\left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right) \cdot im\right) \cdot \cos re} \]

    if 550 < im < 8.5999999999999994e51

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified5.4%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in re around 0

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{4} \cdot {re}^{2}\right)\right), \mathsf{*.f64}\left(\color{blue}{im}, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left({re}^{2}\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left(re \cdot re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6452.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified52.7%

      \[\leadsto \color{blue}{\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(\left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot im\right) \cdot \color{blue}{\left(-2 + \left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)} \]
      2. flip-+N/A

        \[\leadsto \left(\left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot im\right) \cdot \frac{-2 \cdot -2 - \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)}{\color{blue}{-2 - \left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)}} \]
      3. associate-*r/N/A

        \[\leadsto \frac{\left(\left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot im\right) \cdot \left(-2 \cdot -2 - \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)\right)}{\color{blue}{-2 - \left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(\left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot im\right) \cdot \left(-2 \cdot -2 - \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)\right)\right), \color{blue}{\left(-2 - \left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)}\right) \]
    10. Applied egg-rr87.6%

      \[\leadsto \color{blue}{\frac{\left(im \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(4 - \left(im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right)}{-2 - im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)}} \]

    if 8.5999999999999994e51 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{-1}{60} \cdot {im}^{2}} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{-1}{60} \cdot {im}^{2}} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{60} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{60} \cdot {im}^{2} + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{\frac{-1}{60} \cdot {im}^{2}}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left(\frac{-1}{60} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\frac{-1}{60} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(\frac{-1}{60} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(\frac{-1}{60} \cdot im\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{60} \cdot im\right)}\right)\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{-1}{60}}\right)\right)\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{60}}\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified100.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot -0.016666666666666666\right)\right)\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification92.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 550:\\ \;\;\;\;\cos re \cdot \left(im \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 8.6 \cdot 10^{+51}:\\ \;\;\;\;\frac{\left(im \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(4 - \left(im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right)}{-2 - im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot -0.016666666666666666\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 94.1% accurate, 2.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 490:\\ \;\;\;\;\cos re \cdot \left(im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im\_m \leq 8.6 \cdot 10^{+51}:\\ \;\;\;\;\frac{\left(im\_m \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(4 - t\_0 \cdot t\_0\right)}{-2 - t\_0}\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \left(\cos re \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot \left(-0.16666666666666666 + im\_m \cdot \left(im\_m \cdot -0.008333333333333333\right)\right)\right)\right)\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0
         (*
          im_m
          (*
           im_m
           (+
            -0.3333333333333333
            (*
             im_m
             (*
              im_m
              (+
               -0.016666666666666666
               (* (* im_m im_m) -0.0003968253968253968)))))))))
   (*
    im_s
    (if (<= im_m 490.0)
      (* (cos re) (* im_m (+ -1.0 (* (* im_m im_m) -0.16666666666666666))))
      (if (<= im_m 8.6e+51)
        (/
         (* (* im_m (+ 0.5 (* re (* re -0.25)))) (- 4.0 (* t_0 t_0)))
         (- -2.0 t_0))
        (*
         im_m
         (*
          (cos re)
          (+
           -1.0
           (*
            (* im_m im_m)
            (+
             -0.16666666666666666
             (* im_m (* im_m -0.008333333333333333))))))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))));
	double tmp;
	if (im_m <= 490.0) {
		tmp = cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	} else if (im_m <= 8.6e+51) {
		tmp = ((im_m * (0.5 + (re * (re * -0.25)))) * (4.0 - (t_0 * t_0))) / (-2.0 - t_0);
	} else {
		tmp = im_m * (cos(re) * (-1.0 + ((im_m * im_m) * (-0.16666666666666666 + (im_m * (im_m * -0.008333333333333333))))));
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = im_m * (im_m * ((-0.3333333333333333d0) + (im_m * (im_m * ((-0.016666666666666666d0) + ((im_m * im_m) * (-0.0003968253968253968d0)))))))
    if (im_m <= 490.0d0) then
        tmp = cos(re) * (im_m * ((-1.0d0) + ((im_m * im_m) * (-0.16666666666666666d0))))
    else if (im_m <= 8.6d+51) then
        tmp = ((im_m * (0.5d0 + (re * (re * (-0.25d0))))) * (4.0d0 - (t_0 * t_0))) / ((-2.0d0) - t_0)
    else
        tmp = im_m * (cos(re) * ((-1.0d0) + ((im_m * im_m) * ((-0.16666666666666666d0) + (im_m * (im_m * (-0.008333333333333333d0)))))))
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))));
	double tmp;
	if (im_m <= 490.0) {
		tmp = Math.cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	} else if (im_m <= 8.6e+51) {
		tmp = ((im_m * (0.5 + (re * (re * -0.25)))) * (4.0 - (t_0 * t_0))) / (-2.0 - t_0);
	} else {
		tmp = im_m * (Math.cos(re) * (-1.0 + ((im_m * im_m) * (-0.16666666666666666 + (im_m * (im_m * -0.008333333333333333))))));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))
	tmp = 0
	if im_m <= 490.0:
		tmp = math.cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)))
	elif im_m <= 8.6e+51:
		tmp = ((im_m * (0.5 + (re * (re * -0.25)))) * (4.0 - (t_0 * t_0))) / (-2.0 - t_0)
	else:
		tmp = im_m * (math.cos(re) * (-1.0 + ((im_m * im_m) * (-0.16666666666666666 + (im_m * (im_m * -0.008333333333333333))))))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(im_m * Float64(im_m * Float64(-0.3333333333333333 + Float64(im_m * Float64(im_m * Float64(-0.016666666666666666 + Float64(Float64(im_m * im_m) * -0.0003968253968253968)))))))
	tmp = 0.0
	if (im_m <= 490.0)
		tmp = Float64(cos(re) * Float64(im_m * Float64(-1.0 + Float64(Float64(im_m * im_m) * -0.16666666666666666))));
	elseif (im_m <= 8.6e+51)
		tmp = Float64(Float64(Float64(im_m * Float64(0.5 + Float64(re * Float64(re * -0.25)))) * Float64(4.0 - Float64(t_0 * t_0))) / Float64(-2.0 - t_0));
	else
		tmp = Float64(im_m * Float64(cos(re) * Float64(-1.0 + Float64(Float64(im_m * im_m) * Float64(-0.16666666666666666 + Float64(im_m * Float64(im_m * -0.008333333333333333)))))));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	t_0 = im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))));
	tmp = 0.0;
	if (im_m <= 490.0)
		tmp = cos(re) * (im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	elseif (im_m <= 8.6e+51)
		tmp = ((im_m * (0.5 + (re * (re * -0.25)))) * (4.0 - (t_0 * t_0))) / (-2.0 - t_0);
	else
		tmp = im_m * (cos(re) * (-1.0 + ((im_m * im_m) * (-0.16666666666666666 + (im_m * (im_m * -0.008333333333333333))))));
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(im$95$m * N[(im$95$m * N[(-0.3333333333333333 + N[(im$95$m * N[(im$95$m * N[(-0.016666666666666666 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 490.0], N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(-1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 8.6e+51], N[(N[(N[(im$95$m * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(4.0 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-2.0 - t$95$0), $MachinePrecision]), $MachinePrecision], N[(im$95$m * N[(N[Cos[re], $MachinePrecision] * N[(-1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(-0.16666666666666666 + N[(im$95$m * N[(im$95$m * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 490:\\
\;\;\;\;\cos re \cdot \left(im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\right)\\

\mathbf{elif}\;im\_m \leq 8.6 \cdot 10^{+51}:\\
\;\;\;\;\frac{\left(im\_m \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(4 - t\_0 \cdot t\_0\right)}{-2 - t\_0}\\

\mathbf{else}:\\
\;\;\;\;im\_m \cdot \left(\cos re \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot \left(-0.16666666666666666 + im\_m \cdot \left(im\_m \cdot -0.008333333333333333\right)\right)\right)\right)\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 490

    1. Initial program 32.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified95.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in im around 0

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right) + \color{blue}{-1 \cdot \cos re}\right) \]
      2. *-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \left(\cos re \cdot {im}^{2}\right) + -1 \cdot \cos re\right) \]
      3. associate-*r*N/A

        \[\leadsto im \cdot \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2} + \color{blue}{-1} \cdot \cos re\right) \]
      4. distribute-lft-inN/A

        \[\leadsto im \cdot \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right) + \color{blue}{im \cdot \left(-1 \cdot \cos re\right)} \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right) \cdot im + \color{blue}{im} \cdot \left(-1 \cdot \cos re\right) \]
      6. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{6} \cdot \left(\cos re \cdot {im}^{2}\right)\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      7. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      8. associate-*r*N/A

        \[\leadsto \left(\left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \cos re\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      9. associate-*l*N/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(\cos re \cdot im\right) + \color{blue}{im} \cdot \left(-1 \cdot \cos re\right) \]
      10. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + im \cdot \left(-1 \cdot \cos re\right) \]
      11. mul-1-negN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + im \cdot \left(\mathsf{neg}\left(\cos re\right)\right) \]
      12. distribute-rgt-neg-inN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + \left(\mathsf{neg}\left(im \cdot \cos re\right)\right) \]
      13. mul-1-negN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + -1 \cdot \color{blue}{\left(im \cdot \cos re\right)} \]
      14. distribute-rgt-outN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \color{blue}{\left(\frac{-1}{6} \cdot {im}^{2} + -1\right)} \]
      15. metadata-evalN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \left(\frac{-1}{6} \cdot {im}^{2} + \left(\mathsf{neg}\left(1\right)\right)\right) \]
      16. sub-negN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \left(\frac{-1}{6} \cdot {im}^{2} - \color{blue}{1}\right) \]
    8. Simplified90.5%

      \[\leadsto \color{blue}{\left(im \cdot \cos re\right) \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot \color{blue}{\left(im \cdot \cos re\right)} \]
      2. associate-*r*N/A

        \[\leadsto \left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot im\right) \cdot \color{blue}{\cos re} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot im\right), \color{blue}{\cos re}\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right), im\right), \cos \color{blue}{re}\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \left(\left(im \cdot im\right) \cdot \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      8. cos-lowering-cos.f6490.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right), im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    10. Applied egg-rr90.5%

      \[\leadsto \color{blue}{\left(\left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right) \cdot im\right) \cdot \cos re} \]

    if 490 < im < 8.5999999999999994e51

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified5.4%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in re around 0

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{4} \cdot {re}^{2}\right)\right), \mathsf{*.f64}\left(\color{blue}{im}, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left({re}^{2}\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left(re \cdot re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6452.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified52.7%

      \[\leadsto \color{blue}{\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(\left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot im\right) \cdot \color{blue}{\left(-2 + \left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)} \]
      2. flip-+N/A

        \[\leadsto \left(\left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot im\right) \cdot \frac{-2 \cdot -2 - \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)}{\color{blue}{-2 - \left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)}} \]
      3. associate-*r/N/A

        \[\leadsto \frac{\left(\left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot im\right) \cdot \left(-2 \cdot -2 - \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)\right)}{\color{blue}{-2 - \left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(\left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot im\right) \cdot \left(-2 \cdot -2 - \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)\right)\right), \color{blue}{\left(-2 - \left(im \cdot im\right) \cdot \left(\frac{-1}{3} + im \cdot \left(im \cdot \left(\frac{-1}{60} + \left(im \cdot im\right) \cdot \frac{-1}{2520}\right)\right)\right)\right)}\right) \]
    10. Applied egg-rr87.6%

      \[\leadsto \color{blue}{\frac{\left(im \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(4 - \left(im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right)}{-2 - im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)}} \]

    if 8.5999999999999994e51 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \cos re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \cos re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \cos re\right)\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left(-1 \cdot \cos re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \cos re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \cos re\right)\right)\right)}\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot -1 + \color{blue}{{im}^{2}} \cdot \left(\frac{-1}{6} \cdot \cos re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \cos re\right)\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot -1 + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \cos re + \left(\frac{-1}{120} \cdot {im}^{2}\right) \cdot \color{blue}{\cos re}\right)\right)\right) \]
      4. distribute-rgt-outN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot -1 + {im}^{2} \cdot \left(\cos re \cdot \color{blue}{\left(\frac{-1}{6} + \frac{-1}{120} \cdot {im}^{2}\right)}\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot -1 + \left({im}^{2} \cdot \cos re\right) \cdot \color{blue}{\left(\frac{-1}{6} + \frac{-1}{120} \cdot {im}^{2}\right)}\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot -1 + \left({im}^{2} \cdot \cos re\right) \cdot \left(\frac{-1}{120} \cdot {im}^{2} + \color{blue}{\frac{-1}{6}}\right)\right)\right) \]
      7. distribute-lft-outN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot -1 + \left(\left({im}^{2} \cdot \cos re\right) \cdot \left(\frac{-1}{120} \cdot {im}^{2}\right) + \color{blue}{\left({im}^{2} \cdot \cos re\right) \cdot \frac{-1}{6}}\right)\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot -1 + \left(\left(\cos re \cdot {im}^{2}\right) \cdot \left(\frac{-1}{120} \cdot {im}^{2}\right) + \left(\color{blue}{{im}^{2}} \cdot \cos re\right) \cdot \frac{-1}{6}\right)\right)\right) \]
      9. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot -1 + \left(\cos re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2}\right)\right) + \color{blue}{\left({im}^{2} \cdot \cos re\right)} \cdot \frac{-1}{6}\right)\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot -1 + \left(\cos re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2}\right)\right) + \frac{-1}{6} \cdot \color{blue}{\left({im}^{2} \cdot \cos re\right)}\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot -1 + \left(\cos re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2}\right)\right) + \frac{-1}{6} \cdot \left(\cos re \cdot \color{blue}{{im}^{2}}\right)\right)\right)\right) \]
      12. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot -1 + \left(\cos re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2}\right)\right) + \left(\frac{-1}{6} \cdot \cos re\right) \cdot \color{blue}{{im}^{2}}\right)\right)\right) \]
    5. Simplified98.6%

      \[\leadsto \color{blue}{im \cdot \left(\cos re \cdot \left(-1 + \left(im \cdot im\right) \cdot \left(-0.16666666666666666 + im \cdot \left(im \cdot -0.008333333333333333\right)\right)\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification92.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 490:\\ \;\;\;\;\cos re \cdot \left(im \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 8.6 \cdot 10^{+51}:\\ \;\;\;\;\frac{\left(im \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(4 - \left(im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right)}{-2 - im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(\cos re \cdot \left(-1 + \left(im \cdot im\right) \cdot \left(-0.16666666666666666 + im \cdot \left(im \cdot -0.008333333333333333\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 94.4% accurate, 2.6× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := -1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 490:\\ \;\;\;\;\cos re \cdot \left(im\_m \cdot t\_0\right)\\ \mathbf{elif}\;im\_m \leq 3.4 \cdot 10^{+101}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im\_m \cdot \left(-2 + im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \left(\cos re \cdot t\_0\right)\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (+ -1.0 (* (* im_m im_m) -0.16666666666666666))))
   (*
    im_s
    (if (<= im_m 490.0)
      (* (cos re) (* im_m t_0))
      (if (<= im_m 3.4e+101)
        (*
         re
         (*
          re
          (*
           (*
            im_m
            (+
             -2.0
             (*
              im_m
              (*
               im_m
               (+
                -0.3333333333333333
                (*
                 im_m
                 (*
                  im_m
                  (+
                   -0.016666666666666666
                   (* (* im_m im_m) -0.0003968253968253968)))))))))
           (+ -0.25 (/ 0.5 (* re re))))))
        (* im_m (* (cos re) t_0)))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = -1.0 + ((im_m * im_m) * -0.16666666666666666);
	double tmp;
	if (im_m <= 490.0) {
		tmp = cos(re) * (im_m * t_0);
	} else if (im_m <= 3.4e+101) {
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	} else {
		tmp = im_m * (cos(re) * t_0);
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-1.0d0) + ((im_m * im_m) * (-0.16666666666666666d0))
    if (im_m <= 490.0d0) then
        tmp = cos(re) * (im_m * t_0)
    else if (im_m <= 3.4d+101) then
        tmp = re * (re * ((im_m * ((-2.0d0) + (im_m * (im_m * ((-0.3333333333333333d0) + (im_m * (im_m * ((-0.016666666666666666d0) + ((im_m * im_m) * (-0.0003968253968253968d0)))))))))) * ((-0.25d0) + (0.5d0 / (re * re)))))
    else
        tmp = im_m * (cos(re) * t_0)
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = -1.0 + ((im_m * im_m) * -0.16666666666666666);
	double tmp;
	if (im_m <= 490.0) {
		tmp = Math.cos(re) * (im_m * t_0);
	} else if (im_m <= 3.4e+101) {
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	} else {
		tmp = im_m * (Math.cos(re) * t_0);
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = -1.0 + ((im_m * im_m) * -0.16666666666666666)
	tmp = 0
	if im_m <= 490.0:
		tmp = math.cos(re) * (im_m * t_0)
	elif im_m <= 3.4e+101:
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))))
	else:
		tmp = im_m * (math.cos(re) * t_0)
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(-1.0 + Float64(Float64(im_m * im_m) * -0.16666666666666666))
	tmp = 0.0
	if (im_m <= 490.0)
		tmp = Float64(cos(re) * Float64(im_m * t_0));
	elseif (im_m <= 3.4e+101)
		tmp = Float64(re * Float64(re * Float64(Float64(im_m * Float64(-2.0 + Float64(im_m * Float64(im_m * Float64(-0.3333333333333333 + Float64(im_m * Float64(im_m * Float64(-0.016666666666666666 + Float64(Float64(im_m * im_m) * -0.0003968253968253968))))))))) * Float64(-0.25 + Float64(0.5 / Float64(re * re))))));
	else
		tmp = Float64(im_m * Float64(cos(re) * t_0));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	t_0 = -1.0 + ((im_m * im_m) * -0.16666666666666666);
	tmp = 0.0;
	if (im_m <= 490.0)
		tmp = cos(re) * (im_m * t_0);
	elseif (im_m <= 3.4e+101)
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	else
		tmp = im_m * (cos(re) * t_0);
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(-1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 490.0], N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 3.4e+101], N[(re * N[(re * N[(N[(im$95$m * N[(-2.0 + N[(im$95$m * N[(im$95$m * N[(-0.3333333333333333 + N[(im$95$m * N[(im$95$m * N[(-0.016666666666666666 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.25 + N[(0.5 / N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im$95$m * N[(N[Cos[re], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := -1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 490:\\
\;\;\;\;\cos re \cdot \left(im\_m \cdot t\_0\right)\\

\mathbf{elif}\;im\_m \leq 3.4 \cdot 10^{+101}:\\
\;\;\;\;re \cdot \left(re \cdot \left(\left(im\_m \cdot \left(-2 + im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;im\_m \cdot \left(\cos re \cdot t\_0\right)\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 490

    1. Initial program 32.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified95.9%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in im around 0

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right) + \color{blue}{-1 \cdot \cos re}\right) \]
      2. *-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \left(\cos re \cdot {im}^{2}\right) + -1 \cdot \cos re\right) \]
      3. associate-*r*N/A

        \[\leadsto im \cdot \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2} + \color{blue}{-1} \cdot \cos re\right) \]
      4. distribute-lft-inN/A

        \[\leadsto im \cdot \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right) + \color{blue}{im \cdot \left(-1 \cdot \cos re\right)} \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right) \cdot im + \color{blue}{im} \cdot \left(-1 \cdot \cos re\right) \]
      6. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{6} \cdot \left(\cos re \cdot {im}^{2}\right)\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      7. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      8. associate-*r*N/A

        \[\leadsto \left(\left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \cos re\right) \cdot im + im \cdot \left(-1 \cdot \cos re\right) \]
      9. associate-*l*N/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(\cos re \cdot im\right) + \color{blue}{im} \cdot \left(-1 \cdot \cos re\right) \]
      10. *-commutativeN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + im \cdot \left(-1 \cdot \cos re\right) \]
      11. mul-1-negN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + im \cdot \left(\mathsf{neg}\left(\cos re\right)\right) \]
      12. distribute-rgt-neg-inN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + \left(\mathsf{neg}\left(im \cdot \cos re\right)\right) \]
      13. mul-1-negN/A

        \[\leadsto \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \left(im \cdot \cos re\right) + -1 \cdot \color{blue}{\left(im \cdot \cos re\right)} \]
      14. distribute-rgt-outN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \color{blue}{\left(\frac{-1}{6} \cdot {im}^{2} + -1\right)} \]
      15. metadata-evalN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \left(\frac{-1}{6} \cdot {im}^{2} + \left(\mathsf{neg}\left(1\right)\right)\right) \]
      16. sub-negN/A

        \[\leadsto \left(im \cdot \cos re\right) \cdot \left(\frac{-1}{6} \cdot {im}^{2} - \color{blue}{1}\right) \]
    8. Simplified90.5%

      \[\leadsto \color{blue}{\left(im \cdot \cos re\right) \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot \color{blue}{\left(im \cdot \cos re\right)} \]
      2. associate-*r*N/A

        \[\leadsto \left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot im\right) \cdot \color{blue}{\cos re} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right) \cdot im\right), \color{blue}{\cos re}\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(-1 + \left(im \cdot im\right) \cdot \frac{-1}{6}\right), im\right), \cos \color{blue}{re}\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \left(\left(im \cdot im\right) \cdot \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right), im\right), \cos re\right) \]
      8. cos-lowering-cos.f6490.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right), im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    10. Applied egg-rr90.5%

      \[\leadsto \color{blue}{\left(\left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right) \cdot im\right) \cdot \cos re} \]

    if 490 < im < 3.40000000000000017e101

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified55.5%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in re around 0

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{4} \cdot {re}^{2}\right)\right), \mathsf{*.f64}\left(\color{blue}{im}, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left({re}^{2}\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left(re \cdot re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6460.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified60.1%

      \[\leadsto \color{blue}{\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \]
    9. Taylor expanded in re around inf

      \[\leadsto \color{blue}{{re}^{2} \cdot \left(\frac{-1}{4} \cdot \left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right) + \frac{1}{2} \cdot \frac{im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}{{re}^{2}}\right)} \]
    10. Simplified76.5%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(\left(im \cdot \left(-2 + im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot -0.0003968253968253968 + -0.016666666666666666\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)} \]

    if 3.40000000000000017e101 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto im \cdot \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \left(\cos re \cdot \color{blue}{{im}^{2}}\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto im \cdot \left(-1 \cdot \cos re + \left(\frac{-1}{6} \cdot \cos re\right) \cdot \color{blue}{{im}^{2}}\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left(-1 \cdot \cos re + \left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right)}\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \color{blue}{\left(\cos re \cdot {im}^{2}\right)}\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \left({im}^{2} \cdot \color{blue}{\cos re}\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(-1 \cdot \cos re + \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \color{blue}{\cos re}\right)\right) \]
      7. distribute-rgt-outN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot \color{blue}{\left(-1 + \frac{-1}{6} \cdot {im}^{2}\right)}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\cos re, \color{blue}{\left(-1 + \frac{-1}{6} \cdot {im}^{2}\right)}\right)\right) \]
      9. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\color{blue}{-1} + \frac{-1}{6} \cdot {im}^{2}\right)\right)\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(-1, \color{blue}{\left(\frac{-1}{6} \cdot {im}^{2}\right)}\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{-1}{6}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{-1}{6}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
      13. *-lowering-*.f6498.1%

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right)\right) \]
    5. Simplified98.1%

      \[\leadsto \color{blue}{im \cdot \left(\cos re \cdot \left(-1 + -0.16666666666666666 \cdot \left(im \cdot im\right)\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 490:\\ \;\;\;\;\cos re \cdot \left(im \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 3.4 \cdot 10^{+101}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im \cdot \left(-2 + im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(\cos re \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 94.4% accurate, 2.6× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := im\_m \cdot \left(\cos re \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\right)\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 480:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 3.4 \cdot 10^{+101}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im\_m \cdot \left(-2 + im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0
         (*
          im_m
          (* (cos re) (+ -1.0 (* (* im_m im_m) -0.16666666666666666))))))
   (*
    im_s
    (if (<= im_m 480.0)
      t_0
      (if (<= im_m 3.4e+101)
        (*
         re
         (*
          re
          (*
           (*
            im_m
            (+
             -2.0
             (*
              im_m
              (*
               im_m
               (+
                -0.3333333333333333
                (*
                 im_m
                 (*
                  im_m
                  (+
                   -0.016666666666666666
                   (* (* im_m im_m) -0.0003968253968253968)))))))))
           (+ -0.25 (/ 0.5 (* re re))))))
        t_0)))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = im_m * (cos(re) * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	double tmp;
	if (im_m <= 480.0) {
		tmp = t_0;
	} else if (im_m <= 3.4e+101) {
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	} else {
		tmp = t_0;
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = im_m * (cos(re) * ((-1.0d0) + ((im_m * im_m) * (-0.16666666666666666d0))))
    if (im_m <= 480.0d0) then
        tmp = t_0
    else if (im_m <= 3.4d+101) then
        tmp = re * (re * ((im_m * ((-2.0d0) + (im_m * (im_m * ((-0.3333333333333333d0) + (im_m * (im_m * ((-0.016666666666666666d0) + ((im_m * im_m) * (-0.0003968253968253968d0)))))))))) * ((-0.25d0) + (0.5d0 / (re * re)))))
    else
        tmp = t_0
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = im_m * (Math.cos(re) * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	double tmp;
	if (im_m <= 480.0) {
		tmp = t_0;
	} else if (im_m <= 3.4e+101) {
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	} else {
		tmp = t_0;
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = im_m * (math.cos(re) * (-1.0 + ((im_m * im_m) * -0.16666666666666666)))
	tmp = 0
	if im_m <= 480.0:
		tmp = t_0
	elif im_m <= 3.4e+101:
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))))
	else:
		tmp = t_0
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(im_m * Float64(cos(re) * Float64(-1.0 + Float64(Float64(im_m * im_m) * -0.16666666666666666))))
	tmp = 0.0
	if (im_m <= 480.0)
		tmp = t_0;
	elseif (im_m <= 3.4e+101)
		tmp = Float64(re * Float64(re * Float64(Float64(im_m * Float64(-2.0 + Float64(im_m * Float64(im_m * Float64(-0.3333333333333333 + Float64(im_m * Float64(im_m * Float64(-0.016666666666666666 + Float64(Float64(im_m * im_m) * -0.0003968253968253968))))))))) * Float64(-0.25 + Float64(0.5 / Float64(re * re))))));
	else
		tmp = t_0;
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	t_0 = im_m * (cos(re) * (-1.0 + ((im_m * im_m) * -0.16666666666666666)));
	tmp = 0.0;
	if (im_m <= 480.0)
		tmp = t_0;
	elseif (im_m <= 3.4e+101)
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	else
		tmp = t_0;
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(im$95$m * N[(N[Cos[re], $MachinePrecision] * N[(-1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 480.0], t$95$0, If[LessEqual[im$95$m, 3.4e+101], N[(re * N[(re * N[(N[(im$95$m * N[(-2.0 + N[(im$95$m * N[(im$95$m * N[(-0.3333333333333333 + N[(im$95$m * N[(im$95$m * N[(-0.016666666666666666 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.25 + N[(0.5 / N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]), $MachinePrecision]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := im\_m \cdot \left(\cos re \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\right)\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 480:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;im\_m \leq 3.4 \cdot 10^{+101}:\\
\;\;\;\;re \cdot \left(re \cdot \left(\left(im\_m \cdot \left(-2 + im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 480 or 3.40000000000000017e101 < im

    1. Initial program 45.8%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \left({im}^{2} \cdot \cos re\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto im \cdot \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \left(\cos re \cdot \color{blue}{{im}^{2}}\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto im \cdot \left(-1 \cdot \cos re + \left(\frac{-1}{6} \cdot \cos re\right) \cdot \color{blue}{{im}^{2}}\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left(-1 \cdot \cos re + \left(\frac{-1}{6} \cdot \cos re\right) \cdot {im}^{2}\right)}\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \color{blue}{\left(\cos re \cdot {im}^{2}\right)}\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(-1 \cdot \cos re + \frac{-1}{6} \cdot \left({im}^{2} \cdot \color{blue}{\cos re}\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(-1 \cdot \cos re + \left(\frac{-1}{6} \cdot {im}^{2}\right) \cdot \color{blue}{\cos re}\right)\right) \]
      7. distribute-rgt-outN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(\cos re \cdot \color{blue}{\left(-1 + \frac{-1}{6} \cdot {im}^{2}\right)}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\cos re, \color{blue}{\left(-1 + \frac{-1}{6} \cdot {im}^{2}\right)}\right)\right) \]
      9. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\color{blue}{-1} + \frac{-1}{6} \cdot {im}^{2}\right)\right)\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(-1, \color{blue}{\left(\frac{-1}{6} \cdot {im}^{2}\right)}\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{-1}{6}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{-1}{6}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
      13. *-lowering-*.f6492.0%

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right)\right) \]
    5. Simplified92.0%

      \[\leadsto \color{blue}{im \cdot \left(\cos re \cdot \left(-1 + -0.16666666666666666 \cdot \left(im \cdot im\right)\right)\right)} \]

    if 480 < im < 3.40000000000000017e101

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified55.5%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in re around 0

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{4} \cdot {re}^{2}\right)\right), \mathsf{*.f64}\left(\color{blue}{im}, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left({re}^{2}\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left(re \cdot re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6460.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified60.1%

      \[\leadsto \color{blue}{\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \]
    9. Taylor expanded in re around inf

      \[\leadsto \color{blue}{{re}^{2} \cdot \left(\frac{-1}{4} \cdot \left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right) + \frac{1}{2} \cdot \frac{im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}{{re}^{2}}\right)} \]
    10. Simplified76.5%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(\left(im \cdot \left(-2 + im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot -0.0003968253968253968 + -0.016666666666666666\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 480:\\ \;\;\;\;im \cdot \left(\cos re \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 3.4 \cdot 10^{+101}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im \cdot \left(-2 + im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(\cos re \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 92.3% accurate, 2.6× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 490:\\ \;\;\;\;0 - im\_m \cdot \cos re\\ \mathbf{elif}\;im\_m \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im\_m \cdot \left(-2 + im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(0 - \frac{im\_m \cdot im\_m}{im\_m}\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 490.0)
    (- 0.0 (* im_m (cos re)))
    (if (<= im_m 1.35e+154)
      (*
       re
       (*
        re
        (*
         (*
          im_m
          (+
           -2.0
           (*
            im_m
            (*
             im_m
             (+
              -0.3333333333333333
              (*
               im_m
               (*
                im_m
                (+
                 -0.016666666666666666
                 (* (* im_m im_m) -0.0003968253968253968)))))))))
         (+ -0.25 (/ 0.5 (* re re))))))
      (* (cos re) (- 0.0 (/ (* im_m im_m) im_m)))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 490.0) {
		tmp = 0.0 - (im_m * cos(re));
	} else if (im_m <= 1.35e+154) {
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	} else {
		tmp = cos(re) * (0.0 - ((im_m * im_m) / im_m));
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 490.0d0) then
        tmp = 0.0d0 - (im_m * cos(re))
    else if (im_m <= 1.35d+154) then
        tmp = re * (re * ((im_m * ((-2.0d0) + (im_m * (im_m * ((-0.3333333333333333d0) + (im_m * (im_m * ((-0.016666666666666666d0) + ((im_m * im_m) * (-0.0003968253968253968d0)))))))))) * ((-0.25d0) + (0.5d0 / (re * re)))))
    else
        tmp = cos(re) * (0.0d0 - ((im_m * im_m) / im_m))
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 490.0) {
		tmp = 0.0 - (im_m * Math.cos(re));
	} else if (im_m <= 1.35e+154) {
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	} else {
		tmp = Math.cos(re) * (0.0 - ((im_m * im_m) / im_m));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 490.0:
		tmp = 0.0 - (im_m * math.cos(re))
	elif im_m <= 1.35e+154:
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))))
	else:
		tmp = math.cos(re) * (0.0 - ((im_m * im_m) / im_m))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 490.0)
		tmp = Float64(0.0 - Float64(im_m * cos(re)));
	elseif (im_m <= 1.35e+154)
		tmp = Float64(re * Float64(re * Float64(Float64(im_m * Float64(-2.0 + Float64(im_m * Float64(im_m * Float64(-0.3333333333333333 + Float64(im_m * Float64(im_m * Float64(-0.016666666666666666 + Float64(Float64(im_m * im_m) * -0.0003968253968253968))))))))) * Float64(-0.25 + Float64(0.5 / Float64(re * re))))));
	else
		tmp = Float64(cos(re) * Float64(0.0 - Float64(Float64(im_m * im_m) / im_m)));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 490.0)
		tmp = 0.0 - (im_m * cos(re));
	elseif (im_m <= 1.35e+154)
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	else
		tmp = cos(re) * (0.0 - ((im_m * im_m) / im_m));
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 490.0], N[(0.0 - N[(im$95$m * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 1.35e+154], N[(re * N[(re * N[(N[(im$95$m * N[(-2.0 + N[(im$95$m * N[(im$95$m * N[(-0.3333333333333333 + N[(im$95$m * N[(im$95$m * N[(-0.016666666666666666 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.25 + N[(0.5 / N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(0.0 - N[(N[(im$95$m * im$95$m), $MachinePrecision] / im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 490:\\
\;\;\;\;0 - im\_m \cdot \cos re\\

\mathbf{elif}\;im\_m \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;re \cdot \left(re \cdot \left(\left(im\_m \cdot \left(-2 + im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(0 - \frac{im\_m \cdot im\_m}{im\_m}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 490

    1. Initial program 32.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
      2. neg-mul-1N/A

        \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
      4. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
      6. cos-lowering-cos.f6473.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    5. Simplified73.6%

      \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
    6. Step-by-step derivation
      1. sub0-negN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \mathsf{cos.f64}\left(\color{blue}{re}\right)\right) \]
      2. neg-lowering-neg.f6473.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{neg.f64}\left(im\right), \mathsf{cos.f64}\left(\color{blue}{re}\right)\right) \]
    7. Applied egg-rr73.6%

      \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]

    if 490 < im < 1.35000000000000003e154

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified73.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in re around 0

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{4} \cdot {re}^{2}\right)\right), \mathsf{*.f64}\left(\color{blue}{im}, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left({re}^{2}\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left(re \cdot re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6461.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified61.5%

      \[\leadsto \color{blue}{\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \]
    9. Taylor expanded in re around inf

      \[\leadsto \color{blue}{{re}^{2} \cdot \left(\frac{-1}{4} \cdot \left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right) + \frac{1}{2} \cdot \frac{im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}{{re}^{2}}\right)} \]
    10. Simplified71.4%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(\left(im \cdot \left(-2 + im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot -0.0003968253968253968 + -0.016666666666666666\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)} \]

    if 1.35000000000000003e154 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
      2. neg-mul-1N/A

        \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
      4. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
      6. cos-lowering-cos.f647.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    5. Simplified7.3%

      \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
    6. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{0 \cdot 0 - im \cdot im}{0 + im}\right), \mathsf{cos.f64}\left(\color{blue}{re}\right)\right) \]
      2. +-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{0 \cdot 0 - im \cdot im}{im}\right), \mathsf{cos.f64}\left(re\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(0 \cdot 0 - im \cdot im\right), im\right), \mathsf{cos.f64}\left(\color{blue}{re}\right)\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(0 - im \cdot im\right), im\right), \mathsf{cos.f64}\left(re\right)\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(0, \left(im \cdot im\right)\right), im\right), \mathsf{cos.f64}\left(re\right)\right) \]
      6. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(im, im\right)\right), im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    7. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{0 - im \cdot im}{im}} \cdot \cos re \]
  3. Recombined 3 regimes into one program.
  4. Final simplification77.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 490:\\ \;\;\;\;0 - im \cdot \cos re\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im \cdot \left(-2 + im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(0 - \frac{im \cdot im}{im}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 85.7% accurate, 2.8× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 480:\\ \;\;\;\;0 - im\_m \cdot \cos re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im\_m \cdot \left(-2 + im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 480.0)
    (- 0.0 (* im_m (cos re)))
    (*
     re
     (*
      re
      (*
       (*
        im_m
        (+
         -2.0
         (*
          im_m
          (*
           im_m
           (+
            -0.3333333333333333
            (*
             im_m
             (*
              im_m
              (+
               -0.016666666666666666
               (* (* im_m im_m) -0.0003968253968253968)))))))))
       (+ -0.25 (/ 0.5 (* re re)))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 480.0) {
		tmp = 0.0 - (im_m * cos(re));
	} else {
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 480.0d0) then
        tmp = 0.0d0 - (im_m * cos(re))
    else
        tmp = re * (re * ((im_m * ((-2.0d0) + (im_m * (im_m * ((-0.3333333333333333d0) + (im_m * (im_m * ((-0.016666666666666666d0) + ((im_m * im_m) * (-0.0003968253968253968d0)))))))))) * ((-0.25d0) + (0.5d0 / (re * re)))))
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 480.0) {
		tmp = 0.0 - (im_m * Math.cos(re));
	} else {
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 480.0:
		tmp = 0.0 - (im_m * math.cos(re))
	else:
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 480.0)
		tmp = Float64(0.0 - Float64(im_m * cos(re)));
	else
		tmp = Float64(re * Float64(re * Float64(Float64(im_m * Float64(-2.0 + Float64(im_m * Float64(im_m * Float64(-0.3333333333333333 + Float64(im_m * Float64(im_m * Float64(-0.016666666666666666 + Float64(Float64(im_m * im_m) * -0.0003968253968253968))))))))) * Float64(-0.25 + Float64(0.5 / Float64(re * re))))));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 480.0)
		tmp = 0.0 - (im_m * cos(re));
	else
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 480.0], N[(0.0 - N[(im$95$m * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(re * N[(N[(im$95$m * N[(-2.0 + N[(im$95$m * N[(im$95$m * N[(-0.3333333333333333 + N[(im$95$m * N[(im$95$m * N[(-0.016666666666666666 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.25 + N[(0.5 / N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 480:\\
\;\;\;\;0 - im\_m \cdot \cos re\\

\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot \left(\left(im\_m \cdot \left(-2 + im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 480

    1. Initial program 32.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
      2. neg-mul-1N/A

        \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
      4. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
      6. cos-lowering-cos.f6473.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    5. Simplified73.6%

      \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
    6. Step-by-step derivation
      1. sub0-negN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \mathsf{cos.f64}\left(\color{blue}{re}\right)\right) \]
      2. neg-lowering-neg.f6473.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{neg.f64}\left(im\right), \mathsf{cos.f64}\left(\color{blue}{re}\right)\right) \]
    7. Applied egg-rr73.6%

      \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]

    if 480 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified88.2%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in re around 0

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{4} \cdot {re}^{2}\right)\right), \mathsf{*.f64}\left(\color{blue}{im}, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left({re}^{2}\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left(re \cdot re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6473.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified73.8%

      \[\leadsto \color{blue}{\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \]
    9. Taylor expanded in re around inf

      \[\leadsto \color{blue}{{re}^{2} \cdot \left(\frac{-1}{4} \cdot \left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right) + \frac{1}{2} \cdot \frac{im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}{{re}^{2}}\right)} \]
    10. Simplified78.1%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(\left(im \cdot \left(-2 + im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot -0.0003968253968253968 + -0.016666666666666666\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification74.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 480:\\ \;\;\;\;0 - im \cdot \cos re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im \cdot \left(-2 + im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 63.6% accurate, 8.1× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 210:\\ \;\;\;\;0 - im\_m\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im\_m \cdot \left(-2 + im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 210.0)
    (- 0.0 im_m)
    (*
     re
     (*
      re
      (*
       (*
        im_m
        (+
         -2.0
         (*
          im_m
          (*
           im_m
           (+
            -0.3333333333333333
            (*
             im_m
             (*
              im_m
              (+
               -0.016666666666666666
               (* (* im_m im_m) -0.0003968253968253968)))))))))
       (+ -0.25 (/ 0.5 (* re re)))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 210.0) {
		tmp = 0.0 - im_m;
	} else {
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 210.0d0) then
        tmp = 0.0d0 - im_m
    else
        tmp = re * (re * ((im_m * ((-2.0d0) + (im_m * (im_m * ((-0.3333333333333333d0) + (im_m * (im_m * ((-0.016666666666666666d0) + ((im_m * im_m) * (-0.0003968253968253968d0)))))))))) * ((-0.25d0) + (0.5d0 / (re * re)))))
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 210.0) {
		tmp = 0.0 - im_m;
	} else {
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 210.0:
		tmp = 0.0 - im_m
	else:
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 210.0)
		tmp = Float64(0.0 - im_m);
	else
		tmp = Float64(re * Float64(re * Float64(Float64(im_m * Float64(-2.0 + Float64(im_m * Float64(im_m * Float64(-0.3333333333333333 + Float64(im_m * Float64(im_m * Float64(-0.016666666666666666 + Float64(Float64(im_m * im_m) * -0.0003968253968253968))))))))) * Float64(-0.25 + Float64(0.5 / Float64(re * re))))));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 210.0)
		tmp = 0.0 - im_m;
	else
		tmp = re * (re * ((im_m * (-2.0 + (im_m * (im_m * (-0.3333333333333333 + (im_m * (im_m * (-0.016666666666666666 + ((im_m * im_m) * -0.0003968253968253968))))))))) * (-0.25 + (0.5 / (re * re)))));
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 210.0], N[(0.0 - im$95$m), $MachinePrecision], N[(re * N[(re * N[(N[(im$95$m * N[(-2.0 + N[(im$95$m * N[(im$95$m * N[(-0.3333333333333333 + N[(im$95$m * N[(im$95$m * N[(-0.016666666666666666 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.25 + N[(0.5 / N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 210:\\
\;\;\;\;0 - im\_m\\

\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot \left(\left(im\_m \cdot \left(-2 + im\_m \cdot \left(im\_m \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot \left(-0.016666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 210

    1. Initial program 32.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
      2. neg-mul-1N/A

        \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
      4. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
      6. cos-lowering-cos.f6473.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    5. Simplified73.6%

      \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
    6. Taylor expanded in re around 0

      \[\leadsto \color{blue}{-1 \cdot im} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(im\right) \]
      2. neg-sub0N/A

        \[\leadsto 0 - \color{blue}{im} \]
      3. --lowering--.f6439.8%

        \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{im}\right) \]
    8. Simplified39.8%

      \[\leadsto \color{blue}{0 - im} \]
    9. Step-by-step derivation
      1. sub0-negN/A

        \[\leadsto \mathsf{neg}\left(im\right) \]
      2. neg-lowering-neg.f6439.8%

        \[\leadsto \mathsf{neg.f64}\left(im\right) \]
    10. Applied egg-rr39.8%

      \[\leadsto \color{blue}{-im} \]

    if 210 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2520} \cdot {im}^{2}} - \frac{1}{60}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{60}\right)\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2520} \cdot {im}^{2} + \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right)\right) \]
      19. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{60} + \color{blue}{\frac{-1}{2520} \cdot {im}^{2}}\right)\right)\right)\right)\right)\right)\right)\right) \]
      20. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \color{blue}{\left(\frac{-1}{2520} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified88.2%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)} \]
    6. Taylor expanded in re around 0

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{4} \cdot {re}^{2}\right)\right), \mathsf{*.f64}\left(\color{blue}{im}, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left({re}^{2}\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left(re \cdot re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6473.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{60}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{2520}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified73.8%

      \[\leadsto \color{blue}{\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right) \]
    9. Taylor expanded in re around inf

      \[\leadsto \color{blue}{{re}^{2} \cdot \left(\frac{-1}{4} \cdot \left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right) + \frac{1}{2} \cdot \frac{im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)}{{re}^{2}}\right)} \]
    10. Simplified78.1%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(\left(im \cdot \left(-2 + im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot -0.0003968253968253968 + -0.016666666666666666\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification49.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 210:\\ \;\;\;\;0 - im\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im \cdot \left(-2 + im \cdot \left(im \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot \left(-0.016666666666666666 + \left(im \cdot im\right) \cdot -0.0003968253968253968\right)\right)\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 60.0% accurate, 11.9× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 1.55 \cdot 10^{+173}:\\ \;\;\;\;im\_m \cdot \left(-1 + im\_m \cdot \left(im\_m \cdot \left(-0.16666666666666666 + \left(im\_m \cdot im\_m\right) \cdot \left(-0.008333333333333333 + \left(im\_m \cdot im\_m\right) \cdot -0.0001984126984126984\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= re 1.55e+173)
    (*
     im_m
     (+
      -1.0
      (*
       im_m
       (*
        im_m
        (+
         -0.16666666666666666
         (*
          (* im_m im_m)
          (+
           -0.008333333333333333
           (* (* im_m im_m) -0.0001984126984126984))))))))
    (* im_m (+ -1.0 (* 0.5 (* re re)))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 1.55e+173) {
		tmp = im_m * (-1.0 + (im_m * (im_m * (-0.16666666666666666 + ((im_m * im_m) * (-0.008333333333333333 + ((im_m * im_m) * -0.0001984126984126984)))))));
	} else {
		tmp = im_m * (-1.0 + (0.5 * (re * re)));
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (re <= 1.55d+173) then
        tmp = im_m * ((-1.0d0) + (im_m * (im_m * ((-0.16666666666666666d0) + ((im_m * im_m) * ((-0.008333333333333333d0) + ((im_m * im_m) * (-0.0001984126984126984d0))))))))
    else
        tmp = im_m * ((-1.0d0) + (0.5d0 * (re * re)))
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 1.55e+173) {
		tmp = im_m * (-1.0 + (im_m * (im_m * (-0.16666666666666666 + ((im_m * im_m) * (-0.008333333333333333 + ((im_m * im_m) * -0.0001984126984126984)))))));
	} else {
		tmp = im_m * (-1.0 + (0.5 * (re * re)));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if re <= 1.55e+173:
		tmp = im_m * (-1.0 + (im_m * (im_m * (-0.16666666666666666 + ((im_m * im_m) * (-0.008333333333333333 + ((im_m * im_m) * -0.0001984126984126984)))))))
	else:
		tmp = im_m * (-1.0 + (0.5 * (re * re)))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (re <= 1.55e+173)
		tmp = Float64(im_m * Float64(-1.0 + Float64(im_m * Float64(im_m * Float64(-0.16666666666666666 + Float64(Float64(im_m * im_m) * Float64(-0.008333333333333333 + Float64(Float64(im_m * im_m) * -0.0001984126984126984))))))));
	else
		tmp = Float64(im_m * Float64(-1.0 + Float64(0.5 * Float64(re * re))));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (re <= 1.55e+173)
		tmp = im_m * (-1.0 + (im_m * (im_m * (-0.16666666666666666 + ((im_m * im_m) * (-0.008333333333333333 + ((im_m * im_m) * -0.0001984126984126984)))))));
	else
		tmp = im_m * (-1.0 + (0.5 * (re * re)));
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 1.55e+173], N[(im$95$m * N[(-1.0 + N[(im$95$m * N[(im$95$m * N[(-0.16666666666666666 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(-0.008333333333333333 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im$95$m * N[(-1.0 + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;re \leq 1.55 \cdot 10^{+173}:\\
\;\;\;\;im\_m \cdot \left(-1 + im\_m \cdot \left(im\_m \cdot \left(-0.16666666666666666 + \left(im\_m \cdot im\_m\right) \cdot \left(-0.008333333333333333 + \left(im\_m \cdot im\_m\right) \cdot -0.0001984126984126984\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;im\_m \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 1.55e173

    1. Initial program 48.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + \color{blue}{\left(\mathsf{neg}\left(e^{im}\right)\right)}\right) \]
      2. +-commutativeN/A

        \[\leadsto \frac{1}{2} \cdot \left(\left(\mathsf{neg}\left(e^{im}\right)\right) + \color{blue}{e^{\mathsf{neg}\left(im\right)}}\right) \]
      3. distribute-rgt-inN/A

        \[\leadsto \left(\mathsf{neg}\left(e^{im}\right)\right) \cdot \frac{1}{2} + \color{blue}{e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{2} \cdot \left(\mathsf{neg}\left(e^{im}\right)\right) + \color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2} \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot \left(\mathsf{neg}\left(e^{im}\right)\right)\right), \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)}\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(\mathsf{neg}\left(e^{im}\right)\right) \cdot \frac{1}{2}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
      7. distribute-lft-neg-outN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\mathsf{neg}\left(e^{im} \cdot \frac{1}{2}\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{+.f64}\left(\left(e^{im} \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\left(e^{im} \cdot \frac{-1}{2}\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{im}\right), \frac{-1}{2}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
      11. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \left(e^{\color{blue}{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
      12. exp-negN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \left(\frac{1}{e^{im}} \cdot \frac{1}{2}\right)\right) \]
      13. associate-*l/N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \left(\frac{1 \cdot \frac{1}{2}}{\color{blue}{e^{im}}}\right)\right) \]
      14. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \left(\frac{\frac{1}{2}}{e^{\color{blue}{im}}}\right)\right) \]
      15. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right) \]
      16. exp-lowering-exp.f6439.2%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right) \]
    5. Simplified39.2%

      \[\leadsto \color{blue}{e^{im} \cdot -0.5 + \frac{0.5}{e^{im}}} \]
    6. Taylor expanded in im around 0

      \[\leadsto \color{blue}{im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right) - \frac{1}{6}\right) - 1\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right) - \frac{1}{6}\right) - 1\right)}\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right) - \frac{1}{6}\right) + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right) - \frac{1}{6}\right) + -1\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(im, \left(-1 + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right) - \frac{1}{6}\right)}\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right) - \frac{1}{6}\right)\right)}\right)\right) \]
      6. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{{im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right)} - \frac{1}{6}\right)\right)\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \left(im \cdot \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right) - \frac{1}{6}\right)\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right) - \frac{1}{6}\right)\right)}\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right) - \frac{1}{6}\right)}\right)\right)\right)\right) \]
      10. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}\right)\right)\right)\right)\right) \]
      11. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right) + \frac{-1}{6}\right)\right)\right)\right)\right) \]
      12. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{6} + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right)}\right)\right)\right)\right)\right) \]
      13. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{6}, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right)\right)}\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{-1}{5040} \cdot {im}^{2} - \frac{1}{120}\right)}\right)\right)\right)\right)\right)\right) \]
      15. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{-1}{5040} \cdot {im}^{2}} - \frac{1}{120}\right)\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{-1}{5040} \cdot {im}^{2}} - \frac{1}{120}\right)\right)\right)\right)\right)\right)\right) \]
      17. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{5040} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{120}\right)\right)}\right)\right)\right)\right)\right)\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{5040} \cdot {im}^{2} + \frac{-1}{120}\right)\right)\right)\right)\right)\right)\right) \]
    8. Simplified63.5%

      \[\leadsto \color{blue}{im \cdot \left(-1 + im \cdot \left(im \cdot \left(-0.16666666666666666 + \left(im \cdot im\right) \cdot \left(-0.008333333333333333 + \left(im \cdot im\right) \cdot -0.0001984126984126984\right)\right)\right)\right)} \]

    if 1.55e173 < re

    1. Initial program 57.6%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
      2. neg-mul-1N/A

        \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
      4. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
      6. cos-lowering-cos.f6447.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    5. Simplified47.5%

      \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
    6. Taylor expanded in re around 0

      \[\leadsto \color{blue}{-1 \cdot im + \frac{1}{2} \cdot \left(im \cdot {re}^{2}\right)} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto -1 \cdot im + \frac{1}{2} \cdot \left({re}^{2} \cdot \color{blue}{im}\right) \]
      2. associate-*r*N/A

        \[\leadsto -1 \cdot im + \left(\frac{1}{2} \cdot {re}^{2}\right) \cdot \color{blue}{im} \]
      3. distribute-rgt-outN/A

        \[\leadsto im \cdot \color{blue}{\left(-1 + \frac{1}{2} \cdot {re}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left(-1 + \frac{1}{2} \cdot {re}^{2}\right)}\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \color{blue}{\left(\frac{1}{2} \cdot {re}^{2}\right)}\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left({re}^{2}\right)}\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{re}\right)\right)\right)\right) \]
      8. *-lowering-*.f6439.0%

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right)\right) \]
    8. Simplified39.0%

      \[\leadsto \color{blue}{im \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 58.0% accurate, 14.0× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 1.55 \cdot 10^{+173}:\\ \;\;\;\;0.5 \cdot \left(im\_m \cdot \left(-2 + \left(im\_m \cdot im\_m\right) \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot -0.016666666666666666\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= re 1.55e+173)
    (*
     0.5
     (*
      im_m
      (+
       -2.0
       (*
        (* im_m im_m)
        (+ -0.3333333333333333 (* im_m (* im_m -0.016666666666666666)))))))
    (* im_m (+ -1.0 (* 0.5 (* re re)))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 1.55e+173) {
		tmp = 0.5 * (im_m * (-2.0 + ((im_m * im_m) * (-0.3333333333333333 + (im_m * (im_m * -0.016666666666666666))))));
	} else {
		tmp = im_m * (-1.0 + (0.5 * (re * re)));
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (re <= 1.55d+173) then
        tmp = 0.5d0 * (im_m * ((-2.0d0) + ((im_m * im_m) * ((-0.3333333333333333d0) + (im_m * (im_m * (-0.016666666666666666d0)))))))
    else
        tmp = im_m * ((-1.0d0) + (0.5d0 * (re * re)))
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 1.55e+173) {
		tmp = 0.5 * (im_m * (-2.0 + ((im_m * im_m) * (-0.3333333333333333 + (im_m * (im_m * -0.016666666666666666))))));
	} else {
		tmp = im_m * (-1.0 + (0.5 * (re * re)));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if re <= 1.55e+173:
		tmp = 0.5 * (im_m * (-2.0 + ((im_m * im_m) * (-0.3333333333333333 + (im_m * (im_m * -0.016666666666666666))))))
	else:
		tmp = im_m * (-1.0 + (0.5 * (re * re)))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (re <= 1.55e+173)
		tmp = Float64(0.5 * Float64(im_m * Float64(-2.0 + Float64(Float64(im_m * im_m) * Float64(-0.3333333333333333 + Float64(im_m * Float64(im_m * -0.016666666666666666)))))));
	else
		tmp = Float64(im_m * Float64(-1.0 + Float64(0.5 * Float64(re * re))));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (re <= 1.55e+173)
		tmp = 0.5 * (im_m * (-2.0 + ((im_m * im_m) * (-0.3333333333333333 + (im_m * (im_m * -0.016666666666666666))))));
	else
		tmp = im_m * (-1.0 + (0.5 * (re * re)));
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 1.55e+173], N[(0.5 * N[(im$95$m * N[(-2.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(-0.3333333333333333 + N[(im$95$m * N[(im$95$m * -0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im$95$m * N[(-1.0 + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;re \leq 1.55 \cdot 10^{+173}:\\
\;\;\;\;0.5 \cdot \left(im\_m \cdot \left(-2 + \left(im\_m \cdot im\_m\right) \cdot \left(-0.3333333333333333 + im\_m \cdot \left(im\_m \cdot -0.016666666666666666\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;im\_m \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 1.55e173

    1. Initial program 48.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) - 2\right)\right)}\right) \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) - 2\right)}\right)\right) \]
      2. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) + -2\right)\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right)}\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right)\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right)}\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{-1}{60} \cdot {im}^{2}} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{-1}{60} \cdot {im}^{2}} - \frac{1}{3}\right)\right)\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{60} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}\right)\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{60} \cdot {im}^{2} + \frac{-1}{3}\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{3} + \color{blue}{\frac{-1}{60} \cdot {im}^{2}}\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \color{blue}{\left(\frac{-1}{60} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\frac{-1}{60} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right)\right) \]
      14. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(\left(\frac{-1}{60} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \left(im \cdot \color{blue}{\left(\frac{-1}{60} \cdot im\right)}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{60} \cdot im\right)}\right)\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{-1}{60}}\right)\right)\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f6493.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{60}}\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified93.2%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot -0.016666666666666666\right)\right)\right)\right)} \]
    6. Taylor expanded in re around 0

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\frac{1}{2}}, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \frac{-1}{60}\right)\right)\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. Simplified63.0%

        \[\leadsto \color{blue}{0.5} \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot \left(-0.3333333333333333 + im \cdot \left(im \cdot -0.016666666666666666\right)\right)\right)\right) \]

      if 1.55e173 < re

      1. Initial program 57.6%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      4. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
        2. neg-mul-1N/A

          \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
        3. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
        4. neg-sub0N/A

          \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
        6. cos-lowering-cos.f6447.5%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
      5. Simplified47.5%

        \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
      6. Taylor expanded in re around 0

        \[\leadsto \color{blue}{-1 \cdot im + \frac{1}{2} \cdot \left(im \cdot {re}^{2}\right)} \]
      7. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto -1 \cdot im + \frac{1}{2} \cdot \left({re}^{2} \cdot \color{blue}{im}\right) \]
        2. associate-*r*N/A

          \[\leadsto -1 \cdot im + \left(\frac{1}{2} \cdot {re}^{2}\right) \cdot \color{blue}{im} \]
        3. distribute-rgt-outN/A

          \[\leadsto im \cdot \color{blue}{\left(-1 + \frac{1}{2} \cdot {re}^{2}\right)} \]
        4. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left(-1 + \frac{1}{2} \cdot {re}^{2}\right)}\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \color{blue}{\left(\frac{1}{2} \cdot {re}^{2}\right)}\right)\right) \]
        6. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left({re}^{2}\right)}\right)\right)\right) \]
        7. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{re}\right)\right)\right)\right) \]
        8. *-lowering-*.f6439.0%

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right)\right) \]
      8. Simplified39.0%

        \[\leadsto \color{blue}{im \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)} \]
    8. Recombined 2 regimes into one program.
    9. Add Preprocessing

    Alternative 13: 58.0% accurate, 15.4× speedup?

    \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 1.55 \cdot 10^{+173}:\\ \;\;\;\;im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot \left(-0.16666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.008333333333333333\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)\\ \end{array} \end{array} \]
    im\_m = (fabs.f64 im)
    im\_s = (copysign.f64 #s(literal 1 binary64) im)
    (FPCore (im_s re im_m)
     :precision binary64
     (*
      im_s
      (if (<= re 1.55e+173)
        (*
         im_m
         (+
          -1.0
          (*
           (* im_m im_m)
           (+ -0.16666666666666666 (* (* im_m im_m) -0.008333333333333333)))))
        (* im_m (+ -1.0 (* 0.5 (* re re)))))))
    im\_m = fabs(im);
    im\_s = copysign(1.0, im);
    double code(double im_s, double re, double im_m) {
    	double tmp;
    	if (re <= 1.55e+173) {
    		tmp = im_m * (-1.0 + ((im_m * im_m) * (-0.16666666666666666 + ((im_m * im_m) * -0.008333333333333333))));
    	} else {
    		tmp = im_m * (-1.0 + (0.5 * (re * re)));
    	}
    	return im_s * tmp;
    }
    
    im\_m = abs(im)
    im\_s = copysign(1.0d0, im)
    real(8) function code(im_s, re, im_m)
        real(8), intent (in) :: im_s
        real(8), intent (in) :: re
        real(8), intent (in) :: im_m
        real(8) :: tmp
        if (re <= 1.55d+173) then
            tmp = im_m * ((-1.0d0) + ((im_m * im_m) * ((-0.16666666666666666d0) + ((im_m * im_m) * (-0.008333333333333333d0)))))
        else
            tmp = im_m * ((-1.0d0) + (0.5d0 * (re * re)))
        end if
        code = im_s * tmp
    end function
    
    im\_m = Math.abs(im);
    im\_s = Math.copySign(1.0, im);
    public static double code(double im_s, double re, double im_m) {
    	double tmp;
    	if (re <= 1.55e+173) {
    		tmp = im_m * (-1.0 + ((im_m * im_m) * (-0.16666666666666666 + ((im_m * im_m) * -0.008333333333333333))));
    	} else {
    		tmp = im_m * (-1.0 + (0.5 * (re * re)));
    	}
    	return im_s * tmp;
    }
    
    im\_m = math.fabs(im)
    im\_s = math.copysign(1.0, im)
    def code(im_s, re, im_m):
    	tmp = 0
    	if re <= 1.55e+173:
    		tmp = im_m * (-1.0 + ((im_m * im_m) * (-0.16666666666666666 + ((im_m * im_m) * -0.008333333333333333))))
    	else:
    		tmp = im_m * (-1.0 + (0.5 * (re * re)))
    	return im_s * tmp
    
    im\_m = abs(im)
    im\_s = copysign(1.0, im)
    function code(im_s, re, im_m)
    	tmp = 0.0
    	if (re <= 1.55e+173)
    		tmp = Float64(im_m * Float64(-1.0 + Float64(Float64(im_m * im_m) * Float64(-0.16666666666666666 + Float64(Float64(im_m * im_m) * -0.008333333333333333)))));
    	else
    		tmp = Float64(im_m * Float64(-1.0 + Float64(0.5 * Float64(re * re))));
    	end
    	return Float64(im_s * tmp)
    end
    
    im\_m = abs(im);
    im\_s = sign(im) * abs(1.0);
    function tmp_2 = code(im_s, re, im_m)
    	tmp = 0.0;
    	if (re <= 1.55e+173)
    		tmp = im_m * (-1.0 + ((im_m * im_m) * (-0.16666666666666666 + ((im_m * im_m) * -0.008333333333333333))));
    	else
    		tmp = im_m * (-1.0 + (0.5 * (re * re)));
    	end
    	tmp_2 = im_s * tmp;
    end
    
    im\_m = N[Abs[im], $MachinePrecision]
    im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 1.55e+173], N[(im$95$m * N[(-1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(-0.16666666666666666 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im$95$m * N[(-1.0 + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
    
    \begin{array}{l}
    im\_m = \left|im\right|
    \\
    im\_s = \mathsf{copysign}\left(1, im\right)
    
    \\
    im\_s \cdot \begin{array}{l}
    \mathbf{if}\;re \leq 1.55 \cdot 10^{+173}:\\
    \;\;\;\;im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot \left(-0.16666666666666666 + \left(im\_m \cdot im\_m\right) \cdot -0.008333333333333333\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;im\_m \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if re < 1.55e173

      1. Initial program 48.3%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0

        \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
      4. Step-by-step derivation
        1. sub-negN/A

          \[\leadsto \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + \color{blue}{\left(\mathsf{neg}\left(e^{im}\right)\right)}\right) \]
        2. +-commutativeN/A

          \[\leadsto \frac{1}{2} \cdot \left(\left(\mathsf{neg}\left(e^{im}\right)\right) + \color{blue}{e^{\mathsf{neg}\left(im\right)}}\right) \]
        3. distribute-rgt-inN/A

          \[\leadsto \left(\mathsf{neg}\left(e^{im}\right)\right) \cdot \frac{1}{2} + \color{blue}{e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}} \]
        4. *-commutativeN/A

          \[\leadsto \frac{1}{2} \cdot \left(\mathsf{neg}\left(e^{im}\right)\right) + \color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2} \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot \left(\mathsf{neg}\left(e^{im}\right)\right)\right), \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)}\right) \]
        6. *-commutativeN/A

          \[\leadsto \mathsf{+.f64}\left(\left(\left(\mathsf{neg}\left(e^{im}\right)\right) \cdot \frac{1}{2}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
        7. distribute-lft-neg-outN/A

          \[\leadsto \mathsf{+.f64}\left(\left(\mathsf{neg}\left(e^{im} \cdot \frac{1}{2}\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
        8. distribute-rgt-neg-inN/A

          \[\leadsto \mathsf{+.f64}\left(\left(e^{im} \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
        9. metadata-evalN/A

          \[\leadsto \mathsf{+.f64}\left(\left(e^{im} \cdot \frac{-1}{2}\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right) \]
        10. *-lowering-*.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{im}\right), \frac{-1}{2}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
        11. exp-lowering-exp.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \left(e^{\color{blue}{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
        12. exp-negN/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \left(\frac{1}{e^{im}} \cdot \frac{1}{2}\right)\right) \]
        13. associate-*l/N/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \left(\frac{1 \cdot \frac{1}{2}}{\color{blue}{e^{im}}}\right)\right) \]
        14. metadata-evalN/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \left(\frac{\frac{1}{2}}{e^{\color{blue}{im}}}\right)\right) \]
        15. /-lowering-/.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right) \]
        16. exp-lowering-exp.f6439.2%

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right) \]
      5. Simplified39.2%

        \[\leadsto \color{blue}{e^{im} \cdot -0.5 + \frac{0.5}{e^{im}}} \]
      6. Taylor expanded in im around 0

        \[\leadsto \color{blue}{im \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)} \]
      7. Step-by-step derivation
        1. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)}\right) \]
        2. sub-negN/A

          \[\leadsto \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) \]
        3. metadata-evalN/A

          \[\leadsto \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) + -1\right)\right) \]
        4. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(im, \left(-1 + \color{blue}{{im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right)}\right)\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right)\right)}\right)\right) \]
        6. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right)}\right)\right)\right) \]
        7. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{-1}{120} \cdot {im}^{2}} - \frac{1}{6}\right)\right)\right)\right) \]
        8. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{-1}{120} \cdot {im}^{2}} - \frac{1}{6}\right)\right)\right)\right) \]
        9. sub-negN/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{120} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{6}\right)\right)}\right)\right)\right)\right) \]
        10. metadata-evalN/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{120} \cdot {im}^{2} + \frac{-1}{6}\right)\right)\right)\right) \]
        11. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{6} + \color{blue}{\frac{-1}{120} \cdot {im}^{2}}\right)\right)\right)\right) \]
        12. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{6}, \color{blue}{\left(\frac{-1}{120} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
        13. *-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{6}, \left({im}^{2} \cdot \color{blue}{\frac{-1}{120}}\right)\right)\right)\right)\right) \]
        14. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{-1}{120}}\right)\right)\right)\right)\right) \]
        15. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{-1}{120}\right)\right)\right)\right)\right) \]
        16. *-lowering-*.f6462.7%

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{120}\right)\right)\right)\right)\right) \]
      8. Simplified62.7%

        \[\leadsto \color{blue}{im \cdot \left(-1 + \left(im \cdot im\right) \cdot \left(-0.16666666666666666 + \left(im \cdot im\right) \cdot -0.008333333333333333\right)\right)} \]

      if 1.55e173 < re

      1. Initial program 57.6%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      4. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
        2. neg-mul-1N/A

          \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
        3. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
        4. neg-sub0N/A

          \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
        6. cos-lowering-cos.f6447.5%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
      5. Simplified47.5%

        \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
      6. Taylor expanded in re around 0

        \[\leadsto \color{blue}{-1 \cdot im + \frac{1}{2} \cdot \left(im \cdot {re}^{2}\right)} \]
      7. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto -1 \cdot im + \frac{1}{2} \cdot \left({re}^{2} \cdot \color{blue}{im}\right) \]
        2. associate-*r*N/A

          \[\leadsto -1 \cdot im + \left(\frac{1}{2} \cdot {re}^{2}\right) \cdot \color{blue}{im} \]
        3. distribute-rgt-outN/A

          \[\leadsto im \cdot \color{blue}{\left(-1 + \frac{1}{2} \cdot {re}^{2}\right)} \]
        4. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left(-1 + \frac{1}{2} \cdot {re}^{2}\right)}\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \color{blue}{\left(\frac{1}{2} \cdot {re}^{2}\right)}\right)\right) \]
        6. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left({re}^{2}\right)}\right)\right)\right) \]
        7. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{re}\right)\right)\right)\right) \]
        8. *-lowering-*.f6439.0%

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right)\right) \]
      8. Simplified39.0%

        \[\leadsto \color{blue}{im \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 14: 50.8% accurate, 16.2× speedup?

    \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 32:\\ \;\;\;\;0 - im\_m\\ \mathbf{elif}\;im\_m \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;im\_m \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(im\_m \cdot im\_m\right) \cdot \frac{-1}{im\_m}\\ \end{array} \end{array} \]
    im\_m = (fabs.f64 im)
    im\_s = (copysign.f64 #s(literal 1 binary64) im)
    (FPCore (im_s re im_m)
     :precision binary64
     (*
      im_s
      (if (<= im_m 32.0)
        (- 0.0 im_m)
        (if (<= im_m 1.35e+154)
          (* im_m (+ -1.0 (* 0.5 (* re re))))
          (* (* im_m im_m) (/ -1.0 im_m))))))
    im\_m = fabs(im);
    im\_s = copysign(1.0, im);
    double code(double im_s, double re, double im_m) {
    	double tmp;
    	if (im_m <= 32.0) {
    		tmp = 0.0 - im_m;
    	} else if (im_m <= 1.35e+154) {
    		tmp = im_m * (-1.0 + (0.5 * (re * re)));
    	} else {
    		tmp = (im_m * im_m) * (-1.0 / im_m);
    	}
    	return im_s * tmp;
    }
    
    im\_m = abs(im)
    im\_s = copysign(1.0d0, im)
    real(8) function code(im_s, re, im_m)
        real(8), intent (in) :: im_s
        real(8), intent (in) :: re
        real(8), intent (in) :: im_m
        real(8) :: tmp
        if (im_m <= 32.0d0) then
            tmp = 0.0d0 - im_m
        else if (im_m <= 1.35d+154) then
            tmp = im_m * ((-1.0d0) + (0.5d0 * (re * re)))
        else
            tmp = (im_m * im_m) * ((-1.0d0) / im_m)
        end if
        code = im_s * tmp
    end function
    
    im\_m = Math.abs(im);
    im\_s = Math.copySign(1.0, im);
    public static double code(double im_s, double re, double im_m) {
    	double tmp;
    	if (im_m <= 32.0) {
    		tmp = 0.0 - im_m;
    	} else if (im_m <= 1.35e+154) {
    		tmp = im_m * (-1.0 + (0.5 * (re * re)));
    	} else {
    		tmp = (im_m * im_m) * (-1.0 / im_m);
    	}
    	return im_s * tmp;
    }
    
    im\_m = math.fabs(im)
    im\_s = math.copysign(1.0, im)
    def code(im_s, re, im_m):
    	tmp = 0
    	if im_m <= 32.0:
    		tmp = 0.0 - im_m
    	elif im_m <= 1.35e+154:
    		tmp = im_m * (-1.0 + (0.5 * (re * re)))
    	else:
    		tmp = (im_m * im_m) * (-1.0 / im_m)
    	return im_s * tmp
    
    im\_m = abs(im)
    im\_s = copysign(1.0, im)
    function code(im_s, re, im_m)
    	tmp = 0.0
    	if (im_m <= 32.0)
    		tmp = Float64(0.0 - im_m);
    	elseif (im_m <= 1.35e+154)
    		tmp = Float64(im_m * Float64(-1.0 + Float64(0.5 * Float64(re * re))));
    	else
    		tmp = Float64(Float64(im_m * im_m) * Float64(-1.0 / im_m));
    	end
    	return Float64(im_s * tmp)
    end
    
    im\_m = abs(im);
    im\_s = sign(im) * abs(1.0);
    function tmp_2 = code(im_s, re, im_m)
    	tmp = 0.0;
    	if (im_m <= 32.0)
    		tmp = 0.0 - im_m;
    	elseif (im_m <= 1.35e+154)
    		tmp = im_m * (-1.0 + (0.5 * (re * re)));
    	else
    		tmp = (im_m * im_m) * (-1.0 / im_m);
    	end
    	tmp_2 = im_s * tmp;
    end
    
    im\_m = N[Abs[im], $MachinePrecision]
    im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 32.0], N[(0.0 - im$95$m), $MachinePrecision], If[LessEqual[im$95$m, 1.35e+154], N[(im$95$m * N[(-1.0 + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(-1.0 / im$95$m), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
    
    \begin{array}{l}
    im\_m = \left|im\right|
    \\
    im\_s = \mathsf{copysign}\left(1, im\right)
    
    \\
    im\_s \cdot \begin{array}{l}
    \mathbf{if}\;im\_m \leq 32:\\
    \;\;\;\;0 - im\_m\\
    
    \mathbf{elif}\;im\_m \leq 1.35 \cdot 10^{+154}:\\
    \;\;\;\;im\_m \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(im\_m \cdot im\_m\right) \cdot \frac{-1}{im\_m}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if im < 32

      1. Initial program 32.5%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      4. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
        2. neg-mul-1N/A

          \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
        3. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
        4. neg-sub0N/A

          \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
        6. cos-lowering-cos.f6473.6%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
      5. Simplified73.6%

        \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
      6. Taylor expanded in re around 0

        \[\leadsto \color{blue}{-1 \cdot im} \]
      7. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \mathsf{neg}\left(im\right) \]
        2. neg-sub0N/A

          \[\leadsto 0 - \color{blue}{im} \]
        3. --lowering--.f6439.8%

          \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{im}\right) \]
      8. Simplified39.8%

        \[\leadsto \color{blue}{0 - im} \]
      9. Step-by-step derivation
        1. sub0-negN/A

          \[\leadsto \mathsf{neg}\left(im\right) \]
        2. neg-lowering-neg.f6439.8%

          \[\leadsto \mathsf{neg.f64}\left(im\right) \]
      10. Applied egg-rr39.8%

        \[\leadsto \color{blue}{-im} \]

      if 32 < im < 1.35000000000000003e154

      1. Initial program 100.0%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      4. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
        2. neg-mul-1N/A

          \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
        3. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
        4. neg-sub0N/A

          \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
        6. cos-lowering-cos.f643.9%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
      5. Simplified3.9%

        \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
      6. Taylor expanded in re around 0

        \[\leadsto \color{blue}{-1 \cdot im + \frac{1}{2} \cdot \left(im \cdot {re}^{2}\right)} \]
      7. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto -1 \cdot im + \frac{1}{2} \cdot \left({re}^{2} \cdot \color{blue}{im}\right) \]
        2. associate-*r*N/A

          \[\leadsto -1 \cdot im + \left(\frac{1}{2} \cdot {re}^{2}\right) \cdot \color{blue}{im} \]
        3. distribute-rgt-outN/A

          \[\leadsto im \cdot \color{blue}{\left(-1 + \frac{1}{2} \cdot {re}^{2}\right)} \]
        4. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left(-1 + \frac{1}{2} \cdot {re}^{2}\right)}\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \color{blue}{\left(\frac{1}{2} \cdot {re}^{2}\right)}\right)\right) \]
        6. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left({re}^{2}\right)}\right)\right)\right) \]
        7. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{re}\right)\right)\right)\right) \]
        8. *-lowering-*.f6433.7%

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right)\right) \]
      8. Simplified33.7%

        \[\leadsto \color{blue}{im \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)} \]

      if 1.35000000000000003e154 < im

      1. Initial program 100.0%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      4. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
        2. neg-mul-1N/A

          \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
        3. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
        4. neg-sub0N/A

          \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
        6. cos-lowering-cos.f647.3%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
      5. Simplified7.3%

        \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
      6. Taylor expanded in re around 0

        \[\leadsto \color{blue}{-1 \cdot im} \]
      7. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \mathsf{neg}\left(im\right) \]
        2. neg-sub0N/A

          \[\leadsto 0 - \color{blue}{im} \]
        3. --lowering--.f646.3%

          \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{im}\right) \]
      8. Simplified6.3%

        \[\leadsto \color{blue}{0 - im} \]
      9. Step-by-step derivation
        1. flip--N/A

          \[\leadsto \frac{0 \cdot 0 - im \cdot im}{\color{blue}{0 + im}} \]
        2. +-lft-identityN/A

          \[\leadsto \frac{0 \cdot 0 - im \cdot im}{im} \]
        3. frac-2negN/A

          \[\leadsto \frac{\mathsf{neg}\left(\left(0 \cdot 0 - im \cdot im\right)\right)}{\color{blue}{\mathsf{neg}\left(im\right)}} \]
        4. sub0-negN/A

          \[\leadsto \frac{\mathsf{neg}\left(\left(0 \cdot 0 - im \cdot im\right)\right)}{0 - \color{blue}{im}} \]
        5. div-invN/A

          \[\leadsto \left(\mathsf{neg}\left(\left(0 \cdot 0 - im \cdot im\right)\right)\right) \cdot \color{blue}{\frac{1}{0 - im}} \]
        6. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(\left(0 - im \cdot im\right)\right)\right) \cdot \frac{1}{0 - im} \]
        7. sub0-negN/A

          \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(im \cdot im\right)\right)\right)\right) \cdot \frac{1}{0 - im} \]
        8. remove-double-negN/A

          \[\leadsto \left(im \cdot im\right) \cdot \frac{\color{blue}{1}}{0 - im} \]
        9. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(im \cdot im\right), \color{blue}{\left(\frac{1}{0 - im}\right)}\right) \]
        10. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{\color{blue}{1}}{0 - im}\right)\right) \]
        11. metadata-evalN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{\mathsf{neg}\left(-1\right)}{\color{blue}{0} - im}\right)\right) \]
        12. sub0-negN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(im\right)}\right)\right) \]
        13. frac-2negN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{\color{blue}{im}}\right)\right) \]
        14. /-lowering-/.f6486.1%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{/.f64}\left(-1, \color{blue}{im}\right)\right) \]
      10. Applied egg-rr86.1%

        \[\leadsto \color{blue}{\left(im \cdot im\right) \cdot \frac{-1}{im}} \]
    3. Recombined 3 regimes into one program.
    4. Final simplification45.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 32:\\ \;\;\;\;0 - im\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;im \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-1}{im}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 15: 55.7% accurate, 17.2× speedup?

    \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 300:\\ \;\;\;\;0 - im\_m\\ \mathbf{else}:\\ \;\;\;\;\left(im\_m \cdot \left(im\_m \cdot im\_m\right)\right) \cdot \left(-0.16666666666666666 + \left(re \cdot re\right) \cdot 0.08333333333333333\right)\\ \end{array} \end{array} \]
    im\_m = (fabs.f64 im)
    im\_s = (copysign.f64 #s(literal 1 binary64) im)
    (FPCore (im_s re im_m)
     :precision binary64
     (*
      im_s
      (if (<= im_m 300.0)
        (- 0.0 im_m)
        (*
         (* im_m (* im_m im_m))
         (+ -0.16666666666666666 (* (* re re) 0.08333333333333333))))))
    im\_m = fabs(im);
    im\_s = copysign(1.0, im);
    double code(double im_s, double re, double im_m) {
    	double tmp;
    	if (im_m <= 300.0) {
    		tmp = 0.0 - im_m;
    	} else {
    		tmp = (im_m * (im_m * im_m)) * (-0.16666666666666666 + ((re * re) * 0.08333333333333333));
    	}
    	return im_s * tmp;
    }
    
    im\_m = abs(im)
    im\_s = copysign(1.0d0, im)
    real(8) function code(im_s, re, im_m)
        real(8), intent (in) :: im_s
        real(8), intent (in) :: re
        real(8), intent (in) :: im_m
        real(8) :: tmp
        if (im_m <= 300.0d0) then
            tmp = 0.0d0 - im_m
        else
            tmp = (im_m * (im_m * im_m)) * ((-0.16666666666666666d0) + ((re * re) * 0.08333333333333333d0))
        end if
        code = im_s * tmp
    end function
    
    im\_m = Math.abs(im);
    im\_s = Math.copySign(1.0, im);
    public static double code(double im_s, double re, double im_m) {
    	double tmp;
    	if (im_m <= 300.0) {
    		tmp = 0.0 - im_m;
    	} else {
    		tmp = (im_m * (im_m * im_m)) * (-0.16666666666666666 + ((re * re) * 0.08333333333333333));
    	}
    	return im_s * tmp;
    }
    
    im\_m = math.fabs(im)
    im\_s = math.copysign(1.0, im)
    def code(im_s, re, im_m):
    	tmp = 0
    	if im_m <= 300.0:
    		tmp = 0.0 - im_m
    	else:
    		tmp = (im_m * (im_m * im_m)) * (-0.16666666666666666 + ((re * re) * 0.08333333333333333))
    	return im_s * tmp
    
    im\_m = abs(im)
    im\_s = copysign(1.0, im)
    function code(im_s, re, im_m)
    	tmp = 0.0
    	if (im_m <= 300.0)
    		tmp = Float64(0.0 - im_m);
    	else
    		tmp = Float64(Float64(im_m * Float64(im_m * im_m)) * Float64(-0.16666666666666666 + Float64(Float64(re * re) * 0.08333333333333333)));
    	end
    	return Float64(im_s * tmp)
    end
    
    im\_m = abs(im);
    im\_s = sign(im) * abs(1.0);
    function tmp_2 = code(im_s, re, im_m)
    	tmp = 0.0;
    	if (im_m <= 300.0)
    		tmp = 0.0 - im_m;
    	else
    		tmp = (im_m * (im_m * im_m)) * (-0.16666666666666666 + ((re * re) * 0.08333333333333333));
    	end
    	tmp_2 = im_s * tmp;
    end
    
    im\_m = N[Abs[im], $MachinePrecision]
    im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 300.0], N[(0.0 - im$95$m), $MachinePrecision], N[(N[(im$95$m * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision] * N[(-0.16666666666666666 + N[(N[(re * re), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
    
    \begin{array}{l}
    im\_m = \left|im\right|
    \\
    im\_s = \mathsf{copysign}\left(1, im\right)
    
    \\
    im\_s \cdot \begin{array}{l}
    \mathbf{if}\;im\_m \leq 300:\\
    \;\;\;\;0 - im\_m\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(im\_m \cdot \left(im\_m \cdot im\_m\right)\right) \cdot \left(-0.16666666666666666 + \left(re \cdot re\right) \cdot 0.08333333333333333\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if im < 300

      1. Initial program 32.5%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      4. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
        2. neg-mul-1N/A

          \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
        3. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
        4. neg-sub0N/A

          \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
        6. cos-lowering-cos.f6473.6%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
      5. Simplified73.6%

        \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
      6. Taylor expanded in re around 0

        \[\leadsto \color{blue}{-1 \cdot im} \]
      7. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \mathsf{neg}\left(im\right) \]
        2. neg-sub0N/A

          \[\leadsto 0 - \color{blue}{im} \]
        3. --lowering--.f6439.8%

          \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{im}\right) \]
      8. Simplified39.8%

        \[\leadsto \color{blue}{0 - im} \]
      9. Step-by-step derivation
        1. sub0-negN/A

          \[\leadsto \mathsf{neg}\left(im\right) \]
        2. neg-lowering-neg.f6439.8%

          \[\leadsto \mathsf{neg.f64}\left(im\right) \]
      10. Applied egg-rr39.8%

        \[\leadsto \color{blue}{-im} \]

      if 300 < im

      1. Initial program 100.0%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right)}\right) \]
      4. Step-by-step derivation
        1. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{3} \cdot {im}^{2} - 2\right)}\right)\right) \]
        2. sub-negN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(\frac{-1}{3} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right)\right) \]
        3. metadata-evalN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(\frac{-1}{3} \cdot {im}^{2} + -2\right)\right)\right) \]
        4. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \left(-2 + \color{blue}{\frac{-1}{3} \cdot {im}^{2}}\right)\right)\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \color{blue}{\left(\frac{-1}{3} \cdot {im}^{2}\right)}\right)\right)\right) \]
        6. *-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \left({im}^{2} \cdot \color{blue}{\frac{-1}{3}}\right)\right)\right)\right) \]
        7. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{-1}{3}}\right)\right)\right)\right) \]
        8. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{-1}{3}\right)\right)\right)\right) \]
        9. *-lowering-*.f6473.5%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{3}\right)\right)\right)\right) \]
      5. Simplified73.5%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot -0.3333333333333333\right)\right)} \]
      6. Taylor expanded in re around 0

        \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{3}\right)\right)\right)\right) \]
      7. Step-by-step derivation
        1. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{4} \cdot {re}^{2}\right)\right), \mathsf{*.f64}\left(\color{blue}{im}, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{3}\right)\right)\right)\right) \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left({re}^{2}\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{3}\right)\right)\right)\right) \]
        3. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left(re \cdot re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{3}\right)\right)\right)\right) \]
        4. *-lowering-*.f6466.4%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{3}\right)\right)\right)\right) \]
      8. Simplified66.4%

        \[\leadsto \color{blue}{\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \cdot \left(im \cdot \left(-2 + \left(im \cdot im\right) \cdot -0.3333333333333333\right)\right) \]
      9. Taylor expanded in im around inf

        \[\leadsto \color{blue}{\frac{-1}{3} \cdot \left({im}^{3} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)} \]
      10. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left(\frac{-1}{3} \cdot {im}^{3}\right) \cdot \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)} \]
        2. *-commutativeN/A

          \[\leadsto \left({im}^{3} \cdot \frac{-1}{3}\right) \cdot \left(\color{blue}{\frac{1}{2}} + \frac{-1}{4} \cdot {re}^{2}\right) \]
        3. associate-*r*N/A

          \[\leadsto {im}^{3} \cdot \color{blue}{\left(\frac{-1}{3} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)} \]
        4. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left({im}^{3}\right), \color{blue}{\left(\frac{-1}{3} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)}\right) \]
        5. cube-multN/A

          \[\leadsto \mathsf{*.f64}\left(\left(im \cdot \left(im \cdot im\right)\right), \left(\color{blue}{\frac{-1}{3}} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
        6. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(\left(im \cdot {im}^{2}\right), \left(\frac{-1}{3} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
        7. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \left({im}^{2}\right)\right), \left(\color{blue}{\frac{-1}{3}} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
        8. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \left(im \cdot im\right)\right), \left(\frac{-1}{3} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
        9. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right), \left(\frac{-1}{3} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
        10. distribute-rgt-inN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right), \left(\frac{1}{2} \cdot \frac{-1}{3} + \color{blue}{\left(\frac{-1}{4} \cdot {re}^{2}\right) \cdot \frac{-1}{3}}\right)\right) \]
        11. metadata-evalN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right), \left(\frac{-1}{6} + \color{blue}{\left(\frac{-1}{4} \cdot {re}^{2}\right)} \cdot \frac{-1}{3}\right)\right) \]
        12. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{-1}{6}, \color{blue}{\left(\left(\frac{-1}{4} \cdot {re}^{2}\right) \cdot \frac{-1}{3}\right)}\right)\right) \]
        13. *-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{-1}{6}, \left(\left({re}^{2} \cdot \frac{-1}{4}\right) \cdot \frac{-1}{3}\right)\right)\right) \]
        14. associate-*l*N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{-1}{6}, \left({re}^{2} \cdot \color{blue}{\left(\frac{-1}{4} \cdot \frac{-1}{3}\right)}\right)\right)\right) \]
        15. metadata-evalN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{-1}{6}, \left({re}^{2} \cdot \frac{1}{12}\right)\right)\right) \]
        16. metadata-evalN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{-1}{6}, \left({re}^{2} \cdot \left(\frac{-1}{3} \cdot \color{blue}{\frac{-1}{4}}\right)\right)\right)\right) \]
        17. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\left({re}^{2}\right), \color{blue}{\left(\frac{-1}{3} \cdot \frac{-1}{4}\right)}\right)\right)\right) \]
        18. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\left(re \cdot re\right), \left(\color{blue}{\frac{-1}{3}} \cdot \frac{-1}{4}\right)\right)\right)\right) \]
        19. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \left(\color{blue}{\frac{-1}{3}} \cdot \frac{-1}{4}\right)\right)\right)\right) \]
        20. metadata-eval66.4%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{-1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \frac{1}{12}\right)\right)\right) \]
      11. Simplified66.4%

        \[\leadsto \color{blue}{\left(im \cdot \left(im \cdot im\right)\right) \cdot \left(-0.16666666666666666 + \left(re \cdot re\right) \cdot 0.08333333333333333\right)} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification46.4%

      \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 300:\\ \;\;\;\;0 - im\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot \left(im \cdot im\right)\right) \cdot \left(-0.16666666666666666 + \left(re \cdot re\right) \cdot 0.08333333333333333\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 16: 53.5% accurate, 22.0× speedup?

    \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 1.55 \cdot 10^{+173}:\\ \;\;\;\;im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)\\ \end{array} \end{array} \]
    im\_m = (fabs.f64 im)
    im\_s = (copysign.f64 #s(literal 1 binary64) im)
    (FPCore (im_s re im_m)
     :precision binary64
     (*
      im_s
      (if (<= re 1.55e+173)
        (* im_m (+ -1.0 (* (* im_m im_m) -0.16666666666666666)))
        (* im_m (+ -1.0 (* 0.5 (* re re)))))))
    im\_m = fabs(im);
    im\_s = copysign(1.0, im);
    double code(double im_s, double re, double im_m) {
    	double tmp;
    	if (re <= 1.55e+173) {
    		tmp = im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666));
    	} else {
    		tmp = im_m * (-1.0 + (0.5 * (re * re)));
    	}
    	return im_s * tmp;
    }
    
    im\_m = abs(im)
    im\_s = copysign(1.0d0, im)
    real(8) function code(im_s, re, im_m)
        real(8), intent (in) :: im_s
        real(8), intent (in) :: re
        real(8), intent (in) :: im_m
        real(8) :: tmp
        if (re <= 1.55d+173) then
            tmp = im_m * ((-1.0d0) + ((im_m * im_m) * (-0.16666666666666666d0)))
        else
            tmp = im_m * ((-1.0d0) + (0.5d0 * (re * re)))
        end if
        code = im_s * tmp
    end function
    
    im\_m = Math.abs(im);
    im\_s = Math.copySign(1.0, im);
    public static double code(double im_s, double re, double im_m) {
    	double tmp;
    	if (re <= 1.55e+173) {
    		tmp = im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666));
    	} else {
    		tmp = im_m * (-1.0 + (0.5 * (re * re)));
    	}
    	return im_s * tmp;
    }
    
    im\_m = math.fabs(im)
    im\_s = math.copysign(1.0, im)
    def code(im_s, re, im_m):
    	tmp = 0
    	if re <= 1.55e+173:
    		tmp = im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666))
    	else:
    		tmp = im_m * (-1.0 + (0.5 * (re * re)))
    	return im_s * tmp
    
    im\_m = abs(im)
    im\_s = copysign(1.0, im)
    function code(im_s, re, im_m)
    	tmp = 0.0
    	if (re <= 1.55e+173)
    		tmp = Float64(im_m * Float64(-1.0 + Float64(Float64(im_m * im_m) * -0.16666666666666666)));
    	else
    		tmp = Float64(im_m * Float64(-1.0 + Float64(0.5 * Float64(re * re))));
    	end
    	return Float64(im_s * tmp)
    end
    
    im\_m = abs(im);
    im\_s = sign(im) * abs(1.0);
    function tmp_2 = code(im_s, re, im_m)
    	tmp = 0.0;
    	if (re <= 1.55e+173)
    		tmp = im_m * (-1.0 + ((im_m * im_m) * -0.16666666666666666));
    	else
    		tmp = im_m * (-1.0 + (0.5 * (re * re)));
    	end
    	tmp_2 = im_s * tmp;
    end
    
    im\_m = N[Abs[im], $MachinePrecision]
    im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 1.55e+173], N[(im$95$m * N[(-1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im$95$m * N[(-1.0 + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
    
    \begin{array}{l}
    im\_m = \left|im\right|
    \\
    im\_s = \mathsf{copysign}\left(1, im\right)
    
    \\
    im\_s \cdot \begin{array}{l}
    \mathbf{if}\;re \leq 1.55 \cdot 10^{+173}:\\
    \;\;\;\;im\_m \cdot \left(-1 + \left(im\_m \cdot im\_m\right) \cdot -0.16666666666666666\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;im\_m \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if re < 1.55e173

      1. Initial program 48.3%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0

        \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right)} \]
      4. Step-by-step derivation
        1. sub-negN/A

          \[\leadsto \frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + \color{blue}{\left(\mathsf{neg}\left(e^{im}\right)\right)}\right) \]
        2. +-commutativeN/A

          \[\leadsto \frac{1}{2} \cdot \left(\left(\mathsf{neg}\left(e^{im}\right)\right) + \color{blue}{e^{\mathsf{neg}\left(im\right)}}\right) \]
        3. distribute-rgt-inN/A

          \[\leadsto \left(\mathsf{neg}\left(e^{im}\right)\right) \cdot \frac{1}{2} + \color{blue}{e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}} \]
        4. *-commutativeN/A

          \[\leadsto \frac{1}{2} \cdot \left(\mathsf{neg}\left(e^{im}\right)\right) + \color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2} \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot \left(\mathsf{neg}\left(e^{im}\right)\right)\right), \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)}\right) \]
        6. *-commutativeN/A

          \[\leadsto \mathsf{+.f64}\left(\left(\left(\mathsf{neg}\left(e^{im}\right)\right) \cdot \frac{1}{2}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
        7. distribute-lft-neg-outN/A

          \[\leadsto \mathsf{+.f64}\left(\left(\mathsf{neg}\left(e^{im} \cdot \frac{1}{2}\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
        8. distribute-rgt-neg-inN/A

          \[\leadsto \mathsf{+.f64}\left(\left(e^{im} \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
        9. metadata-evalN/A

          \[\leadsto \mathsf{+.f64}\left(\left(e^{im} \cdot \frac{-1}{2}\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right) \]
        10. *-lowering-*.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(e^{im}\right), \frac{-1}{2}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
        11. exp-lowering-exp.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \left(e^{\color{blue}{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right) \]
        12. exp-negN/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \left(\frac{1}{e^{im}} \cdot \frac{1}{2}\right)\right) \]
        13. associate-*l/N/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \left(\frac{1 \cdot \frac{1}{2}}{\color{blue}{e^{im}}}\right)\right) \]
        14. metadata-evalN/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \left(\frac{\frac{1}{2}}{e^{\color{blue}{im}}}\right)\right) \]
        15. /-lowering-/.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right) \]
        16. exp-lowering-exp.f6439.2%

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{exp.f64}\left(im\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right) \]
      5. Simplified39.2%

        \[\leadsto \color{blue}{e^{im} \cdot -0.5 + \frac{0.5}{e^{im}}} \]
      6. Taylor expanded in im around 0

        \[\leadsto \color{blue}{im \cdot \left(\frac{-1}{6} \cdot {im}^{2} - 1\right)} \]
      7. Step-by-step derivation
        1. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{6} \cdot {im}^{2} - 1\right)}\right) \]
        2. sub-negN/A

          \[\leadsto \mathsf{*.f64}\left(im, \left(\frac{-1}{6} \cdot {im}^{2} + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) \]
        3. metadata-evalN/A

          \[\leadsto \mathsf{*.f64}\left(im, \left(\frac{-1}{6} \cdot {im}^{2} + -1\right)\right) \]
        4. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(im, \left(-1 + \color{blue}{\frac{-1}{6} \cdot {im}^{2}}\right)\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \color{blue}{\left(\frac{-1}{6} \cdot {im}^{2}\right)}\right)\right) \]
        6. *-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \left({im}^{2} \cdot \color{blue}{\frac{-1}{6}}\right)\right)\right) \]
        7. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{-1}{6}}\right)\right)\right) \]
        8. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{-1}{6}\right)\right)\right) \]
        9. *-lowering-*.f6458.5%

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{-1}{6}\right)\right)\right) \]
      8. Simplified58.5%

        \[\leadsto \color{blue}{im \cdot \left(-1 + \left(im \cdot im\right) \cdot -0.16666666666666666\right)} \]

      if 1.55e173 < re

      1. Initial program 57.6%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      4. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
        2. neg-mul-1N/A

          \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
        3. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
        4. neg-sub0N/A

          \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
        6. cos-lowering-cos.f6447.5%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
      5. Simplified47.5%

        \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
      6. Taylor expanded in re around 0

        \[\leadsto \color{blue}{-1 \cdot im + \frac{1}{2} \cdot \left(im \cdot {re}^{2}\right)} \]
      7. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto -1 \cdot im + \frac{1}{2} \cdot \left({re}^{2} \cdot \color{blue}{im}\right) \]
        2. associate-*r*N/A

          \[\leadsto -1 \cdot im + \left(\frac{1}{2} \cdot {re}^{2}\right) \cdot \color{blue}{im} \]
        3. distribute-rgt-outN/A

          \[\leadsto im \cdot \color{blue}{\left(-1 + \frac{1}{2} \cdot {re}^{2}\right)} \]
        4. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left(-1 + \frac{1}{2} \cdot {re}^{2}\right)}\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \color{blue}{\left(\frac{1}{2} \cdot {re}^{2}\right)}\right)\right) \]
        6. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left({re}^{2}\right)}\right)\right)\right) \]
        7. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{re}\right)\right)\right)\right) \]
        8. *-lowering-*.f6439.0%

          \[\leadsto \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right)\right) \]
      8. Simplified39.0%

        \[\leadsto \color{blue}{im \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 17: 47.6% accurate, 25.7× speedup?

    \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 2 \cdot 10^{-10}:\\ \;\;\;\;0 - im\_m\\ \mathbf{else}:\\ \;\;\;\;\left(im\_m \cdot im\_m\right) \cdot \frac{-1}{im\_m}\\ \end{array} \end{array} \]
    im\_m = (fabs.f64 im)
    im\_s = (copysign.f64 #s(literal 1 binary64) im)
    (FPCore (im_s re im_m)
     :precision binary64
     (* im_s (if (<= im_m 2e-10) (- 0.0 im_m) (* (* im_m im_m) (/ -1.0 im_m)))))
    im\_m = fabs(im);
    im\_s = copysign(1.0, im);
    double code(double im_s, double re, double im_m) {
    	double tmp;
    	if (im_m <= 2e-10) {
    		tmp = 0.0 - im_m;
    	} else {
    		tmp = (im_m * im_m) * (-1.0 / im_m);
    	}
    	return im_s * tmp;
    }
    
    im\_m = abs(im)
    im\_s = copysign(1.0d0, im)
    real(8) function code(im_s, re, im_m)
        real(8), intent (in) :: im_s
        real(8), intent (in) :: re
        real(8), intent (in) :: im_m
        real(8) :: tmp
        if (im_m <= 2d-10) then
            tmp = 0.0d0 - im_m
        else
            tmp = (im_m * im_m) * ((-1.0d0) / im_m)
        end if
        code = im_s * tmp
    end function
    
    im\_m = Math.abs(im);
    im\_s = Math.copySign(1.0, im);
    public static double code(double im_s, double re, double im_m) {
    	double tmp;
    	if (im_m <= 2e-10) {
    		tmp = 0.0 - im_m;
    	} else {
    		tmp = (im_m * im_m) * (-1.0 / im_m);
    	}
    	return im_s * tmp;
    }
    
    im\_m = math.fabs(im)
    im\_s = math.copysign(1.0, im)
    def code(im_s, re, im_m):
    	tmp = 0
    	if im_m <= 2e-10:
    		tmp = 0.0 - im_m
    	else:
    		tmp = (im_m * im_m) * (-1.0 / im_m)
    	return im_s * tmp
    
    im\_m = abs(im)
    im\_s = copysign(1.0, im)
    function code(im_s, re, im_m)
    	tmp = 0.0
    	if (im_m <= 2e-10)
    		tmp = Float64(0.0 - im_m);
    	else
    		tmp = Float64(Float64(im_m * im_m) * Float64(-1.0 / im_m));
    	end
    	return Float64(im_s * tmp)
    end
    
    im\_m = abs(im);
    im\_s = sign(im) * abs(1.0);
    function tmp_2 = code(im_s, re, im_m)
    	tmp = 0.0;
    	if (im_m <= 2e-10)
    		tmp = 0.0 - im_m;
    	else
    		tmp = (im_m * im_m) * (-1.0 / im_m);
    	end
    	tmp_2 = im_s * tmp;
    end
    
    im\_m = N[Abs[im], $MachinePrecision]
    im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 2e-10], N[(0.0 - im$95$m), $MachinePrecision], N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(-1.0 / im$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
    
    \begin{array}{l}
    im\_m = \left|im\right|
    \\
    im\_s = \mathsf{copysign}\left(1, im\right)
    
    \\
    im\_s \cdot \begin{array}{l}
    \mathbf{if}\;im\_m \leq 2 \cdot 10^{-10}:\\
    \;\;\;\;0 - im\_m\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(im\_m \cdot im\_m\right) \cdot \frac{-1}{im\_m}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if im < 2.00000000000000007e-10

      1. Initial program 32.2%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      4. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
        2. neg-mul-1N/A

          \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
        3. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
        4. neg-sub0N/A

          \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
        6. cos-lowering-cos.f6473.7%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
      5. Simplified73.7%

        \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
      6. Taylor expanded in re around 0

        \[\leadsto \color{blue}{-1 \cdot im} \]
      7. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \mathsf{neg}\left(im\right) \]
        2. neg-sub0N/A

          \[\leadsto 0 - \color{blue}{im} \]
        3. --lowering--.f6439.9%

          \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{im}\right) \]
      8. Simplified39.9%

        \[\leadsto \color{blue}{0 - im} \]
      9. Step-by-step derivation
        1. sub0-negN/A

          \[\leadsto \mathsf{neg}\left(im\right) \]
        2. neg-lowering-neg.f6439.9%

          \[\leadsto \mathsf{neg.f64}\left(im\right) \]
      10. Applied egg-rr39.9%

        \[\leadsto \color{blue}{-im} \]

      if 2.00000000000000007e-10 < im

      1. Initial program 99.8%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
      4. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
        2. neg-mul-1N/A

          \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
        3. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
        4. neg-sub0N/A

          \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
        6. cos-lowering-cos.f646.7%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
      5. Simplified6.7%

        \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
      6. Taylor expanded in re around 0

        \[\leadsto \color{blue}{-1 \cdot im} \]
      7. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \mathsf{neg}\left(im\right) \]
        2. neg-sub0N/A

          \[\leadsto 0 - \color{blue}{im} \]
        3. --lowering--.f644.9%

          \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{im}\right) \]
      8. Simplified4.9%

        \[\leadsto \color{blue}{0 - im} \]
      9. Step-by-step derivation
        1. flip--N/A

          \[\leadsto \frac{0 \cdot 0 - im \cdot im}{\color{blue}{0 + im}} \]
        2. +-lft-identityN/A

          \[\leadsto \frac{0 \cdot 0 - im \cdot im}{im} \]
        3. frac-2negN/A

          \[\leadsto \frac{\mathsf{neg}\left(\left(0 \cdot 0 - im \cdot im\right)\right)}{\color{blue}{\mathsf{neg}\left(im\right)}} \]
        4. sub0-negN/A

          \[\leadsto \frac{\mathsf{neg}\left(\left(0 \cdot 0 - im \cdot im\right)\right)}{0 - \color{blue}{im}} \]
        5. div-invN/A

          \[\leadsto \left(\mathsf{neg}\left(\left(0 \cdot 0 - im \cdot im\right)\right)\right) \cdot \color{blue}{\frac{1}{0 - im}} \]
        6. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(\left(0 - im \cdot im\right)\right)\right) \cdot \frac{1}{0 - im} \]
        7. sub0-negN/A

          \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(im \cdot im\right)\right)\right)\right) \cdot \frac{1}{0 - im} \]
        8. remove-double-negN/A

          \[\leadsto \left(im \cdot im\right) \cdot \frac{\color{blue}{1}}{0 - im} \]
        9. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\left(im \cdot im\right), \color{blue}{\left(\frac{1}{0 - im}\right)}\right) \]
        10. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{\color{blue}{1}}{0 - im}\right)\right) \]
        11. metadata-evalN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{\mathsf{neg}\left(-1\right)}{\color{blue}{0} - im}\right)\right) \]
        12. sub0-negN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(im\right)}\right)\right) \]
        13. frac-2negN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{-1}{\color{blue}{im}}\right)\right) \]
        14. /-lowering-/.f6449.1%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{/.f64}\left(-1, \color{blue}{im}\right)\right) \]
      10. Applied egg-rr49.1%

        \[\leadsto \color{blue}{\left(im \cdot im\right) \cdot \frac{-1}{im}} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification42.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2 \cdot 10^{-10}:\\ \;\;\;\;0 - im\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-1}{im}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 18: 29.3% accurate, 103.0× speedup?

    \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \left(0 - im\_m\right) \end{array} \]
    im\_m = (fabs.f64 im)
    im\_s = (copysign.f64 #s(literal 1 binary64) im)
    (FPCore (im_s re im_m) :precision binary64 (* im_s (- 0.0 im_m)))
    im\_m = fabs(im);
    im\_s = copysign(1.0, im);
    double code(double im_s, double re, double im_m) {
    	return im_s * (0.0 - im_m);
    }
    
    im\_m = abs(im)
    im\_s = copysign(1.0d0, im)
    real(8) function code(im_s, re, im_m)
        real(8), intent (in) :: im_s
        real(8), intent (in) :: re
        real(8), intent (in) :: im_m
        code = im_s * (0.0d0 - im_m)
    end function
    
    im\_m = Math.abs(im);
    im\_s = Math.copySign(1.0, im);
    public static double code(double im_s, double re, double im_m) {
    	return im_s * (0.0 - im_m);
    }
    
    im\_m = math.fabs(im)
    im\_s = math.copysign(1.0, im)
    def code(im_s, re, im_m):
    	return im_s * (0.0 - im_m)
    
    im\_m = abs(im)
    im\_s = copysign(1.0, im)
    function code(im_s, re, im_m)
    	return Float64(im_s * Float64(0.0 - im_m))
    end
    
    im\_m = abs(im);
    im\_s = sign(im) * abs(1.0);
    function tmp = code(im_s, re, im_m)
    	tmp = im_s * (0.0 - im_m);
    end
    
    im\_m = N[Abs[im], $MachinePrecision]
    im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[im$95$s_, re_, im$95$m_] := N[(im$95$s * N[(0.0 - im$95$m), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    im\_m = \left|im\right|
    \\
    im\_s = \mathsf{copysign}\left(1, im\right)
    
    \\
    im\_s \cdot \left(0 - im\_m\right)
    \end{array}
    
    Derivation
    1. Initial program 49.4%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(-1 \cdot im\right) \cdot \color{blue}{\cos re} \]
      2. neg-mul-1N/A

        \[\leadsto \left(\mathsf{neg}\left(im\right)\right) \cdot \cos \color{blue}{re} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{neg}\left(im\right)\right), \color{blue}{\cos re}\right) \]
      4. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\left(0 - im\right), \cos \color{blue}{re}\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \cos \color{blue}{re}\right) \]
      6. cos-lowering-cos.f6456.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, im\right), \mathsf{cos.f64}\left(re\right)\right) \]
    5. Simplified56.7%

      \[\leadsto \color{blue}{\left(0 - im\right) \cdot \cos re} \]
    6. Taylor expanded in re around 0

      \[\leadsto \color{blue}{-1 \cdot im} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(im\right) \]
      2. neg-sub0N/A

        \[\leadsto 0 - \color{blue}{im} \]
      3. --lowering--.f6431.0%

        \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{im}\right) \]
    8. Simplified31.0%

      \[\leadsto \color{blue}{0 - im} \]
    9. Step-by-step derivation
      1. sub0-negN/A

        \[\leadsto \mathsf{neg}\left(im\right) \]
      2. neg-lowering-neg.f6431.0%

        \[\leadsto \mathsf{neg.f64}\left(im\right) \]
    10. Applied egg-rr31.0%

      \[\leadsto \color{blue}{-im} \]
    11. Final simplification31.0%

      \[\leadsto 0 - im \]
    12. Add Preprocessing

    Developer Target 1: 99.8% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|im\right| < 1:\\ \;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\ \end{array} \end{array} \]
    (FPCore (re im)
     :precision binary64
     (if (< (fabs im) 1.0)
       (-
        (*
         (cos re)
         (+
          (+ im (* (* (* 0.16666666666666666 im) im) im))
          (* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
       (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
    double code(double re, double im) {
    	double tmp;
    	if (fabs(im) < 1.0) {
    		tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
    	} else {
    		tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
    	}
    	return tmp;
    }
    
    real(8) function code(re, im)
        real(8), intent (in) :: re
        real(8), intent (in) :: im
        real(8) :: tmp
        if (abs(im) < 1.0d0) then
            tmp = -(cos(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
        else
            tmp = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
        end if
        code = tmp
    end function
    
    public static double code(double re, double im) {
    	double tmp;
    	if (Math.abs(im) < 1.0) {
    		tmp = -(Math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
    	} else {
    		tmp = (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
    	}
    	return tmp;
    }
    
    def code(re, im):
    	tmp = 0
    	if math.fabs(im) < 1.0:
    		tmp = -(math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)))
    	else:
    		tmp = (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
    	return tmp
    
    function code(re, im)
    	tmp = 0.0
    	if (abs(im) < 1.0)
    		tmp = Float64(-Float64(cos(re) * Float64(Float64(im + Float64(Float64(Float64(0.16666666666666666 * im) * im) * im)) + Float64(Float64(Float64(Float64(Float64(0.008333333333333333 * im) * im) * im) * im) * im))));
    	else
    		tmp = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(re, im)
    	tmp = 0.0;
    	if (abs(im) < 1.0)
    		tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
    	else
    		tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
    	end
    	tmp_2 = tmp;
    end
    
    code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Cos[re], $MachinePrecision] * N[(N[(im + N[(N[(N[(0.16666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\left|im\right| < 1:\\
    \;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
    
    
    \end{array}
    \end{array}
    

    Reproduce

    ?
    herbie shell --seed 2024185 
    (FPCore (re im)
      :name "math.sin on complex, imaginary part"
      :precision binary64
    
      :alt
      (! :herbie-platform default (if (< (fabs im) 1) (- (* (cos re) (+ im (* 1/6 im im im) (* 1/120 im im im im im)))) (* (* 1/2 (cos re)) (- (exp (- 0 im)) (exp im)))))
    
      (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))