math.sin on complex, imaginary part

Percentage Accurate: 53.8% → 99.7%
Time: 14.6s
Alternatives: 16
Speedup: 2.9×

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 16 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: 53.8% 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.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{elif}\;t_0 \leq 0.02:\\ \;\;\;\;\cos re \cdot \left(\left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right) - im\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(e^{im} \cdot -0.5 + 0.5 \cdot \frac{1}{e^{im}}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (<= t_0 (- INFINITY))
     (* (* 0.5 (cos re)) t_0)
     (if (<= t_0 0.02)
       (*
        (cos re)
        (-
         (+
          (* -0.16666666666666666 (pow im 3.0))
          (* -0.008333333333333333 (pow im 5.0)))
         im))
       (* (cos re) (+ (* (exp im) -0.5) (* 0.5 (/ 1.0 (exp im)))))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else if (t_0 <= 0.02) {
		tmp = cos(re) * (((-0.16666666666666666 * pow(im, 3.0)) + (-0.008333333333333333 * pow(im, 5.0))) - im);
	} else {
		tmp = cos(re) * ((exp(im) * -0.5) + (0.5 * (1.0 / exp(im))));
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else if (t_0 <= 0.02) {
		tmp = Math.cos(re) * (((-0.16666666666666666 * Math.pow(im, 3.0)) + (-0.008333333333333333 * Math.pow(im, 5.0))) - im);
	} else {
		tmp = Math.cos(re) * ((Math.exp(im) * -0.5) + (0.5 * (1.0 / Math.exp(im))));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if t_0 <= -math.inf:
		tmp = (0.5 * math.cos(re)) * t_0
	elif t_0 <= 0.02:
		tmp = math.cos(re) * (((-0.16666666666666666 * math.pow(im, 3.0)) + (-0.008333333333333333 * math.pow(im, 5.0))) - im)
	else:
		tmp = math.cos(re) * ((math.exp(im) * -0.5) + (0.5 * (1.0 / math.exp(im))))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	elseif (t_0 <= 0.02)
		tmp = Float64(cos(re) * Float64(Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) + Float64(-0.008333333333333333 * (im ^ 5.0))) - im));
	else
		tmp = Float64(cos(re) * Float64(Float64(exp(im) * -0.5) + Float64(0.5 * Float64(1.0 / exp(im)))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = (0.5 * cos(re)) * t_0;
	elseif (t_0 <= 0.02)
		tmp = cos(re) * (((-0.16666666666666666 * (im ^ 3.0)) + (-0.008333333333333333 * (im ^ 5.0))) - im);
	else
		tmp = cos(re) * ((exp(im) * -0.5) + (0.5 * (1.0 / exp(im))));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[t$95$0, 0.02], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Exp[im], $MachinePrecision] * -0.5), $MachinePrecision] + N[(0.5 * N[(1.0 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;t_0 \leq 0.02:\\
\;\;\;\;\cos re \cdot \left(\left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right) - im\right)\\

\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(e^{im} \cdot -0.5 + 0.5 \cdot \frac{1}{e^{im}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 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. Step-by-step derivation
      1. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

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

    if -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 0.0200000000000000004

    1. Initial program 8.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg8.5%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative8.5%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*8.5%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg8.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub08.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative8.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in8.5%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg8.5%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in8.5%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in8.5%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out8.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in8.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval8.5%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval8.5%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def8.5%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval8.5%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub08.5%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff8.4%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified8.4%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 99.8%

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

    if 0.0200000000000000004 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around inf 100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -\infty:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;e^{-im} - e^{im} \leq 0.02:\\ \;\;\;\;\cos re \cdot \left(\left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right) - im\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(e^{im} \cdot -0.5 + 0.5 \cdot \frac{1}{e^{im}}\right)\\ \end{array} \]

Alternative 2: 99.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{-15}:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(e^{im} \cdot -0.5 + 0.5 \cdot \frac{1}{e^{im}}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (<= t_0 (- INFINITY))
     (* (* 0.5 (cos re)) t_0)
     (if (<= t_0 2e-15)
       (* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im))
       (* (cos re) (+ (* (exp im) -0.5) (* 0.5 (/ 1.0 (exp im)))))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else if (t_0 <= 2e-15) {
		tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
	} else {
		tmp = cos(re) * ((exp(im) * -0.5) + (0.5 * (1.0 / exp(im))));
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else if (t_0 <= 2e-15) {
		tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
	} else {
		tmp = Math.cos(re) * ((Math.exp(im) * -0.5) + (0.5 * (1.0 / Math.exp(im))));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if t_0 <= -math.inf:
		tmp = (0.5 * math.cos(re)) * t_0
	elif t_0 <= 2e-15:
		tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im)
	else:
		tmp = math.cos(re) * ((math.exp(im) * -0.5) + (0.5 * (1.0 / math.exp(im))))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	elseif (t_0 <= 2e-15)
		tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im));
	else
		tmp = Float64(cos(re) * Float64(Float64(exp(im) * -0.5) + Float64(0.5 * Float64(1.0 / exp(im)))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = (0.5 * cos(re)) * t_0;
	elseif (t_0 <= 2e-15)
		tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im);
	else
		tmp = cos(re) * ((exp(im) * -0.5) + (0.5 * (1.0 / exp(im))));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[t$95$0, 2e-15], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Exp[im], $MachinePrecision] * -0.5), $MachinePrecision] + N[(0.5 * N[(1.0 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-15}:\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\

\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(e^{im} \cdot -0.5 + 0.5 \cdot \frac{1}{e^{im}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 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. Step-by-step derivation
      1. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified100.0%

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

    if -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 2.0000000000000002e-15

    1. Initial program 7.8%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg7.8%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative7.8%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*7.8%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg7.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub07.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative7.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in7.8%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg7.8%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in7.8%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in7.8%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out7.8%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in7.8%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval7.8%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval7.8%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def7.8%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval7.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub07.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff7.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified7.8%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 99.8%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*99.8%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) \]
      2. associate-*r*99.8%

        \[\leadsto \left(-1 \cdot im\right) \cdot \cos re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      3. distribute-rgt-out99.8%

        \[\leadsto \color{blue}{\cos re \cdot \left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right)} \]
      4. *-commutative99.8%

        \[\leadsto \color{blue}{\left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      5. +-commutative99.8%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} + -1 \cdot im\right)} \cdot \cos re \]
      6. neg-mul-199.8%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} + \color{blue}{\left(-im\right)}\right) \cdot \cos re \]
      7. unsub-neg99.8%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \cdot \cos re \]
    6. Simplified99.8%

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

    if 2.0000000000000002e-15 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 99.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg99.9%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative99.9%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*99.9%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg99.9%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub099.9%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative99.9%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in99.9%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg99.9%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in99.9%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in99.9%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out99.9%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in99.9%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval99.9%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval99.9%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def99.9%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval99.9%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub099.9%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff99.9%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around inf 99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -\infty:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;e^{-im} - e^{im} \leq 2 \cdot 10^{-15}:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(e^{im} \cdot -0.5 + 0.5 \cdot \frac{1}{e^{im}}\right)\\ \end{array} \]

Alternative 3: 99.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 2 \cdot 10^{-15}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e-15)))
     (* (* 0.5 (cos re)) t_0)
     (* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im)))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 2e-15)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 2e-15)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 2e-15):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im)
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 2e-15))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 2e-15)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 2e-15]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 2 \cdot 10^{-15}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -inf.0 or 2.0000000000000002e-15 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 99.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub099.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.9%

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

    if -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 2.0000000000000002e-15

    1. Initial program 7.8%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg7.8%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative7.8%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*7.8%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg7.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub07.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative7.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in7.8%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg7.8%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in7.8%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in7.8%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out7.8%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in7.8%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval7.8%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval7.8%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def7.8%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval7.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub07.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff7.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified7.8%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 99.8%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*99.8%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) \]
      2. associate-*r*99.8%

        \[\leadsto \left(-1 \cdot im\right) \cdot \cos re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      3. distribute-rgt-out99.8%

        \[\leadsto \color{blue}{\cos re \cdot \left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right)} \]
      4. *-commutative99.8%

        \[\leadsto \color{blue}{\left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      5. +-commutative99.8%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} + -1 \cdot im\right)} \cdot \cos re \]
      6. neg-mul-199.8%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} + \color{blue}{\left(-im\right)}\right) \cdot \cos re \]
      7. unsub-neg99.8%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \cdot \cos re \]
    6. Simplified99.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -\infty \lor \neg \left(e^{-im} - e^{im} \leq 2 \cdot 10^{-15}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \end{array} \]

Alternative 4: 97.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\ t_1 := -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\ \mathbf{if}\;im \leq -4.5 \cdot 10^{+61}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.048:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.28:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (- (exp (- im)) (exp im)) (+ 0.5 (* (* re re) -0.25))))
        (t_1 (* -0.008333333333333333 (* (cos re) (pow im 5.0)))))
   (if (<= im -4.5e+61)
     t_1
     (if (<= im -0.048)
       t_0
       (if (<= im 0.28)
         (* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im))
         (if (<= im 4.4e+61) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = (exp(-im) - exp(im)) * (0.5 + ((re * re) * -0.25));
	double t_1 = -0.008333333333333333 * (cos(re) * pow(im, 5.0));
	double tmp;
	if (im <= -4.5e+61) {
		tmp = t_1;
	} else if (im <= -0.048) {
		tmp = t_0;
	} else if (im <= 0.28) {
		tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
	} else if (im <= 4.4e+61) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (exp(-im) - exp(im)) * (0.5d0 + ((re * re) * (-0.25d0)))
    t_1 = (-0.008333333333333333d0) * (cos(re) * (im ** 5.0d0))
    if (im <= (-4.5d+61)) then
        tmp = t_1
    else if (im <= (-0.048d0)) then
        tmp = t_0
    else if (im <= 0.28d0) then
        tmp = cos(re) * (((-0.16666666666666666d0) * (im ** 3.0d0)) - im)
    else if (im <= 4.4d+61) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (Math.exp(-im) - Math.exp(im)) * (0.5 + ((re * re) * -0.25));
	double t_1 = -0.008333333333333333 * (Math.cos(re) * Math.pow(im, 5.0));
	double tmp;
	if (im <= -4.5e+61) {
		tmp = t_1;
	} else if (im <= -0.048) {
		tmp = t_0;
	} else if (im <= 0.28) {
		tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
	} else if (im <= 4.4e+61) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.exp(-im) - math.exp(im)) * (0.5 + ((re * re) * -0.25))
	t_1 = -0.008333333333333333 * (math.cos(re) * math.pow(im, 5.0))
	tmp = 0
	if im <= -4.5e+61:
		tmp = t_1
	elif im <= -0.048:
		tmp = t_0
	elif im <= 0.28:
		tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im)
	elif im <= 4.4e+61:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 + Float64(Float64(re * re) * -0.25)))
	t_1 = Float64(-0.008333333333333333 * Float64(cos(re) * (im ^ 5.0)))
	tmp = 0.0
	if (im <= -4.5e+61)
		tmp = t_1;
	elseif (im <= -0.048)
		tmp = t_0;
	elseif (im <= 0.28)
		tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im));
	elseif (im <= 4.4e+61)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (exp(-im) - exp(im)) * (0.5 + ((re * re) * -0.25));
	t_1 = -0.008333333333333333 * (cos(re) * (im ^ 5.0));
	tmp = 0.0;
	if (im <= -4.5e+61)
		tmp = t_1;
	elseif (im <= -0.048)
		tmp = t_0;
	elseif (im <= 0.28)
		tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im);
	elseif (im <= 4.4e+61)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.008333333333333333 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.5e+61], t$95$1, If[LessEqual[im, -0.048], t$95$0, If[LessEqual[im, 0.28], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.4e+61], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\
t_1 := -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\
\mathbf{if}\;im \leq -4.5 \cdot 10^{+61}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -0.048:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 0.28:\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\

\mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4.5e61 or 4.4000000000000001e61 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \cos re \cdot \color{blue}{\left(-1 \cdot im + \left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right)\right)} \]
    5. Taylor expanded in im around inf 100.0%

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

    if -4.5e61 < im < -0.048000000000000001 or 0.28000000000000003 < im < 4.4000000000000001e61

    1. Initial program 99.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub099.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 4.1%

      \[\leadsto \color{blue}{-0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. associate-*r*4.1%

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. distribute-rgt-out88.1%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      3. +-commutative88.1%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \color{blue}{\left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      4. *-commutative88.1%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      5. unpow288.1%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
    6. Simplified88.1%

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

    if -0.048000000000000001 < im < 0.28000000000000003

    1. Initial program 8.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg8.5%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative8.5%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*8.5%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg8.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub08.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative8.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in8.5%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg8.5%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in8.5%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in8.5%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out8.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in8.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval8.5%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval8.5%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def8.5%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval8.5%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub08.5%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff8.4%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified8.4%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 99.6%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*99.6%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) \]
      2. associate-*r*99.6%

        \[\leadsto \left(-1 \cdot im\right) \cdot \cos re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      3. distribute-rgt-out99.6%

        \[\leadsto \color{blue}{\cos re \cdot \left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right)} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      5. +-commutative99.6%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} + -1 \cdot im\right)} \cdot \cos re \]
      6. neg-mul-199.6%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} + \color{blue}{\left(-im\right)}\right) \cdot \cos re \]
      7. unsub-neg99.6%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \cdot \cos re \]
    6. Simplified99.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.5 \cdot 10^{+61}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq -0.048:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\ \mathbf{elif}\;im \leq 0.28:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\ \end{array} \]

Alternative 5: 94.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\ \mathbf{if}\;im \leq -2.8 \cdot 10^{+78}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.0066:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 55000000000000:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+48}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
        (t_1 (* -0.008333333333333333 (* (cos re) (pow im 5.0)))))
   (if (<= im -2.8e+78)
     t_1
     (if (<= im -0.0066)
       t_0
       (if (<= im 55000000000000.0)
         (* im (- (cos re)))
         (if (<= im 7.5e+48) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double t_1 = -0.008333333333333333 * (cos(re) * pow(im, 5.0));
	double tmp;
	if (im <= -2.8e+78) {
		tmp = t_1;
	} else if (im <= -0.0066) {
		tmp = t_0;
	} else if (im <= 55000000000000.0) {
		tmp = im * -cos(re);
	} else if (im <= 7.5e+48) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * (exp(-im) - exp(im))
    t_1 = (-0.008333333333333333d0) * (cos(re) * (im ** 5.0d0))
    if (im <= (-2.8d+78)) then
        tmp = t_1
    else if (im <= (-0.0066d0)) then
        tmp = t_0
    else if (im <= 55000000000000.0d0) then
        tmp = im * -cos(re)
    else if (im <= 7.5d+48) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
	double t_1 = -0.008333333333333333 * (Math.cos(re) * Math.pow(im, 5.0));
	double tmp;
	if (im <= -2.8e+78) {
		tmp = t_1;
	} else if (im <= -0.0066) {
		tmp = t_0;
	} else if (im <= 55000000000000.0) {
		tmp = im * -Math.cos(re);
	} else if (im <= 7.5e+48) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * (math.exp(-im) - math.exp(im))
	t_1 = -0.008333333333333333 * (math.cos(re) * math.pow(im, 5.0))
	tmp = 0
	if im <= -2.8e+78:
		tmp = t_1
	elif im <= -0.0066:
		tmp = t_0
	elif im <= 55000000000000.0:
		tmp = im * -math.cos(re)
	elif im <= 7.5e+48:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	t_1 = Float64(-0.008333333333333333 * Float64(cos(re) * (im ^ 5.0)))
	tmp = 0.0
	if (im <= -2.8e+78)
		tmp = t_1;
	elseif (im <= -0.0066)
		tmp = t_0;
	elseif (im <= 55000000000000.0)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 7.5e+48)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * (exp(-im) - exp(im));
	t_1 = -0.008333333333333333 * (cos(re) * (im ^ 5.0));
	tmp = 0.0;
	if (im <= -2.8e+78)
		tmp = t_1;
	elseif (im <= -0.0066)
		tmp = t_0;
	elseif (im <= 55000000000000.0)
		tmp = im * -cos(re);
	elseif (im <= 7.5e+48)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.008333333333333333 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.8e+78], t$95$1, If[LessEqual[im, -0.0066], t$95$0, If[LessEqual[im, 55000000000000.0], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 7.5e+48], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\
\mathbf{if}\;im \leq -2.8 \cdot 10^{+78}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -0.0066:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 55000000000000:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\

\mathbf{elif}\;im \leq 7.5 \cdot 10^{+48}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.8000000000000001e78 or 7.5000000000000006e48 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 98.1%

      \[\leadsto \cos re \cdot \color{blue}{\left(-1 \cdot im + \left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right)\right)} \]
    5. Taylor expanded in im around inf 98.1%

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

    if -2.8000000000000001e78 < im < -0.0066 or 5.5e13 < im < 7.5000000000000006e48

    1. Initial program 99.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub099.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 80.0%

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

    if -0.0066 < im < 5.5e13

    1. Initial program 9.2%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg9.2%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative9.2%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*9.2%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg9.2%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub09.2%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative9.2%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in9.2%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg9.2%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in9.2%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in9.2%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out9.2%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in9.2%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval9.2%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval9.2%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def9.2%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval9.2%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub09.2%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff9.1%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified9.1%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 98.3%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*98.3%

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified98.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.8 \cdot 10^{+78}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq -0.0066:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 55000000000000:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+48}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\ \end{array} \]

Alternative 6: 95.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\ \mathbf{if}\;im \leq -2.8 \cdot 10^{+78}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.048:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 55000000000000:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+48}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
        (t_1 (* -0.008333333333333333 (* (cos re) (pow im 5.0)))))
   (if (<= im -2.8e+78)
     t_1
     (if (<= im -0.048)
       t_0
       (if (<= im 55000000000000.0)
         (* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im))
         (if (<= im 7.5e+48) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double t_1 = -0.008333333333333333 * (cos(re) * pow(im, 5.0));
	double tmp;
	if (im <= -2.8e+78) {
		tmp = t_1;
	} else if (im <= -0.048) {
		tmp = t_0;
	} else if (im <= 55000000000000.0) {
		tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
	} else if (im <= 7.5e+48) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * (exp(-im) - exp(im))
    t_1 = (-0.008333333333333333d0) * (cos(re) * (im ** 5.0d0))
    if (im <= (-2.8d+78)) then
        tmp = t_1
    else if (im <= (-0.048d0)) then
        tmp = t_0
    else if (im <= 55000000000000.0d0) then
        tmp = cos(re) * (((-0.16666666666666666d0) * (im ** 3.0d0)) - im)
    else if (im <= 7.5d+48) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
	double t_1 = -0.008333333333333333 * (Math.cos(re) * Math.pow(im, 5.0));
	double tmp;
	if (im <= -2.8e+78) {
		tmp = t_1;
	} else if (im <= -0.048) {
		tmp = t_0;
	} else if (im <= 55000000000000.0) {
		tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im);
	} else if (im <= 7.5e+48) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * (math.exp(-im) - math.exp(im))
	t_1 = -0.008333333333333333 * (math.cos(re) * math.pow(im, 5.0))
	tmp = 0
	if im <= -2.8e+78:
		tmp = t_1
	elif im <= -0.048:
		tmp = t_0
	elif im <= 55000000000000.0:
		tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im)
	elif im <= 7.5e+48:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	t_1 = Float64(-0.008333333333333333 * Float64(cos(re) * (im ^ 5.0)))
	tmp = 0.0
	if (im <= -2.8e+78)
		tmp = t_1;
	elseif (im <= -0.048)
		tmp = t_0;
	elseif (im <= 55000000000000.0)
		tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im));
	elseif (im <= 7.5e+48)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * (exp(-im) - exp(im));
	t_1 = -0.008333333333333333 * (cos(re) * (im ^ 5.0));
	tmp = 0.0;
	if (im <= -2.8e+78)
		tmp = t_1;
	elseif (im <= -0.048)
		tmp = t_0;
	elseif (im <= 55000000000000.0)
		tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im);
	elseif (im <= 7.5e+48)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.008333333333333333 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.8e+78], t$95$1, If[LessEqual[im, -0.048], t$95$0, If[LessEqual[im, 55000000000000.0], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 7.5e+48], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\
\mathbf{if}\;im \leq -2.8 \cdot 10^{+78}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -0.048:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 55000000000000:\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\

\mathbf{elif}\;im \leq 7.5 \cdot 10^{+48}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.8000000000000001e78 or 7.5000000000000006e48 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 98.1%

      \[\leadsto \cos re \cdot \color{blue}{\left(-1 \cdot im + \left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right)\right)} \]
    5. Taylor expanded in im around inf 98.1%

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

    if -2.8000000000000001e78 < im < -0.048000000000000001 or 5.5e13 < im < 7.5000000000000006e48

    1. Initial program 99.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub099.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 80.0%

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

    if -0.048000000000000001 < im < 5.5e13

    1. Initial program 9.2%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg9.2%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative9.2%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*9.2%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg9.2%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub09.2%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative9.2%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in9.2%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg9.2%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in9.2%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in9.2%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out9.2%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in9.2%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval9.2%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval9.2%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def9.2%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval9.2%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub09.2%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff9.1%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified9.1%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 98.9%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*98.9%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) \]
      2. associate-*r*98.9%

        \[\leadsto \left(-1 \cdot im\right) \cdot \cos re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      3. distribute-rgt-out98.9%

        \[\leadsto \color{blue}{\cos re \cdot \left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right)} \]
      4. *-commutative98.9%

        \[\leadsto \color{blue}{\left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      5. +-commutative98.9%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} + -1 \cdot im\right)} \cdot \cos re \]
      6. neg-mul-198.9%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} + \color{blue}{\left(-im\right)}\right) \cdot \cos re \]
      7. unsub-neg98.9%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \cdot \cos re \]
    6. Simplified98.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.8 \cdot 10^{+78}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq -0.048:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 55000000000000:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+48}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\ \end{array} \]

Alternative 7: 89.4% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -3.3 \lor \neg \left(im \leq 3.4\right):\\ \;\;\;\;-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -3.3) (not (<= im 3.4)))
   (* -0.008333333333333333 (* (cos re) (pow im 5.0)))
   (* im (- (cos re)))))
double code(double re, double im) {
	double tmp;
	if ((im <= -3.3) || !(im <= 3.4)) {
		tmp = -0.008333333333333333 * (cos(re) * pow(im, 5.0));
	} else {
		tmp = im * -cos(re);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-3.3d0)) .or. (.not. (im <= 3.4d0))) then
        tmp = (-0.008333333333333333d0) * (cos(re) * (im ** 5.0d0))
    else
        tmp = im * -cos(re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -3.3) || !(im <= 3.4)) {
		tmp = -0.008333333333333333 * (Math.cos(re) * Math.pow(im, 5.0));
	} else {
		tmp = im * -Math.cos(re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -3.3) or not (im <= 3.4):
		tmp = -0.008333333333333333 * (math.cos(re) * math.pow(im, 5.0))
	else:
		tmp = im * -math.cos(re)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -3.3) || !(im <= 3.4))
		tmp = Float64(-0.008333333333333333 * Float64(cos(re) * (im ^ 5.0)));
	else
		tmp = Float64(im * Float64(-cos(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -3.3) || ~((im <= 3.4)))
		tmp = -0.008333333333333333 * (cos(re) * (im ^ 5.0));
	else
		tmp = im * -cos(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -3.3], N[Not[LessEqual[im, 3.4]], $MachinePrecision]], N[(-0.008333333333333333 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.3 \lor \neg \left(im \leq 3.4\right):\\
\;\;\;\;-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -3.2999999999999998 or 3.39999999999999991 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 81.2%

      \[\leadsto \cos re \cdot \color{blue}{\left(-1 \cdot im + \left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right)\right)} \]
    5. Taylor expanded in im around inf 81.2%

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

    if -3.2999999999999998 < im < 3.39999999999999991

    1. Initial program 9.2%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg9.2%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative9.2%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*9.2%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg9.2%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub09.2%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative9.2%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in9.2%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg9.2%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in9.2%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in9.2%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out9.2%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in9.2%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval9.2%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval9.2%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def9.2%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval9.2%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub09.2%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff9.1%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified9.1%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 98.5%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*98.5%

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified98.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.3 \lor \neg \left(im \leq 3.4\right):\\ \;\;\;\;-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 8: 79.6% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -0.16666666666666666 \cdot {im}^{3}\\ t_1 := 1 + -0.5 \cdot \left(re \cdot re\right)\\ \mathbf{if}\;im \leq -2.5 \cdot 10^{+102}:\\ \;\;\;\;t_0 \cdot t_1\\ \mathbf{elif}\;im \leq -4.4 \cdot 10^{+37}:\\ \;\;\;\;-0.008333333333333333 \cdot {im}^{5}\\ \mathbf{elif}\;im \leq -0.07 \lor \neg \left(im \leq 480\right):\\ \;\;\;\;\left(t_0 - im\right) \cdot t_1\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* -0.16666666666666666 (pow im 3.0)))
        (t_1 (+ 1.0 (* -0.5 (* re re)))))
   (if (<= im -2.5e+102)
     (* t_0 t_1)
     (if (<= im -4.4e+37)
       (* -0.008333333333333333 (pow im 5.0))
       (if (or (<= im -0.07) (not (<= im 480.0)))
         (* (- t_0 im) t_1)
         (* im (- (cos re))))))))
double code(double re, double im) {
	double t_0 = -0.16666666666666666 * pow(im, 3.0);
	double t_1 = 1.0 + (-0.5 * (re * re));
	double tmp;
	if (im <= -2.5e+102) {
		tmp = t_0 * t_1;
	} else if (im <= -4.4e+37) {
		tmp = -0.008333333333333333 * pow(im, 5.0);
	} else if ((im <= -0.07) || !(im <= 480.0)) {
		tmp = (t_0 - im) * t_1;
	} else {
		tmp = im * -cos(re);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (-0.16666666666666666d0) * (im ** 3.0d0)
    t_1 = 1.0d0 + ((-0.5d0) * (re * re))
    if (im <= (-2.5d+102)) then
        tmp = t_0 * t_1
    else if (im <= (-4.4d+37)) then
        tmp = (-0.008333333333333333d0) * (im ** 5.0d0)
    else if ((im <= (-0.07d0)) .or. (.not. (im <= 480.0d0))) then
        tmp = (t_0 - im) * t_1
    else
        tmp = im * -cos(re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = -0.16666666666666666 * Math.pow(im, 3.0);
	double t_1 = 1.0 + (-0.5 * (re * re));
	double tmp;
	if (im <= -2.5e+102) {
		tmp = t_0 * t_1;
	} else if (im <= -4.4e+37) {
		tmp = -0.008333333333333333 * Math.pow(im, 5.0);
	} else if ((im <= -0.07) || !(im <= 480.0)) {
		tmp = (t_0 - im) * t_1;
	} else {
		tmp = im * -Math.cos(re);
	}
	return tmp;
}
def code(re, im):
	t_0 = -0.16666666666666666 * math.pow(im, 3.0)
	t_1 = 1.0 + (-0.5 * (re * re))
	tmp = 0
	if im <= -2.5e+102:
		tmp = t_0 * t_1
	elif im <= -4.4e+37:
		tmp = -0.008333333333333333 * math.pow(im, 5.0)
	elif (im <= -0.07) or not (im <= 480.0):
		tmp = (t_0 - im) * t_1
	else:
		tmp = im * -math.cos(re)
	return tmp
function code(re, im)
	t_0 = Float64(-0.16666666666666666 * (im ^ 3.0))
	t_1 = Float64(1.0 + Float64(-0.5 * Float64(re * re)))
	tmp = 0.0
	if (im <= -2.5e+102)
		tmp = Float64(t_0 * t_1);
	elseif (im <= -4.4e+37)
		tmp = Float64(-0.008333333333333333 * (im ^ 5.0));
	elseif ((im <= -0.07) || !(im <= 480.0))
		tmp = Float64(Float64(t_0 - im) * t_1);
	else
		tmp = Float64(im * Float64(-cos(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = -0.16666666666666666 * (im ^ 3.0);
	t_1 = 1.0 + (-0.5 * (re * re));
	tmp = 0.0;
	if (im <= -2.5e+102)
		tmp = t_0 * t_1;
	elseif (im <= -4.4e+37)
		tmp = -0.008333333333333333 * (im ^ 5.0);
	elseif ((im <= -0.07) || ~((im <= 480.0)))
		tmp = (t_0 - im) * t_1;
	else
		tmp = im * -cos(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.5e+102], N[(t$95$0 * t$95$1), $MachinePrecision], If[LessEqual[im, -4.4e+37], N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, -0.07], N[Not[LessEqual[im, 480.0]], $MachinePrecision]], N[(N[(t$95$0 - im), $MachinePrecision] * t$95$1), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -0.16666666666666666 \cdot {im}^{3}\\
t_1 := 1 + -0.5 \cdot \left(re \cdot re\right)\\
\mathbf{if}\;im \leq -2.5 \cdot 10^{+102}:\\
\;\;\;\;t_0 \cdot t_1\\

\mathbf{elif}\;im \leq -4.4 \cdot 10^{+37}:\\
\;\;\;\;-0.008333333333333333 \cdot {im}^{5}\\

\mathbf{elif}\;im \leq -0.07 \lor \neg \left(im \leq 480\right):\\
\;\;\;\;\left(t_0 - im\right) \cdot t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -2.5e102

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) \]
      2. associate-*r*100.0%

        \[\leadsto \left(-1 \cdot im\right) \cdot \cos re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      3. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\cos re \cdot \left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right)} \]
      4. *-commutative100.0%

        \[\leadsto \color{blue}{\left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      5. +-commutative100.0%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} + -1 \cdot im\right)} \cdot \cos re \]
      6. neg-mul-1100.0%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} + \color{blue}{\left(-im\right)}\right) \cdot \cos re \]
      7. unsub-neg100.0%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \cdot \cos re \]
    6. Simplified100.0%

      \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 0.0%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + -0.16666666666666666 \cdot {im}^{3}\right) - im} \]
    8. Step-by-step derivation
      1. associate--l+0.0%

        \[\leadsto \color{blue}{-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      2. associate-*r*0.0%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} + \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
      3. distribute-lft1-in91.2%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      4. unpow291.2%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
    9. Simplified91.2%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
    10. Taylor expanded in im around inf 91.2%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \left(1 + -0.5 \cdot {re}^{2}\right)\right)} \]
    11. Step-by-step derivation
      1. associate-*r*91.2%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \left(1 + -0.5 \cdot {re}^{2}\right)} \]
      2. unpow291.2%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \left(1 + -0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    12. Simplified91.2%

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

    if -2.5e102 < im < -4.4000000000000001e37

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 56.7%

      \[\leadsto \cos re \cdot \color{blue}{\left(-1 \cdot im + \left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right)\right)} \]
    5. Taylor expanded in im around inf 56.7%

      \[\leadsto \color{blue}{-0.008333333333333333 \cdot \left({im}^{5} \cdot \cos re\right)} \]
    6. Step-by-step derivation
      1. associate-*r*56.7%

        \[\leadsto \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \cos re} \]
      2. *-commutative56.7%

        \[\leadsto \color{blue}{\left({im}^{5} \cdot -0.008333333333333333\right)} \cdot \cos re \]
      3. associate-*l*56.7%

        \[\leadsto \color{blue}{{im}^{5} \cdot \left(-0.008333333333333333 \cdot \cos re\right)} \]
    7. Simplified56.7%

      \[\leadsto \color{blue}{{im}^{5} \cdot \left(-0.008333333333333333 \cdot \cos re\right)} \]
    8. Taylor expanded in re around 0 49.1%

      \[\leadsto {im}^{5} \cdot \color{blue}{-0.008333333333333333} \]

    if -4.4000000000000001e37 < im < -0.070000000000000007 or 480 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 63.9%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*63.9%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) \]
      2. associate-*r*63.9%

        \[\leadsto \left(-1 \cdot im\right) \cdot \cos re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      3. distribute-rgt-out63.9%

        \[\leadsto \color{blue}{\cos re \cdot \left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right)} \]
      4. *-commutative63.9%

        \[\leadsto \color{blue}{\left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      5. +-commutative63.9%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} + -1 \cdot im\right)} \cdot \cos re \]
      6. neg-mul-163.9%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} + \color{blue}{\left(-im\right)}\right) \cdot \cos re \]
      7. unsub-neg63.9%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \cdot \cos re \]
    6. Simplified63.9%

      \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 12.5%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + -0.16666666666666666 \cdot {im}^{3}\right) - im} \]
    8. Step-by-step derivation
      1. associate--l+12.5%

        \[\leadsto \color{blue}{-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      2. associate-*r*12.5%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} + \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
      3. distribute-lft1-in59.2%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      4. unpow259.2%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
    9. Simplified59.2%

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

    if -0.070000000000000007 < im < 480

    1. Initial program 8.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg8.5%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative8.5%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*8.5%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg8.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub08.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative8.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in8.5%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg8.5%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in8.5%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in8.5%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out8.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in8.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval8.5%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval8.5%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def8.5%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval8.5%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub08.5%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff8.4%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified8.4%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 99.0%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*99.0%

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified99.0%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification83.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.5 \cdot 10^{+102}:\\ \;\;\;\;\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \left(1 + -0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq -4.4 \cdot 10^{+37}:\\ \;\;\;\;-0.008333333333333333 \cdot {im}^{5}\\ \mathbf{elif}\;im \leq -0.07 \lor \neg \left(im \leq 480\right):\\ \;\;\;\;\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + -0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 9: 79.7% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \left(1 + -0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{if}\;im \leq -2 \cdot 10^{+103}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -4.4 \cdot 10^{+37}:\\ \;\;\;\;-0.008333333333333333 \cdot {im}^{5}\\ \mathbf{elif}\;im \leq -550 \lor \neg \left(im \leq 560\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (* (* -0.16666666666666666 (pow im 3.0)) (+ 1.0 (* -0.5 (* re re))))))
   (if (<= im -2e+103)
     t_0
     (if (<= im -4.4e+37)
       (* -0.008333333333333333 (pow im 5.0))
       (if (or (<= im -550.0) (not (<= im 560.0))) t_0 (* im (- (cos re))))))))
double code(double re, double im) {
	double t_0 = (-0.16666666666666666 * pow(im, 3.0)) * (1.0 + (-0.5 * (re * re)));
	double tmp;
	if (im <= -2e+103) {
		tmp = t_0;
	} else if (im <= -4.4e+37) {
		tmp = -0.008333333333333333 * pow(im, 5.0);
	} else if ((im <= -550.0) || !(im <= 560.0)) {
		tmp = t_0;
	} else {
		tmp = im * -cos(re);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((-0.16666666666666666d0) * (im ** 3.0d0)) * (1.0d0 + ((-0.5d0) * (re * re)))
    if (im <= (-2d+103)) then
        tmp = t_0
    else if (im <= (-4.4d+37)) then
        tmp = (-0.008333333333333333d0) * (im ** 5.0d0)
    else if ((im <= (-550.0d0)) .or. (.not. (im <= 560.0d0))) then
        tmp = t_0
    else
        tmp = im * -cos(re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (-0.16666666666666666 * Math.pow(im, 3.0)) * (1.0 + (-0.5 * (re * re)));
	double tmp;
	if (im <= -2e+103) {
		tmp = t_0;
	} else if (im <= -4.4e+37) {
		tmp = -0.008333333333333333 * Math.pow(im, 5.0);
	} else if ((im <= -550.0) || !(im <= 560.0)) {
		tmp = t_0;
	} else {
		tmp = im * -Math.cos(re);
	}
	return tmp;
}
def code(re, im):
	t_0 = (-0.16666666666666666 * math.pow(im, 3.0)) * (1.0 + (-0.5 * (re * re)))
	tmp = 0
	if im <= -2e+103:
		tmp = t_0
	elif im <= -4.4e+37:
		tmp = -0.008333333333333333 * math.pow(im, 5.0)
	elif (im <= -550.0) or not (im <= 560.0):
		tmp = t_0
	else:
		tmp = im * -math.cos(re)
	return tmp
function code(re, im)
	t_0 = Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) * Float64(1.0 + Float64(-0.5 * Float64(re * re))))
	tmp = 0.0
	if (im <= -2e+103)
		tmp = t_0;
	elseif (im <= -4.4e+37)
		tmp = Float64(-0.008333333333333333 * (im ^ 5.0));
	elseif ((im <= -550.0) || !(im <= 560.0))
		tmp = t_0;
	else
		tmp = Float64(im * Float64(-cos(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (-0.16666666666666666 * (im ^ 3.0)) * (1.0 + (-0.5 * (re * re)));
	tmp = 0.0;
	if (im <= -2e+103)
		tmp = t_0;
	elseif (im <= -4.4e+37)
		tmp = -0.008333333333333333 * (im ^ 5.0);
	elseif ((im <= -550.0) || ~((im <= 560.0)))
		tmp = t_0;
	else
		tmp = im * -cos(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2e+103], t$95$0, If[LessEqual[im, -4.4e+37], N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, -550.0], N[Not[LessEqual[im, 560.0]], $MachinePrecision]], t$95$0, N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \left(1 + -0.5 \cdot \left(re \cdot re\right)\right)\\
\mathbf{if}\;im \leq -2 \cdot 10^{+103}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -4.4 \cdot 10^{+37}:\\
\;\;\;\;-0.008333333333333333 \cdot {im}^{5}\\

\mathbf{elif}\;im \leq -550 \lor \neg \left(im \leq 560\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2e103 or -4.4000000000000001e37 < im < -550 or 560 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 76.0%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*76.0%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) \]
      2. associate-*r*76.0%

        \[\leadsto \left(-1 \cdot im\right) \cdot \cos re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      3. distribute-rgt-out76.0%

        \[\leadsto \color{blue}{\cos re \cdot \left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right)} \]
      4. *-commutative76.0%

        \[\leadsto \color{blue}{\left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      5. +-commutative76.0%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} + -1 \cdot im\right)} \cdot \cos re \]
      6. neg-mul-176.0%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} + \color{blue}{\left(-im\right)}\right) \cdot \cos re \]
      7. unsub-neg76.0%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \cdot \cos re \]
    6. Simplified76.0%

      \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 8.2%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + -0.16666666666666666 \cdot {im}^{3}\right) - im} \]
    8. Step-by-step derivation
      1. associate--l+8.2%

        \[\leadsto \color{blue}{-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      2. associate-*r*8.2%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} + \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
      3. distribute-lft1-in69.9%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      4. unpow269.9%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
    9. Simplified69.9%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
    10. Taylor expanded in im around inf 69.9%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \left(1 + -0.5 \cdot {re}^{2}\right)\right)} \]
    11. Step-by-step derivation
      1. associate-*r*69.9%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \left(1 + -0.5 \cdot {re}^{2}\right)} \]
      2. unpow269.9%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \left(1 + -0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    12. Simplified69.9%

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

    if -2e103 < im < -4.4000000000000001e37

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 56.7%

      \[\leadsto \cos re \cdot \color{blue}{\left(-1 \cdot im + \left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right)\right)} \]
    5. Taylor expanded in im around inf 56.7%

      \[\leadsto \color{blue}{-0.008333333333333333 \cdot \left({im}^{5} \cdot \cos re\right)} \]
    6. Step-by-step derivation
      1. associate-*r*56.7%

        \[\leadsto \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \cos re} \]
      2. *-commutative56.7%

        \[\leadsto \color{blue}{\left({im}^{5} \cdot -0.008333333333333333\right)} \cdot \cos re \]
      3. associate-*l*56.7%

        \[\leadsto \color{blue}{{im}^{5} \cdot \left(-0.008333333333333333 \cdot \cos re\right)} \]
    7. Simplified56.7%

      \[\leadsto \color{blue}{{im}^{5} \cdot \left(-0.008333333333333333 \cdot \cos re\right)} \]
    8. Taylor expanded in re around 0 49.1%

      \[\leadsto {im}^{5} \cdot \color{blue}{-0.008333333333333333} \]

    if -550 < im < 560

    1. Initial program 9.8%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg9.8%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative9.8%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*9.8%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg9.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub09.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative9.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in9.8%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg9.8%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in9.8%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in9.8%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out9.8%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in9.8%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval9.8%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval9.8%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def9.8%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval9.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub09.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff9.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified9.8%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 97.8%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*97.8%

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified97.8%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification83.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2 \cdot 10^{+103}:\\ \;\;\;\;\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \left(1 + -0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq -4.4 \cdot 10^{+37}:\\ \;\;\;\;-0.008333333333333333 \cdot {im}^{5}\\ \mathbf{elif}\;im \leq -550 \lor \neg \left(im \leq 560\right):\\ \;\;\;\;\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \left(1 + -0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 10: 39.3% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos re \leq -0.002:\\ \;\;\;\;im \cdot \left(-1 - -0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= (cos re) -0.002) (* im (- -1.0 (* -0.5 (* re re)))) (- im)))
double code(double re, double im) {
	double tmp;
	if (cos(re) <= -0.002) {
		tmp = im * (-1.0 - (-0.5 * (re * re)));
	} else {
		tmp = -im;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (cos(re) <= (-0.002d0)) then
        tmp = im * ((-1.0d0) - ((-0.5d0) * (re * re)))
    else
        tmp = -im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (Math.cos(re) <= -0.002) {
		tmp = im * (-1.0 - (-0.5 * (re * re)));
	} else {
		tmp = -im;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if math.cos(re) <= -0.002:
		tmp = im * (-1.0 - (-0.5 * (re * re)))
	else:
		tmp = -im
	return tmp
function code(re, im)
	tmp = 0.0
	if (cos(re) <= -0.002)
		tmp = Float64(im * Float64(-1.0 - Float64(-0.5 * Float64(re * re))));
	else
		tmp = Float64(-im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (cos(re) <= -0.002)
		tmp = im * (-1.0 - (-0.5 * (re * re)));
	else
		tmp = -im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[N[Cos[re], $MachinePrecision], -0.002], N[(im * N[(-1.0 - N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-im)]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\cos re \leq -0.002:\\
\;\;\;\;im \cdot \left(-1 - -0.5 \cdot \left(re \cdot re\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-im\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 re) < -2e-3

    1. Initial program 54.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg54.5%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative54.5%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*54.5%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg54.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub054.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative54.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in54.5%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg54.5%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in54.5%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in54.5%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out54.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in54.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval54.5%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval54.5%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def54.5%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval54.5%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub054.5%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff54.6%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified54.6%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 83.5%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*83.5%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) \]
      2. associate-*r*83.5%

        \[\leadsto \left(-1 \cdot im\right) \cdot \cos re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      3. distribute-rgt-out83.5%

        \[\leadsto \color{blue}{\cos re \cdot \left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right)} \]
      4. *-commutative83.5%

        \[\leadsto \color{blue}{\left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      5. +-commutative83.5%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} + -1 \cdot im\right)} \cdot \cos re \]
      6. neg-mul-183.5%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} + \color{blue}{\left(-im\right)}\right) \cdot \cos re \]
      7. unsub-neg83.5%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \cdot \cos re \]
    6. Simplified83.5%

      \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 14.6%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + -0.16666666666666666 \cdot {im}^{3}\right) - im} \]
    8. Step-by-step derivation
      1. associate--l+14.6%

        \[\leadsto \color{blue}{-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      2. associate-*r*14.6%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} + \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
      3. distribute-lft1-in48.4%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      4. unpow248.4%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
    9. Simplified48.4%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
    10. Taylor expanded in im around 0 41.7%

      \[\leadsto \left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \color{blue}{\left(-1 \cdot im\right)} \]
    11. Step-by-step derivation
      1. mul-1-neg41.7%

        \[\leadsto \left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \color{blue}{\left(-im\right)} \]
    12. Simplified41.7%

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

    if -2e-3 < (cos.f64 re)

    1. Initial program 51.1%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg51.1%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative51.1%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*51.1%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg51.1%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub051.1%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative51.1%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in51.1%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg51.1%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in51.1%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in51.1%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out51.1%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in51.1%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval51.1%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval51.1%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def51.1%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval51.1%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub051.1%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff51.1%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified51.1%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 91.6%

      \[\leadsto \cos re \cdot \color{blue}{\left(-1 \cdot im + \left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right)\right)} \]
    5. Taylor expanded in im around inf 91.0%

      \[\leadsto \cos re \cdot \left(-1 \cdot im + \color{blue}{-0.008333333333333333 \cdot {im}^{5}}\right) \]
    6. Taylor expanded in re around 0 74.7%

      \[\leadsto \color{blue}{-1 \cdot im + -0.008333333333333333 \cdot {im}^{5}} \]
    7. Taylor expanded in im around 0 39.3%

      \[\leadsto \color{blue}{-1 \cdot im} \]
    8. Step-by-step derivation
      1. mul-1-neg39.3%

        \[\leadsto \color{blue}{-im} \]
    9. Simplified39.3%

      \[\leadsto \color{blue}{-im} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos re \leq -0.002:\\ \;\;\;\;im \cdot \left(-1 - -0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]

Alternative 11: 79.4% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -0.008333333333333333 \cdot {im}^{5}\\ \mathbf{if}\;im \leq -2 \cdot 10^{+36}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+58}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* -0.008333333333333333 (pow im 5.0))))
   (if (<= im -2e+36)
     t_0
     (if (<= im 1.15e+58) (* im (- (cos re))) (- t_0 im)))))
double code(double re, double im) {
	double t_0 = -0.008333333333333333 * pow(im, 5.0);
	double tmp;
	if (im <= -2e+36) {
		tmp = t_0;
	} else if (im <= 1.15e+58) {
		tmp = im * -cos(re);
	} else {
		tmp = t_0 - im;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-0.008333333333333333d0) * (im ** 5.0d0)
    if (im <= (-2d+36)) then
        tmp = t_0
    else if (im <= 1.15d+58) then
        tmp = im * -cos(re)
    else
        tmp = t_0 - im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = -0.008333333333333333 * Math.pow(im, 5.0);
	double tmp;
	if (im <= -2e+36) {
		tmp = t_0;
	} else if (im <= 1.15e+58) {
		tmp = im * -Math.cos(re);
	} else {
		tmp = t_0 - im;
	}
	return tmp;
}
def code(re, im):
	t_0 = -0.008333333333333333 * math.pow(im, 5.0)
	tmp = 0
	if im <= -2e+36:
		tmp = t_0
	elif im <= 1.15e+58:
		tmp = im * -math.cos(re)
	else:
		tmp = t_0 - im
	return tmp
function code(re, im)
	t_0 = Float64(-0.008333333333333333 * (im ^ 5.0))
	tmp = 0.0
	if (im <= -2e+36)
		tmp = t_0;
	elseif (im <= 1.15e+58)
		tmp = Float64(im * Float64(-cos(re)));
	else
		tmp = Float64(t_0 - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = -0.008333333333333333 * (im ^ 5.0);
	tmp = 0.0;
	if (im <= -2e+36)
		tmp = t_0;
	elseif (im <= 1.15e+58)
		tmp = im * -cos(re);
	else
		tmp = t_0 - im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2e+36], t$95$0, If[LessEqual[im, 1.15e+58], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], N[(t$95$0 - im), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -0.008333333333333333 \cdot {im}^{5}\\
\mathbf{if}\;im \leq -2 \cdot 10^{+36}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 1.15 \cdot 10^{+58}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 88.0%

      \[\leadsto \cos re \cdot \color{blue}{\left(-1 \cdot im + \left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right)\right)} \]
    5. Taylor expanded in im around inf 88.0%

      \[\leadsto \color{blue}{-0.008333333333333333 \cdot \left({im}^{5} \cdot \cos re\right)} \]
    6. Step-by-step derivation
      1. associate-*r*88.0%

        \[\leadsto \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \cos re} \]
      2. *-commutative88.0%

        \[\leadsto \color{blue}{\left({im}^{5} \cdot -0.008333333333333333\right)} \cdot \cos re \]
      3. associate-*l*88.0%

        \[\leadsto \color{blue}{{im}^{5} \cdot \left(-0.008333333333333333 \cdot \cos re\right)} \]
    7. Simplified88.0%

      \[\leadsto \color{blue}{{im}^{5} \cdot \left(-0.008333333333333333 \cdot \cos re\right)} \]
    8. Taylor expanded in re around 0 60.4%

      \[\leadsto {im}^{5} \cdot \color{blue}{-0.008333333333333333} \]

    if -2.00000000000000008e36 < im < 1.15000000000000001e58

    1. Initial program 19.8%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg19.8%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative19.8%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*19.8%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg19.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub019.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative19.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in19.8%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg19.8%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in19.8%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in19.8%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out19.8%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in19.8%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval19.8%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval19.8%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def19.8%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval19.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub019.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff19.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified19.8%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 87.3%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*87.3%

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified87.3%

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

    if 1.15000000000000001e58 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \cos re \cdot \color{blue}{\left(-1 \cdot im + \left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right)\right)} \]
    5. Taylor expanded in im around inf 100.0%

      \[\leadsto \cos re \cdot \left(-1 \cdot im + \color{blue}{-0.008333333333333333 \cdot {im}^{5}}\right) \]
    6. Taylor expanded in re around 0 73.2%

      \[\leadsto \color{blue}{-1 \cdot im + -0.008333333333333333 \cdot {im}^{5}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification79.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2 \cdot 10^{+36}:\\ \;\;\;\;-0.008333333333333333 \cdot {im}^{5}\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+58}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot {im}^{5} - im\\ \end{array} \]

Alternative 12: 60.8% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -1320 \lor \neg \left(im \leq 59000\right):\\ \;\;\;\;im \cdot \left(-1 - -0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -1320.0) (not (<= im 59000.0)))
   (* im (- -1.0 (* -0.5 (* re re))))
   (* im (- (cos re)))))
double code(double re, double im) {
	double tmp;
	if ((im <= -1320.0) || !(im <= 59000.0)) {
		tmp = im * (-1.0 - (-0.5 * (re * re)));
	} else {
		tmp = im * -cos(re);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-1320.0d0)) .or. (.not. (im <= 59000.0d0))) then
        tmp = im * ((-1.0d0) - ((-0.5d0) * (re * re)))
    else
        tmp = im * -cos(re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -1320.0) || !(im <= 59000.0)) {
		tmp = im * (-1.0 - (-0.5 * (re * re)));
	} else {
		tmp = im * -Math.cos(re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -1320.0) or not (im <= 59000.0):
		tmp = im * (-1.0 - (-0.5 * (re * re)))
	else:
		tmp = im * -math.cos(re)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -1320.0) || !(im <= 59000.0))
		tmp = Float64(im * Float64(-1.0 - Float64(-0.5 * Float64(re * re))));
	else
		tmp = Float64(im * Float64(-cos(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -1320.0) || ~((im <= 59000.0)))
		tmp = im * (-1.0 - (-0.5 * (re * re)));
	else
		tmp = im * -cos(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -1320.0], N[Not[LessEqual[im, 59000.0]], $MachinePrecision]], N[(im * N[(-1.0 - N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1320 \lor \neg \left(im \leq 59000\right):\\
\;\;\;\;im \cdot \left(-1 - -0.5 \cdot \left(re \cdot re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -1320 or 59000 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 69.0%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*69.0%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) \]
      2. associate-*r*69.0%

        \[\leadsto \left(-1 \cdot im\right) \cdot \cos re + \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      3. distribute-rgt-out69.0%

        \[\leadsto \color{blue}{\cos re \cdot \left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right)} \]
      4. *-commutative69.0%

        \[\leadsto \color{blue}{\left(-1 \cdot im + -0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} \]
      5. +-commutative69.0%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} + -1 \cdot im\right)} \cdot \cos re \]
      6. neg-mul-169.0%

        \[\leadsto \left(-0.16666666666666666 \cdot {im}^{3} + \color{blue}{\left(-im\right)}\right) \cdot \cos re \]
      7. unsub-neg69.0%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \cdot \cos re \]
    6. Simplified69.0%

      \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 8.7%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + -0.16666666666666666 \cdot {im}^{3}\right) - im} \]
    8. Step-by-step derivation
      1. associate--l+8.7%

        \[\leadsto \color{blue}{-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right) + \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      2. associate-*r*8.7%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} + \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
      3. distribute-lft1-in64.1%

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      4. unpow264.1%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)} + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right) \]
    9. Simplified64.1%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
    10. Taylor expanded in im around 0 26.7%

      \[\leadsto \left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \color{blue}{\left(-1 \cdot im\right)} \]
    11. Step-by-step derivation
      1. mul-1-neg26.7%

        \[\leadsto \left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \color{blue}{\left(-im\right)} \]
    12. Simplified26.7%

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

    if -1320 < im < 59000

    1. Initial program 10.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg10.5%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative10.5%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*10.5%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg10.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub010.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative10.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in10.5%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg10.5%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in10.5%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in10.5%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out10.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in10.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval10.5%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval10.5%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def10.5%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval10.5%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub010.5%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff10.4%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified10.4%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 97.1%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*97.1%

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified97.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1320 \lor \neg \left(im \leq 59000\right):\\ \;\;\;\;im \cdot \left(-1 - -0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 13: 79.4% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -2.35 \cdot 10^{+36} \lor \neg \left(im \leq 1.15 \cdot 10^{+58}\right):\\ \;\;\;\;-0.008333333333333333 \cdot {im}^{5}\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -2.35e+36) (not (<= im 1.15e+58)))
   (* -0.008333333333333333 (pow im 5.0))
   (* im (- (cos re)))))
double code(double re, double im) {
	double tmp;
	if ((im <= -2.35e+36) || !(im <= 1.15e+58)) {
		tmp = -0.008333333333333333 * pow(im, 5.0);
	} else {
		tmp = im * -cos(re);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-2.35d+36)) .or. (.not. (im <= 1.15d+58))) then
        tmp = (-0.008333333333333333d0) * (im ** 5.0d0)
    else
        tmp = im * -cos(re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -2.35e+36) || !(im <= 1.15e+58)) {
		tmp = -0.008333333333333333 * Math.pow(im, 5.0);
	} else {
		tmp = im * -Math.cos(re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -2.35e+36) or not (im <= 1.15e+58):
		tmp = -0.008333333333333333 * math.pow(im, 5.0)
	else:
		tmp = im * -math.cos(re)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -2.35e+36) || !(im <= 1.15e+58))
		tmp = Float64(-0.008333333333333333 * (im ^ 5.0));
	else
		tmp = Float64(im * Float64(-cos(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -2.35e+36) || ~((im <= 1.15e+58)))
		tmp = -0.008333333333333333 * (im ^ 5.0);
	else
		tmp = im * -cos(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -2.35e+36], N[Not[LessEqual[im, 1.15e+58]], $MachinePrecision]], N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.35 \cdot 10^{+36} \lor \neg \left(im \leq 1.15 \cdot 10^{+58}\right):\\
\;\;\;\;-0.008333333333333333 \cdot {im}^{5}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -2.34999999999999994e36 or 1.15000000000000001e58 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg100.0%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub0100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative100.0%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in100.0%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg100.0%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in100.0%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval100.0%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def100.0%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub0100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff100.0%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 94.5%

      \[\leadsto \cos re \cdot \color{blue}{\left(-1 \cdot im + \left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right)\right)} \]
    5. Taylor expanded in im around inf 94.5%

      \[\leadsto \color{blue}{-0.008333333333333333 \cdot \left({im}^{5} \cdot \cos re\right)} \]
    6. Step-by-step derivation
      1. associate-*r*94.5%

        \[\leadsto \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \cos re} \]
      2. *-commutative94.5%

        \[\leadsto \color{blue}{\left({im}^{5} \cdot -0.008333333333333333\right)} \cdot \cos re \]
      3. associate-*l*94.5%

        \[\leadsto \color{blue}{{im}^{5} \cdot \left(-0.008333333333333333 \cdot \cos re\right)} \]
    7. Simplified94.5%

      \[\leadsto \color{blue}{{im}^{5} \cdot \left(-0.008333333333333333 \cdot \cos re\right)} \]
    8. Taylor expanded in re around 0 67.4%

      \[\leadsto {im}^{5} \cdot \color{blue}{-0.008333333333333333} \]

    if -2.34999999999999994e36 < im < 1.15000000000000001e58

    1. Initial program 19.8%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg19.8%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative19.8%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*19.8%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg19.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub019.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative19.8%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in19.8%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg19.8%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in19.8%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in19.8%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out19.8%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in19.8%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval19.8%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval19.8%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def19.8%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval19.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub019.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff19.8%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified19.8%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 87.3%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*87.3%

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified87.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.35 \cdot 10^{+36} \lor \neg \left(im \leq 1.15 \cdot 10^{+58}\right):\\ \;\;\;\;-0.008333333333333333 \cdot {im}^{5}\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 14: 31.9% accurate, 34.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 1.38 \cdot 10^{+153}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;27 + re \cdot \left(re \cdot -13.5\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 1.38e+153) (- im) (+ 27.0 (* re (* re -13.5)))))
double code(double re, double im) {
	double tmp;
	if (re <= 1.38e+153) {
		tmp = -im;
	} else {
		tmp = 27.0 + (re * (re * -13.5));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 1.38d+153) then
        tmp = -im
    else
        tmp = 27.0d0 + (re * (re * (-13.5d0)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 1.38e+153) {
		tmp = -im;
	} else {
		tmp = 27.0 + (re * (re * -13.5));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 1.38e+153:
		tmp = -im
	else:
		tmp = 27.0 + (re * (re * -13.5))
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 1.38e+153)
		tmp = Float64(-im);
	else
		tmp = Float64(27.0 + Float64(re * Float64(re * -13.5)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 1.38e+153)
		tmp = -im;
	else
		tmp = 27.0 + (re * (re * -13.5));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 1.38e+153], (-im), N[(27.0 + N[(re * N[(re * -13.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.38 \cdot 10^{+153}:\\
\;\;\;\;-im\\

\mathbf{else}:\\
\;\;\;\;27 + re \cdot \left(re \cdot -13.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 1.38e153

    1. Initial program 53.1%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg53.1%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative53.1%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*53.1%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg53.1%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub053.1%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative53.1%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in53.1%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg53.1%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in53.1%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in53.1%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out53.1%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in53.1%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval53.1%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval53.1%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def53.1%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval53.1%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub053.1%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff53.1%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified53.1%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 91.0%

      \[\leadsto \cos re \cdot \color{blue}{\left(-1 \cdot im + \left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right)\right)} \]
    5. Taylor expanded in im around inf 90.4%

      \[\leadsto \cos re \cdot \left(-1 \cdot im + \color{blue}{-0.008333333333333333 \cdot {im}^{5}}\right) \]
    6. Taylor expanded in re around 0 60.1%

      \[\leadsto \color{blue}{-1 \cdot im + -0.008333333333333333 \cdot {im}^{5}} \]
    7. Taylor expanded in im around 0 32.5%

      \[\leadsto \color{blue}{-1 \cdot im} \]
    8. Step-by-step derivation
      1. mul-1-neg32.5%

        \[\leadsto \color{blue}{-im} \]
    9. Simplified32.5%

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

    if 1.38e153 < re

    1. Initial program 46.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. cos-neg46.5%

        \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
      2. *-commutative46.5%

        \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
      3. associate-*l*46.5%

        \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
      4. sub-neg46.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
      5. neg-sub046.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
      6. +-commutative46.5%

        \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
      7. distribute-lft-in46.5%

        \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
      8. cos-neg46.5%

        \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
      9. distribute-lft-in46.5%

        \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
      10. distribute-rgt-in46.5%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
      11. distribute-lft-neg-out46.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
      12. distribute-rgt-neg-in46.5%

        \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
      13. metadata-eval46.5%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
      14. metadata-eval46.5%

        \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
      15. fma-def46.5%

        \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
      16. metadata-eval46.5%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
      17. neg-sub046.5%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
      18. exp-diff46.4%

        \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    3. Simplified46.4%

      \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
    4. Applied egg-rr2.8%

      \[\leadsto \cos re \cdot \color{blue}{27} \]
    5. Taylor expanded in re around 0 16.1%

      \[\leadsto \color{blue}{27 + -13.5 \cdot {re}^{2}} \]
    6. Step-by-step derivation
      1. *-commutative16.1%

        \[\leadsto 27 + \color{blue}{{re}^{2} \cdot -13.5} \]
      2. unpow216.1%

        \[\leadsto 27 + \color{blue}{\left(re \cdot re\right)} \cdot -13.5 \]
    7. Simplified16.1%

      \[\leadsto \color{blue}{27 + \left(re \cdot re\right) \cdot -13.5} \]
    8. Taylor expanded in re around 0 16.1%

      \[\leadsto 27 + \color{blue}{-13.5 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative16.1%

        \[\leadsto 27 + \color{blue}{{re}^{2} \cdot -13.5} \]
      2. unpow216.1%

        \[\leadsto 27 + \color{blue}{\left(re \cdot re\right)} \cdot -13.5 \]
      3. associate-*r*16.1%

        \[\leadsto 27 + \color{blue}{re \cdot \left(re \cdot -13.5\right)} \]
    10. Simplified16.1%

      \[\leadsto 27 + \color{blue}{re \cdot \left(re \cdot -13.5\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification29.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.38 \cdot 10^{+153}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;27 + re \cdot \left(re \cdot -13.5\right)\\ \end{array} \]

Alternative 15: 29.8% accurate, 154.5× speedup?

\[\begin{array}{l} \\ -im \end{array} \]
(FPCore (re im) :precision binary64 (- im))
double code(double re, double im) {
	return -im;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = -im
end function
public static double code(double re, double im) {
	return -im;
}
def code(re, im):
	return -im
function code(re, im)
	return Float64(-im)
end
function tmp = code(re, im)
	tmp = -im;
end
code[re_, im_] := (-im)
\begin{array}{l}

\\
-im
\end{array}
Derivation
  1. Initial program 52.1%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. cos-neg52.1%

      \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. *-commutative52.1%

      \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
    3. associate-*l*52.1%

      \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
    4. sub-neg52.1%

      \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
    5. neg-sub052.1%

      \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
    6. +-commutative52.1%

      \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
    7. distribute-lft-in52.1%

      \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
    8. cos-neg52.1%

      \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
    9. distribute-lft-in52.1%

      \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
    10. distribute-rgt-in52.1%

      \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
    11. distribute-lft-neg-out52.1%

      \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
    12. distribute-rgt-neg-in52.1%

      \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
    13. metadata-eval52.1%

      \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
    14. metadata-eval52.1%

      \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
    15. fma-def52.1%

      \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
    16. metadata-eval52.1%

      \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
    17. neg-sub052.1%

      \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
    18. exp-diff52.1%

      \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
  3. Simplified52.1%

    \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
  4. Taylor expanded in im around 0 90.9%

    \[\leadsto \cos re \cdot \color{blue}{\left(-1 \cdot im + \left(-0.16666666666666666 \cdot {im}^{3} + -0.008333333333333333 \cdot {im}^{5}\right)\right)} \]
  5. Taylor expanded in im around inf 90.3%

    \[\leadsto \cos re \cdot \left(-1 \cdot im + \color{blue}{-0.008333333333333333 \cdot {im}^{5}}\right) \]
  6. Taylor expanded in re around 0 54.5%

    \[\leadsto \color{blue}{-1 \cdot im + -0.008333333333333333 \cdot {im}^{5}} \]
  7. Taylor expanded in im around 0 29.0%

    \[\leadsto \color{blue}{-1 \cdot im} \]
  8. Step-by-step derivation
    1. mul-1-neg29.0%

      \[\leadsto \color{blue}{-im} \]
  9. Simplified29.0%

    \[\leadsto \color{blue}{-im} \]
  10. Final simplification29.0%

    \[\leadsto -im \]

Alternative 16: 2.9% accurate, 309.0× speedup?

\[\begin{array}{l} \\ -3 \end{array} \]
(FPCore (re im) :precision binary64 -3.0)
double code(double re, double im) {
	return -3.0;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = -3.0d0
end function
public static double code(double re, double im) {
	return -3.0;
}
def code(re, im):
	return -3.0
function code(re, im)
	return -3.0
end
function tmp = code(re, im)
	tmp = -3.0;
end
code[re_, im_] := -3.0
\begin{array}{l}

\\
-3
\end{array}
Derivation
  1. Initial program 52.1%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. cos-neg52.1%

      \[\leadsto \left(0.5 \cdot \color{blue}{\cos \left(-re\right)}\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. *-commutative52.1%

      \[\leadsto \color{blue}{\left(\cos \left(-re\right) \cdot 0.5\right)} \cdot \left(e^{0 - im} - e^{im}\right) \]
    3. associate-*l*52.1%

      \[\leadsto \color{blue}{\cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{0 - im} - e^{im}\right)\right)} \]
    4. sub-neg52.1%

      \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\right) \]
    5. neg-sub052.1%

      \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im}\right)\right)\right) \]
    6. +-commutative52.1%

      \[\leadsto \cos \left(-re\right) \cdot \left(0.5 \cdot \color{blue}{\left(\left(-e^{im}\right) + e^{-im}\right)}\right) \]
    7. distribute-lft-in52.1%

      \[\leadsto \cos \left(-re\right) \cdot \color{blue}{\left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right)} \]
    8. cos-neg52.1%

      \[\leadsto \color{blue}{\cos re} \cdot \left(0.5 \cdot \left(-e^{im}\right) + 0.5 \cdot e^{-im}\right) \]
    9. distribute-lft-in52.1%

      \[\leadsto \cos re \cdot \color{blue}{\left(0.5 \cdot \left(\left(-e^{im}\right) + e^{-im}\right)\right)} \]
    10. distribute-rgt-in52.1%

      \[\leadsto \cos re \cdot \color{blue}{\left(\left(-e^{im}\right) \cdot 0.5 + e^{-im} \cdot 0.5\right)} \]
    11. distribute-lft-neg-out52.1%

      \[\leadsto \cos re \cdot \left(\color{blue}{\left(-e^{im} \cdot 0.5\right)} + e^{-im} \cdot 0.5\right) \]
    12. distribute-rgt-neg-in52.1%

      \[\leadsto \cos re \cdot \left(\color{blue}{e^{im} \cdot \left(-0.5\right)} + e^{-im} \cdot 0.5\right) \]
    13. metadata-eval52.1%

      \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{-0.5} + e^{-im} \cdot 0.5\right) \]
    14. metadata-eval52.1%

      \[\leadsto \cos re \cdot \left(e^{im} \cdot \color{blue}{\frac{-1}{2}} + e^{-im} \cdot 0.5\right) \]
    15. fma-def52.1%

      \[\leadsto \cos re \cdot \color{blue}{\mathsf{fma}\left(e^{im}, \frac{-1}{2}, e^{-im} \cdot 0.5\right)} \]
    16. metadata-eval52.1%

      \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, \color{blue}{-0.5}, e^{-im} \cdot 0.5\right) \]
    17. neg-sub052.1%

      \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, e^{\color{blue}{0 - im}} \cdot 0.5\right) \]
    18. exp-diff52.1%

      \[\leadsto \cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
  3. Simplified52.1%

    \[\leadsto \color{blue}{\cos re \cdot \mathsf{fma}\left(e^{im}, -0.5, \frac{0.5}{e^{im}}\right)} \]
  4. Applied egg-rr3.0%

    \[\leadsto \cos re \cdot \color{blue}{-3} \]
  5. Taylor expanded in re around 0 3.0%

    \[\leadsto \color{blue}{-3} \]
  6. Final simplification3.0%

    \[\leadsto -3 \]

Developer target: 99.8% accurate, 0.8× 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 2023283 
(FPCore (re im)
  :name "math.sin on complex, imaginary part"
  :precision binary64

  :herbie-target
  (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))))

  (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))