math.sin on complex, imaginary part

Percentage Accurate: 54.9% → 99.7%
Time: 13.1s
Alternatives: 18
Speedup: 2.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 18 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 54.9% 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 \lor \neg \left(t_0 \leq 0.05\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(\left({im}^{3} \cdot -0.16666666666666666 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\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 0.05)))
     (* (* 0.5 (cos re)) t_0)
     (*
      (cos re)
      (+
       (- (* (pow im 3.0) -0.16666666666666666) im)
       (+
        (* (pow im 7.0) -0.0001984126984126984)
        (* (pow im 5.0) -0.008333333333333333)))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 0.05)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * (((pow(im, 3.0) * -0.16666666666666666) - im) + ((pow(im, 7.0) * -0.0001984126984126984) + (pow(im, 5.0) * -0.008333333333333333)));
	}
	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 <= 0.05)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = Math.cos(re) * (((Math.pow(im, 3.0) * -0.16666666666666666) - im) + ((Math.pow(im, 7.0) * -0.0001984126984126984) + (Math.pow(im, 5.0) * -0.008333333333333333)));
	}
	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 <= 0.05):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = math.cos(re) * (((math.pow(im, 3.0) * -0.16666666666666666) - im) + ((math.pow(im, 7.0) * -0.0001984126984126984) + (math.pow(im, 5.0) * -0.008333333333333333)))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 0.05))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(cos(re) * Float64(Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) + Float64(Float64((im ^ 7.0) * -0.0001984126984126984) + Float64((im ^ 5.0) * -0.008333333333333333))));
	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 <= 0.05)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = cos(re) * ((((im ^ 3.0) * -0.16666666666666666) - im) + (((im ^ 7.0) * -0.0001984126984126984) + ((im ^ 5.0) * -0.008333333333333333)));
	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, 0.05]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision] + N[(N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $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 0.05\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(\left({im}^{3} \cdot -0.16666666666666666 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\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 0.050000000000000003 < (-.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. sub0-neg100.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.050000000000000003

    1. Initial program 8.2%

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

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

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

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

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

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

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

        \[\leadsto \left(\left(-\color{blue}{im \cdot \cos re}\right) + -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]
      5. distribute-lft-neg-in99.8%

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

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

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

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

        \[\leadsto \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\color{blue}{\left(\cos re \cdot {im}^{5}\right) \cdot -0.008333333333333333} + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]
      10. associate-*l*99.8%

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

        \[\leadsto \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333\right) + \color{blue}{\left(\cos re \cdot {im}^{7}\right) \cdot -0.0001984126984126984}\right) \]
      12. associate-*l*99.8%

        \[\leadsto \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333\right) + \color{blue}{\cos re \cdot \left({im}^{7} \cdot -0.0001984126984126984\right)}\right) \]
      13. distribute-lft-out99.8%

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

      \[\leadsto \color{blue}{\cos re \cdot \left(\left({im}^{3} \cdot -0.16666666666666666 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right)} \]
  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 0.05\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(\left({im}^{3} \cdot -0.16666666666666666 - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right)\\ \end{array} \]

Alternative 2: 99.7% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(im \cdot -2 + \left({im}^{5} \cdot -0.016666666666666666 + {im}^{3} \cdot -0.3333333333333333\right)\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 0.050000000000000003 < (-.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. sub0-neg100.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.050000000000000003

    1. Initial program 8.2%

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

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

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

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.016666666666666666 \cdot {im}^{5} + -0.3333333333333333 \cdot {im}^{3}\right)\right)} \]
  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 0.05\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im \cdot -2 + \left({im}^{5} \cdot -0.016666666666666666 + {im}^{3} \cdot -0.3333333333333333\right)\right)\\ \end{array} \]

Alternative 3: 99.6% 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 5 \cdot 10^{-6}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - 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 5e-6)))
     (* (* 0.5 (cos re)) t_0)
     (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im)))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 5e-6)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - 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 <= 5e-6)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - 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 <= 5e-6):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - 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 <= 5e-6))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - 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 <= 5e-6)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - 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, 5e-6]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $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 5 \cdot 10^{-6}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - 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 5.00000000000000041e-6 < (-.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. sub0-neg99.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)) < 5.00000000000000041e-6

    1. Initial program 7.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--99.8%

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

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
  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 5 \cdot 10^{-6}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 4: 97.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ t_1 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{if}\;im \leq -2.1 \cdot 10^{+55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.0132:\\ \;\;\;\;0.5 \cdot t_0\\ \mathbf{elif}\;im \leq 0.15:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;t_0 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im)))
        (t_1 (* (pow im 7.0) (* (cos re) -0.0001984126984126984))))
   (if (<= im -2.1e+55)
     t_1
     (if (<= im -0.0132)
       (* 0.5 t_0)
       (if (<= im 0.15)
         (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
         (if (<= im 1.1e+44) (* t_0 (+ 0.5 (* re (* re -0.25)))) t_1))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double t_1 = pow(im, 7.0) * (cos(re) * -0.0001984126984126984);
	double tmp;
	if (im <= -2.1e+55) {
		tmp = t_1;
	} else if (im <= -0.0132) {
		tmp = 0.5 * t_0;
	} else if (im <= 0.15) {
		tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 1.1e+44) {
		tmp = t_0 * (0.5 + (re * (re * -0.25)));
	} 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)
    t_1 = (im ** 7.0d0) * (cos(re) * (-0.0001984126984126984d0))
    if (im <= (-2.1d+55)) then
        tmp = t_1
    else if (im <= (-0.0132d0)) then
        tmp = 0.5d0 * t_0
    else if (im <= 0.15d0) then
        tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    else if (im <= 1.1d+44) then
        tmp = t_0 * (0.5d0 + (re * (re * (-0.25d0))))
    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);
	double t_1 = Math.pow(im, 7.0) * (Math.cos(re) * -0.0001984126984126984);
	double tmp;
	if (im <= -2.1e+55) {
		tmp = t_1;
	} else if (im <= -0.0132) {
		tmp = 0.5 * t_0;
	} else if (im <= 0.15) {
		tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 1.1e+44) {
		tmp = t_0 * (0.5 + (re * (re * -0.25)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	t_1 = math.pow(im, 7.0) * (math.cos(re) * -0.0001984126984126984)
	tmp = 0
	if im <= -2.1e+55:
		tmp = t_1
	elif im <= -0.0132:
		tmp = 0.5 * t_0
	elif im <= 0.15:
		tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	elif im <= 1.1e+44:
		tmp = t_0 * (0.5 + (re * (re * -0.25)))
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	t_1 = Float64((im ^ 7.0) * Float64(cos(re) * -0.0001984126984126984))
	tmp = 0.0
	if (im <= -2.1e+55)
		tmp = t_1;
	elseif (im <= -0.0132)
		tmp = Float64(0.5 * t_0);
	elseif (im <= 0.15)
		tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	elseif (im <= 1.1e+44)
		tmp = Float64(t_0 * Float64(0.5 + Float64(re * Float64(re * -0.25))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	t_1 = (im ^ 7.0) * (cos(re) * -0.0001984126984126984);
	tmp = 0.0;
	if (im <= -2.1e+55)
		tmp = t_1;
	elseif (im <= -0.0132)
		tmp = 0.5 * t_0;
	elseif (im <= 0.15)
		tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	elseif (im <= 1.1e+44)
		tmp = t_0 * (0.5 + (re * (re * -0.25)));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.1e+55], t$95$1, If[LessEqual[im, -0.0132], N[(0.5 * t$95$0), $MachinePrecision], If[LessEqual[im, 0.15], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.1e+44], N[(t$95$0 * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+55}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -0.0132:\\
\;\;\;\;0.5 \cdot t_0\\

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

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -2.1000000000000001e55 or 1.09999999999999998e44 < 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. sub0-neg100.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)} \]
    4. Taylor expanded in im around 0 100.0%

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

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

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

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

        \[\leadsto \left(\left(-\color{blue}{im \cdot \cos re}\right) + -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]
      5. distribute-lft-neg-in100.0%

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

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

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

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

        \[\leadsto \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\color{blue}{\left(\cos re \cdot {im}^{5}\right) \cdot -0.008333333333333333} + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]
      10. associate-*l*100.0%

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

        \[\leadsto \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333\right) + \color{blue}{\left(\cos re \cdot {im}^{7}\right) \cdot -0.0001984126984126984}\right) \]
      12. associate-*l*100.0%

        \[\leadsto \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333\right) + \color{blue}{\cos re \cdot \left({im}^{7} \cdot -0.0001984126984126984\right)}\right) \]
      13. distribute-lft-out100.0%

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

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

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

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

        \[\leadsto \color{blue}{{im}^{7} \cdot \left(-0.0001984126984126984 \cdot \cos re\right)} \]
    9. Simplified100.0%

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

    if -2.1000000000000001e55 < im < -0.0132

    1. Initial program 99.7%

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

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

      \[\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.6%

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

    if -0.0132 < im < 0.149999999999999994

    1. Initial program 7.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--99.8%

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

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

    if 0.149999999999999994 < im < 1.09999999999999998e44

    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. sub0-neg100.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)} \]
    4. Taylor expanded in re around 0 0.0%

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

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

        \[\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) \]
      3. distribute-rgt-out88.9%

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

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*88.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.1 \cdot 10^{+55}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{elif}\;im \leq -0.0132:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.15:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \end{array} \]

Alternative 5: 97.4% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{if}\;im \leq -2.1 \cdot 10^{+55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.0048:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 5.5 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;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 (* (pow im 7.0) (* (cos re) -0.0001984126984126984))))
   (if (<= im -2.1e+55)
     t_1
     (if (<= im -0.0048)
       t_0
       (if (<= im 5.5e-5) (* im (- (cos re))) (if (<= im 1.1e+44) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double t_1 = pow(im, 7.0) * (cos(re) * -0.0001984126984126984);
	double tmp;
	if (im <= -2.1e+55) {
		tmp = t_1;
	} else if (im <= -0.0048) {
		tmp = t_0;
	} else if (im <= 5.5e-5) {
		tmp = im * -cos(re);
	} else if (im <= 1.1e+44) {
		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 = (im ** 7.0d0) * (cos(re) * (-0.0001984126984126984d0))
    if (im <= (-2.1d+55)) then
        tmp = t_1
    else if (im <= (-0.0048d0)) then
        tmp = t_0
    else if (im <= 5.5d-5) then
        tmp = im * -cos(re)
    else if (im <= 1.1d+44) 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 = Math.pow(im, 7.0) * (Math.cos(re) * -0.0001984126984126984);
	double tmp;
	if (im <= -2.1e+55) {
		tmp = t_1;
	} else if (im <= -0.0048) {
		tmp = t_0;
	} else if (im <= 5.5e-5) {
		tmp = im * -Math.cos(re);
	} else if (im <= 1.1e+44) {
		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 = math.pow(im, 7.0) * (math.cos(re) * -0.0001984126984126984)
	tmp = 0
	if im <= -2.1e+55:
		tmp = t_1
	elif im <= -0.0048:
		tmp = t_0
	elif im <= 5.5e-5:
		tmp = im * -math.cos(re)
	elif im <= 1.1e+44:
		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((im ^ 7.0) * Float64(cos(re) * -0.0001984126984126984))
	tmp = 0.0
	if (im <= -2.1e+55)
		tmp = t_1;
	elseif (im <= -0.0048)
		tmp = t_0;
	elseif (im <= 5.5e-5)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 1.1e+44)
		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 = (im ^ 7.0) * (cos(re) * -0.0001984126984126984);
	tmp = 0.0;
	if (im <= -2.1e+55)
		tmp = t_1;
	elseif (im <= -0.0048)
		tmp = t_0;
	elseif (im <= 5.5e-5)
		tmp = im * -cos(re);
	elseif (im <= 1.1e+44)
		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[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.1e+55], t$95$1, If[LessEqual[im, -0.0048], t$95$0, If[LessEqual[im, 5.5e-5], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.1e+44], 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 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+55}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 5.5 \cdot 10^{-5}:\\
\;\;\;\;im \cdot \left(-\cos re\right)\\

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.1000000000000001e55 or 1.09999999999999998e44 < 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. sub0-neg100.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)} \]
    4. Taylor expanded in im around 0 100.0%

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

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

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

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

        \[\leadsto \left(\left(-\color{blue}{im \cdot \cos re}\right) + -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]
      5. distribute-lft-neg-in100.0%

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

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

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

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

        \[\leadsto \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\color{blue}{\left(\cos re \cdot {im}^{5}\right) \cdot -0.008333333333333333} + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]
      10. associate-*l*100.0%

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

        \[\leadsto \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333\right) + \color{blue}{\left(\cos re \cdot {im}^{7}\right) \cdot -0.0001984126984126984}\right) \]
      12. associate-*l*100.0%

        \[\leadsto \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333\right) + \color{blue}{\cos re \cdot \left({im}^{7} \cdot -0.0001984126984126984\right)}\right) \]
      13. distribute-lft-out100.0%

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

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

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

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

        \[\leadsto \color{blue}{{im}^{7} \cdot \left(-0.0001984126984126984 \cdot \cos re\right)} \]
    9. Simplified100.0%

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

    if -2.1000000000000001e55 < im < -0.00479999999999999958 or 5.5000000000000002e-5 < im < 1.09999999999999998e44

    1. Initial program 99.8%

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

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

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

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

    if -0.00479999999999999958 < im < 5.5000000000000002e-5

    1. Initial program 7.5%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg99.7%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative99.7%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in99.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.1 \cdot 10^{+55}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{elif}\;im \leq -0.0048:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 5.5 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \end{array} \]

Alternative 6: 97.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{if}\;im \leq -2.1 \cdot 10^{+55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.014:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.21:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;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 (* (pow im 7.0) (* (cos re) -0.0001984126984126984))))
   (if (<= im -2.1e+55)
     t_1
     (if (<= im -0.014)
       t_0
       (if (<= im 0.21)
         (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
         (if (<= im 1.1e+44) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double t_1 = pow(im, 7.0) * (cos(re) * -0.0001984126984126984);
	double tmp;
	if (im <= -2.1e+55) {
		tmp = t_1;
	} else if (im <= -0.014) {
		tmp = t_0;
	} else if (im <= 0.21) {
		tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 1.1e+44) {
		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 = (im ** 7.0d0) * (cos(re) * (-0.0001984126984126984d0))
    if (im <= (-2.1d+55)) then
        tmp = t_1
    else if (im <= (-0.014d0)) then
        tmp = t_0
    else if (im <= 0.21d0) then
        tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    else if (im <= 1.1d+44) 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 = Math.pow(im, 7.0) * (Math.cos(re) * -0.0001984126984126984);
	double tmp;
	if (im <= -2.1e+55) {
		tmp = t_1;
	} else if (im <= -0.014) {
		tmp = t_0;
	} else if (im <= 0.21) {
		tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 1.1e+44) {
		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 = math.pow(im, 7.0) * (math.cos(re) * -0.0001984126984126984)
	tmp = 0
	if im <= -2.1e+55:
		tmp = t_1
	elif im <= -0.014:
		tmp = t_0
	elif im <= 0.21:
		tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	elif im <= 1.1e+44:
		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((im ^ 7.0) * Float64(cos(re) * -0.0001984126984126984))
	tmp = 0.0
	if (im <= -2.1e+55)
		tmp = t_1;
	elseif (im <= -0.014)
		tmp = t_0;
	elseif (im <= 0.21)
		tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	elseif (im <= 1.1e+44)
		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 = (im ^ 7.0) * (cos(re) * -0.0001984126984126984);
	tmp = 0.0;
	if (im <= -2.1e+55)
		tmp = t_1;
	elseif (im <= -0.014)
		tmp = t_0;
	elseif (im <= 0.21)
		tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	elseif (im <= 1.1e+44)
		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[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.1e+55], t$95$1, If[LessEqual[im, -0.014], t$95$0, If[LessEqual[im, 0.21], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.1e+44], 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 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+55}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.1000000000000001e55 or 1.09999999999999998e44 < 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. sub0-neg100.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)} \]
    4. Taylor expanded in im around 0 100.0%

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

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

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

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

        \[\leadsto \left(\left(-\color{blue}{im \cdot \cos re}\right) + -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right)\right) + \left(-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]
      5. distribute-lft-neg-in100.0%

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

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

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

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

        \[\leadsto \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\color{blue}{\left(\cos re \cdot {im}^{5}\right) \cdot -0.008333333333333333} + -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\right) \]
      10. associate-*l*100.0%

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

        \[\leadsto \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333\right) + \color{blue}{\left(\cos re \cdot {im}^{7}\right) \cdot -0.0001984126984126984}\right) \]
      12. associate-*l*100.0%

        \[\leadsto \cos re \cdot \left(\left(-im\right) + -0.16666666666666666 \cdot {im}^{3}\right) + \left(\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333\right) + \color{blue}{\cos re \cdot \left({im}^{7} \cdot -0.0001984126984126984\right)}\right) \]
      13. distribute-lft-out100.0%

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

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

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

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

        \[\leadsto \color{blue}{{im}^{7} \cdot \left(-0.0001984126984126984 \cdot \cos re\right)} \]
    9. Simplified100.0%

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

    if -2.1000000000000001e55 < im < -0.0140000000000000003 or 0.209999999999999992 < im < 1.09999999999999998e44

    1. Initial program 99.8%

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

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

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

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

    if -0.0140000000000000003 < im < 0.209999999999999992

    1. Initial program 7.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.1 \cdot 10^{+55}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{elif}\;im \leq -0.014:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.21:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \end{array} \]

Alternative 7: 86.3% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{if}\;im \leq -0.00068:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.0004:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 2.55 \cdot 10^{+92}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (- (exp (- im)) (exp im)))))
   (if (<= im -0.00068)
     t_0
     (if (<= im 0.0004)
       (* im (- (cos re)))
       (if (<= im 2.55e+92)
         t_0
         (*
          (- (* (pow im 3.0) -0.16666666666666666) im)
          (+ (* -0.5 (* re re)) 1.0)))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double tmp;
	if (im <= -0.00068) {
		tmp = t_0;
	} else if (im <= 0.0004) {
		tmp = im * -cos(re);
	} else if (im <= 2.55e+92) {
		tmp = t_0;
	} else {
		tmp = ((pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	}
	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.5d0 * (exp(-im) - exp(im))
    if (im <= (-0.00068d0)) then
        tmp = t_0
    else if (im <= 0.0004d0) then
        tmp = im * -cos(re)
    else if (im <= 2.55d+92) then
        tmp = t_0
    else
        tmp = (((im ** 3.0d0) * (-0.16666666666666666d0)) - im) * (((-0.5d0) * (re * re)) + 1.0d0)
    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 tmp;
	if (im <= -0.00068) {
		tmp = t_0;
	} else if (im <= 0.0004) {
		tmp = im * -Math.cos(re);
	} else if (im <= 2.55e+92) {
		tmp = t_0;
	} else {
		tmp = ((Math.pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * (math.exp(-im) - math.exp(im))
	tmp = 0
	if im <= -0.00068:
		tmp = t_0
	elif im <= 0.0004:
		tmp = im * -math.cos(re)
	elif im <= 2.55e+92:
		tmp = t_0
	else:
		tmp = ((math.pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0)
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	tmp = 0.0
	if (im <= -0.00068)
		tmp = t_0;
	elseif (im <= 0.0004)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 2.55e+92)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) * Float64(Float64(-0.5 * Float64(re * re)) + 1.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * (exp(-im) - exp(im));
	tmp = 0.0;
	if (im <= -0.00068)
		tmp = t_0;
	elseif (im <= 0.0004)
		tmp = im * -cos(re);
	elseif (im <= 2.55e+92)
		tmp = t_0;
	else
		tmp = (((im ^ 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	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]}, If[LessEqual[im, -0.00068], t$95$0, If[LessEqual[im, 0.0004], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 2.55e+92], t$95$0, N[(N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision] * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 2.55 \cdot 10^{+92}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -6.8e-4 or 4.00000000000000019e-4 < im < 2.5500000000000001e92

    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. sub0-neg99.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 71.7%

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

    if -6.8e-4 < im < 4.00000000000000019e-4

    1. Initial program 7.5%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg99.7%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative99.7%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in99.7%

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

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

    if 2.5500000000000001e92 < 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. sub0-neg100.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)} \]
    4. Taylor expanded in im around 0 92.6%

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

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

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

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

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--92.6%

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

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

      \[\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. *-commutative5.4%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 78.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \mathbf{if}\;im \leq -7.8 \cdot 10^{+67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -58000:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\left(re \cdot re\right) \cdot 0.75\right)\right)\\ \mathbf{elif}\;im \leq 2900000:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (*
          (- (* (pow im 3.0) -0.16666666666666666) im)
          (+ (* -0.5 (* re re)) 1.0))))
   (if (<= im -7.8e+67)
     t_0
     (if (<= im -58000.0)
       (log1p (expm1 (* (* re re) 0.75)))
       (if (<= im 2900000.0) (* im (- (cos re))) t_0)))))
double code(double re, double im) {
	double t_0 = ((pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	double tmp;
	if (im <= -7.8e+67) {
		tmp = t_0;
	} else if (im <= -58000.0) {
		tmp = log1p(expm1(((re * re) * 0.75)));
	} else if (im <= 2900000.0) {
		tmp = im * -cos(re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = ((Math.pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	double tmp;
	if (im <= -7.8e+67) {
		tmp = t_0;
	} else if (im <= -58000.0) {
		tmp = Math.log1p(Math.expm1(((re * re) * 0.75)));
	} else if (im <= 2900000.0) {
		tmp = im * -Math.cos(re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = ((math.pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0)
	tmp = 0
	if im <= -7.8e+67:
		tmp = t_0
	elif im <= -58000.0:
		tmp = math.log1p(math.expm1(((re * re) * 0.75)))
	elif im <= 2900000.0:
		tmp = im * -math.cos(re)
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) * Float64(Float64(-0.5 * Float64(re * re)) + 1.0))
	tmp = 0.0
	if (im <= -7.8e+67)
		tmp = t_0;
	elseif (im <= -58000.0)
		tmp = log1p(expm1(Float64(Float64(re * re) * 0.75)));
	elseif (im <= 2900000.0)
		tmp = Float64(im * Float64(-cos(re)));
	else
		tmp = t_0;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision] * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.8e+67], t$95$0, If[LessEqual[im, -58000.0], N[Log[1 + N[(Exp[N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 2900000.0], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -58000:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\left(re \cdot re\right) \cdot 0.75\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -7.80000000000000013e67 or 2.9e6 < 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. sub0-neg100.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)} \]
    4. Taylor expanded in im around 0 77.0%

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

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

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

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

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--77.0%

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

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Taylor expanded in re around 0 8.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. *-commutative8.6%

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

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

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

        \[\leadsto \left(-0.5 \cdot {re}^{2}\right) \cdot \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} - im\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right) \]
      5. *-lft-identity8.6%

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

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

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

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

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

    if -7.80000000000000013e67 < im < -58000

    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. sub0-neg100.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)} \]
    4. Taylor expanded in re around 0 0.0%

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

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

        \[\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) \]
      3. distribute-rgt-out54.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr32.8%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 33.1%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative33.1%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow233.1%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
    10. Simplified33.1%

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot 0.75} \]
    11. Step-by-step derivation
      1. log1p-expm1-u46.0%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(re \cdot re\right) \cdot 0.75\right)\right)} \]
    12. Applied egg-rr46.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\left(re \cdot re\right) \cdot 0.75\right)\right)} \]

    if -58000 < im < 2.9e6

    1. Initial program 11.0%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg96.3%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative96.3%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in96.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.8 \cdot 10^{+67}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \mathbf{elif}\;im \leq -58000:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\left(re \cdot re\right) \cdot 0.75\right)\right)\\ \mathbf{elif}\;im \leq 2900000:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \end{array} \]

Alternative 9: 78.3% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -0.0092 \lor \neg \left(im \leq 2900000\right):\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -0.0092) (not (<= im 2900000.0)))
   (* (- (* (pow im 3.0) -0.16666666666666666) im) (+ (* -0.5 (* re re)) 1.0))
   (* im (- (cos re)))))
double code(double re, double im) {
	double tmp;
	if ((im <= -0.0092) || !(im <= 2900000.0)) {
		tmp = ((pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.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 <= (-0.0092d0)) .or. (.not. (im <= 2900000.0d0))) then
        tmp = (((im ** 3.0d0) * (-0.16666666666666666d0)) - im) * (((-0.5d0) * (re * re)) + 1.0d0)
    else
        tmp = im * -cos(re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -0.0092) || !(im <= 2900000.0)) {
		tmp = ((Math.pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	} else {
		tmp = im * -Math.cos(re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -0.0092) or not (im <= 2900000.0):
		tmp = ((math.pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0)
	else:
		tmp = im * -math.cos(re)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -0.0092) || !(im <= 2900000.0))
		tmp = Float64(Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) * Float64(Float64(-0.5 * Float64(re * re)) + 1.0));
	else
		tmp = Float64(im * Float64(-cos(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -0.0092) || ~((im <= 2900000.0)))
		tmp = (((im ^ 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	else
		tmp = im * -cos(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -0.0092], N[Not[LessEqual[im, 2900000.0]], $MachinePrecision]], N[(N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision] * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.0092 \lor \neg \left(im \leq 2900000\right):\\
\;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -0.0091999999999999998 or 2.9e6 < 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. sub0-neg99.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 im around 0 63.1%

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

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

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

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

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--63.1%

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

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

      \[\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. *-commutative10.9%

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

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

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

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

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

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

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

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

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

    if -0.0091999999999999998 < im < 2.9e6

    1. Initial program 8.9%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg98.2%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative98.2%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in98.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -0.0092 \lor \neg \left(im \leq 2900000\right):\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 10: 75.8% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ \mathbf{if}\;im \leq -2.7 \cdot 10^{+68}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -58000:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 4.05 \cdot 10^{+46}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666)))
   (if (<= im -2.7e+68)
     t_0
     (if (<= im -58000.0)
       (* re (* re 0.75))
       (if (<= im 4.05e+46) (* im (- (cos re))) (- t_0 im))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -2.7e+68) {
		tmp = t_0;
	} else if (im <= -58000.0) {
		tmp = re * (re * 0.75);
	} else if (im <= 4.05e+46) {
		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 = (im ** 3.0d0) * (-0.16666666666666666d0)
    if (im <= (-2.7d+68)) then
        tmp = t_0
    else if (im <= (-58000.0d0)) then
        tmp = re * (re * 0.75d0)
    else if (im <= 4.05d+46) 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 = Math.pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -2.7e+68) {
		tmp = t_0;
	} else if (im <= -58000.0) {
		tmp = re * (re * 0.75);
	} else if (im <= 4.05e+46) {
		tmp = im * -Math.cos(re);
	} else {
		tmp = t_0 - im;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	tmp = 0
	if im <= -2.7e+68:
		tmp = t_0
	elif im <= -58000.0:
		tmp = re * (re * 0.75)
	elif im <= 4.05e+46:
		tmp = im * -math.cos(re)
	else:
		tmp = t_0 - im
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im <= -2.7e+68)
		tmp = t_0;
	elseif (im <= -58000.0)
		tmp = Float64(re * Float64(re * 0.75));
	elseif (im <= 4.05e+46)
		tmp = Float64(im * Float64(-cos(re)));
	else
		tmp = Float64(t_0 - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im <= -2.7e+68)
		tmp = t_0;
	elseif (im <= -58000.0)
		tmp = re * (re * 0.75);
	elseif (im <= 4.05e+46)
		tmp = im * -cos(re);
	else
		tmp = t_0 - im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, If[LessEqual[im, -2.7e+68], t$95$0, If[LessEqual[im, -58000.0], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.05e+46], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], N[(t$95$0 - im), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
\mathbf{if}\;im \leq -2.7 \cdot 10^{+68}:\\
\;\;\;\;t_0\\

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

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

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


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

    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. sub0-neg100.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)} \]
    4. Taylor expanded in im around 0 85.4%

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

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

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

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

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--85.4%

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Step-by-step derivation
      1. fma-neg63.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
    9. Simplified63.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
    10. Taylor expanded in im around inf 63.2%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]

    if -2.69999999999999991e68 < im < -58000

    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. sub0-neg100.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)} \]
    4. Taylor expanded in re around 0 0.0%

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

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

        \[\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) \]
      3. distribute-rgt-out54.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr32.8%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 33.1%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative33.1%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow233.1%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*33.1%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified33.1%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]

    if -58000 < im < 4.05000000000000024e46

    1. Initial program 16.0%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg91.0%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative91.0%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in91.0%

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

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

    if 4.05000000000000024e46 < 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. sub0-neg100.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)} \]
    4. Taylor expanded in im around 0 80.5%

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

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

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

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

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--80.5%

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification74.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.7 \cdot 10^{+68}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -58000:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 4.05 \cdot 10^{+46}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 11: 54.3% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ \mathbf{if}\;im \leq -4.5 \cdot 10^{+67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -84000:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{-10}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666)))
   (if (<= im -4.5e+67)
     t_0
     (if (<= im -84000.0)
       (* re (* re 0.75))
       (if (<= im 1.7e-10) (- im) t_0)))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -4.5e+67) {
		tmp = t_0;
	} else if (im <= -84000.0) {
		tmp = re * (re * 0.75);
	} else if (im <= 1.7e-10) {
		tmp = -im;
	} else {
		tmp = t_0;
	}
	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 = (im ** 3.0d0) * (-0.16666666666666666d0)
    if (im <= (-4.5d+67)) then
        tmp = t_0
    else if (im <= (-84000.0d0)) then
        tmp = re * (re * 0.75d0)
    else if (im <= 1.7d-10) then
        tmp = -im
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -4.5e+67) {
		tmp = t_0;
	} else if (im <= -84000.0) {
		tmp = re * (re * 0.75);
	} else if (im <= 1.7e-10) {
		tmp = -im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	tmp = 0
	if im <= -4.5e+67:
		tmp = t_0
	elif im <= -84000.0:
		tmp = re * (re * 0.75)
	elif im <= 1.7e-10:
		tmp = -im
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im <= -4.5e+67)
		tmp = t_0;
	elseif (im <= -84000.0)
		tmp = Float64(re * Float64(re * 0.75));
	elseif (im <= 1.7e-10)
		tmp = Float64(-im);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im <= -4.5e+67)
		tmp = t_0;
	elseif (im <= -84000.0)
		tmp = re * (re * 0.75);
	elseif (im <= 1.7e-10)
		tmp = -im;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, If[LessEqual[im, -4.5e+67], t$95$0, If[LessEqual[im, -84000.0], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.7e-10], (-im), t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
\mathbf{if}\;im \leq -4.5 \cdot 10^{+67}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 1.7 \cdot 10^{-10}:\\
\;\;\;\;-im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4.4999999999999998e67 or 1.70000000000000007e-10 < im

    1. Initial program 99.6%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--75.8%

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Step-by-step derivation
      1. fma-neg54.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
    9. Simplified54.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
    10. Taylor expanded in im around inf 54.2%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]

    if -4.4999999999999998e67 < im < -84000

    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. sub0-neg100.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)} \]
    4. Taylor expanded in re around 0 0.0%

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

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

        \[\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) \]
      3. distribute-rgt-out54.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr32.8%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 33.1%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative33.1%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow233.1%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*33.1%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified33.1%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]

    if -84000 < im < 1.70000000000000007e-10

    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. sub0-neg9.2%

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg97.7%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative97.7%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in97.7%

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

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

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

        \[\leadsto \color{blue}{-im} \]
    9. Simplified55.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.5 \cdot 10^{+67}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -84000:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{-10}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \end{array} \]

Alternative 12: 75.8% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ \mathbf{if}\;im \leq -4.5 \cdot 10^{+67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -59000:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+46}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666)))
   (if (<= im -4.5e+67)
     t_0
     (if (<= im -59000.0)
       (* re (* re 0.75))
       (if (<= im 4.2e+46) (* im (- (cos re))) t_0)))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -4.5e+67) {
		tmp = t_0;
	} else if (im <= -59000.0) {
		tmp = re * (re * 0.75);
	} else if (im <= 4.2e+46) {
		tmp = im * -cos(re);
	} else {
		tmp = t_0;
	}
	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 = (im ** 3.0d0) * (-0.16666666666666666d0)
    if (im <= (-4.5d+67)) then
        tmp = t_0
    else if (im <= (-59000.0d0)) then
        tmp = re * (re * 0.75d0)
    else if (im <= 4.2d+46) then
        tmp = im * -cos(re)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -4.5e+67) {
		tmp = t_0;
	} else if (im <= -59000.0) {
		tmp = re * (re * 0.75);
	} else if (im <= 4.2e+46) {
		tmp = im * -Math.cos(re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	tmp = 0
	if im <= -4.5e+67:
		tmp = t_0
	elif im <= -59000.0:
		tmp = re * (re * 0.75)
	elif im <= 4.2e+46:
		tmp = im * -math.cos(re)
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im <= -4.5e+67)
		tmp = t_0;
	elseif (im <= -59000.0)
		tmp = Float64(re * Float64(re * 0.75));
	elseif (im <= 4.2e+46)
		tmp = Float64(im * Float64(-cos(re)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im <= -4.5e+67)
		tmp = t_0;
	elseif (im <= -59000.0)
		tmp = re * (re * 0.75);
	elseif (im <= 4.2e+46)
		tmp = im * -cos(re);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, If[LessEqual[im, -4.5e+67], t$95$0, If[LessEqual[im, -59000.0], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.2e+46], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
\mathbf{if}\;im \leq -4.5 \cdot 10^{+67}:\\
\;\;\;\;t_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4.4999999999999998e67 or 4.2e46 < 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. sub0-neg100.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)} \]
    4. Taylor expanded in im around 0 83.2%

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

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

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

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

        \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im \]
      5. distribute-lft-out--83.2%

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Step-by-step derivation
      1. fma-neg60.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
    9. Simplified60.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
    10. Taylor expanded in im around inf 60.3%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]

    if -4.4999999999999998e67 < im < -59000

    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. sub0-neg100.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)} \]
    4. Taylor expanded in re around 0 0.0%

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

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

        \[\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) \]
      3. distribute-rgt-out54.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr32.8%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 33.1%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative33.1%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow233.1%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*33.1%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified33.1%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]

    if -59000 < im < 4.2e46

    1. Initial program 16.0%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg91.0%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative91.0%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in91.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.5 \cdot 10^{+67}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -59000:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+46}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \end{array} \]

Alternative 13: 38.6% accurate, 20.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{if}\;im \leq -2.9 \cdot 10^{+55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -58000:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 2200000:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (* im (* 0.5 (* re re))) im)))
   (if (<= im -2.9e+55)
     t_0
     (if (<= im -58000.0)
       (* re (* re 0.75))
       (if (<= im 2200000.0) (- im) t_0)))))
double code(double re, double im) {
	double t_0 = (im * (0.5 * (re * re))) - im;
	double tmp;
	if (im <= -2.9e+55) {
		tmp = t_0;
	} else if (im <= -58000.0) {
		tmp = re * (re * 0.75);
	} else if (im <= 2200000.0) {
		tmp = -im;
	} else {
		tmp = t_0;
	}
	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 = (im * (0.5d0 * (re * re))) - im
    if (im <= (-2.9d+55)) then
        tmp = t_0
    else if (im <= (-58000.0d0)) then
        tmp = re * (re * 0.75d0)
    else if (im <= 2200000.0d0) then
        tmp = -im
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (im * (0.5 * (re * re))) - im;
	double tmp;
	if (im <= -2.9e+55) {
		tmp = t_0;
	} else if (im <= -58000.0) {
		tmp = re * (re * 0.75);
	} else if (im <= 2200000.0) {
		tmp = -im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (im * (0.5 * (re * re))) - im
	tmp = 0
	if im <= -2.9e+55:
		tmp = t_0
	elif im <= -58000.0:
		tmp = re * (re * 0.75)
	elif im <= 2200000.0:
		tmp = -im
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im)
	tmp = 0.0
	if (im <= -2.9e+55)
		tmp = t_0;
	elseif (im <= -58000.0)
		tmp = Float64(re * Float64(re * 0.75));
	elseif (im <= 2200000.0)
		tmp = Float64(-im);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im * (0.5 * (re * re))) - im;
	tmp = 0.0;
	if (im <= -2.9e+55)
		tmp = t_0;
	elseif (im <= -58000.0)
		tmp = re * (re * 0.75);
	elseif (im <= 2200000.0)
		tmp = -im;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]}, If[LessEqual[im, -2.9e+55], t$95$0, If[LessEqual[im, -58000.0], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2200000.0], (-im), t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\
\mathbf{if}\;im \leq -2.9 \cdot 10^{+55}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 2200000:\\
\;\;\;\;-im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.8999999999999999e55 or 2.2e6 < 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. sub0-neg100.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)} \]
    4. Taylor expanded in im around 0 5.6%

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg5.6%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative5.6%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in5.6%

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt2.9%

        \[\leadsto \color{blue}{\sqrt{\left(-im\right) \cdot \cos re} \cdot \sqrt{\left(-im\right) \cdot \cos re}} \]
      2. pow22.9%

        \[\leadsto \color{blue}{{\left(\sqrt{\left(-im\right) \cdot \cos re}\right)}^{2}} \]
      3. *-commutative2.9%

        \[\leadsto {\left(\sqrt{\color{blue}{\cos re \cdot \left(-im\right)}}\right)}^{2} \]
    8. Applied egg-rr2.9%

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

      \[\leadsto \color{blue}{{\left(\sqrt{-1}\right)}^{2} \cdot im + -0.5 \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \left({re}^{2} \cdot im\right)\right)} \]
    10. Step-by-step derivation
      1. fma-def0.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left({\left(\sqrt{-1}\right)}^{2}, im, -0.5 \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \left({re}^{2} \cdot im\right)\right)\right)} \]
      2. unpow20.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{-1} \cdot \sqrt{-1}}, im, -0.5 \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \left({re}^{2} \cdot im\right)\right)\right) \]
      3. rem-square-sqrt0.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{-1}, im, -0.5 \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \left({re}^{2} \cdot im\right)\right)\right) \]
      4. associate-*r*0.0%

        \[\leadsto \mathsf{fma}\left(-1, im, \color{blue}{\left(-0.5 \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \left({re}^{2} \cdot im\right)}\right) \]
      5. unpow20.0%

        \[\leadsto \mathsf{fma}\left(-1, im, \left(-0.5 \cdot \color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)}\right) \cdot \left({re}^{2} \cdot im\right)\right) \]
      6. rem-square-sqrt27.7%

        \[\leadsto \mathsf{fma}\left(-1, im, \left(-0.5 \cdot \color{blue}{-1}\right) \cdot \left({re}^{2} \cdot im\right)\right) \]
      7. metadata-eval27.7%

        \[\leadsto \mathsf{fma}\left(-1, im, \color{blue}{0.5} \cdot \left({re}^{2} \cdot im\right)\right) \]
      8. fma-def27.7%

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

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left({re}^{2} \cdot im\right) \]
      10. +-commutative27.7%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) + \left(-im\right)} \]
      11. unsub-neg27.7%

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) - im} \]
      12. *-commutative27.7%

        \[\leadsto \color{blue}{\left({re}^{2} \cdot im\right) \cdot 0.5} - im \]
      13. *-commutative27.7%

        \[\leadsto \color{blue}{\left(im \cdot {re}^{2}\right)} \cdot 0.5 - im \]
      14. associate-*l*27.7%

        \[\leadsto \color{blue}{im \cdot \left({re}^{2} \cdot 0.5\right)} - im \]
      15. unpow227.7%

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) - im \]
    11. Simplified27.7%

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

    if -2.8999999999999999e55 < im < -58000

    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. sub0-neg100.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)} \]
    4. Taylor expanded in re around 0 0.0%

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

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

        \[\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) \]
      3. distribute-rgt-out55.6%

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

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*55.6%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr34.2%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 34.6%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative34.6%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow234.6%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*34.6%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified34.6%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]

    if -58000 < im < 2.2e6

    1. Initial program 11.0%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg96.3%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative96.3%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in96.3%

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

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

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

        \[\leadsto \color{blue}{-im} \]
    9. Simplified53.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.9 \cdot 10^{+55}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq -58000:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 2200000:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \end{array} \]

Alternative 14: 35.0% accurate, 23.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -80000:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 2400000:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -80000.0)
   (* re (* re 0.75))
   (if (<= im 2400000.0) (- im) (* (+ 0.5 (* re (* re -0.25))) -3.0))))
double code(double re, double im) {
	double tmp;
	if (im <= -80000.0) {
		tmp = re * (re * 0.75);
	} else if (im <= 2400000.0) {
		tmp = -im;
	} else {
		tmp = (0.5 + (re * (re * -0.25))) * -3.0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= (-80000.0d0)) then
        tmp = re * (re * 0.75d0)
    else if (im <= 2400000.0d0) then
        tmp = -im
    else
        tmp = (0.5d0 + (re * (re * (-0.25d0)))) * (-3.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -80000.0) {
		tmp = re * (re * 0.75);
	} else if (im <= 2400000.0) {
		tmp = -im;
	} else {
		tmp = (0.5 + (re * (re * -0.25))) * -3.0;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -80000.0:
		tmp = re * (re * 0.75)
	elif im <= 2400000.0:
		tmp = -im
	else:
		tmp = (0.5 + (re * (re * -0.25))) * -3.0
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -80000.0)
		tmp = Float64(re * Float64(re * 0.75));
	elseif (im <= 2400000.0)
		tmp = Float64(-im);
	else
		tmp = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * -3.0);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -80000.0)
		tmp = re * (re * 0.75);
	elseif (im <= 2400000.0)
		tmp = -im;
	else
		tmp = (0.5 + (re * (re * -0.25))) * -3.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -80000.0], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2400000.0], (-im), N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -3.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -80000:\\
\;\;\;\;re \cdot \left(re \cdot 0.75\right)\\

\mathbf{elif}\;im \leq 2400000:\\
\;\;\;\;-im\\

\mathbf{else}:\\
\;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\\


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

    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. sub0-neg100.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)} \]
    4. Taylor expanded in re around 0 0.0%

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

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

        \[\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) \]
      3. distribute-rgt-out72.6%

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

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*72.6%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr17.4%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 18.0%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative18.0%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow218.0%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*18.0%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified18.0%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]

    if -8e4 < im < 2.4e6

    1. Initial program 11.0%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg96.3%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative96.3%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in96.3%

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

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

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

        \[\leadsto \color{blue}{-im} \]
    9. Simplified53.8%

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

    if 2.4e6 < 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. sub0-neg100.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)} \]
    4. Taylor expanded in re around 0 0.0%

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

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

        \[\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) \]
      3. distribute-rgt-out82.4%

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

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*82.4%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr18.0%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification36.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -80000:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;im \leq 2400000:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\\ \end{array} \]

Alternative 15: 34.2% accurate, 23.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -4.5 \cdot 10^{+152}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;re \leq 8.6 \cdot 10^{+154}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re -4.5e+152)
   (* re (* re 0.75))
   (if (<= re 8.6e+154) (- im) (* (+ 0.5 (* re (* re -0.25))) 27.0))))
double code(double re, double im) {
	double tmp;
	if (re <= -4.5e+152) {
		tmp = re * (re * 0.75);
	} else if (re <= 8.6e+154) {
		tmp = -im;
	} else {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= (-4.5d+152)) then
        tmp = re * (re * 0.75d0)
    else if (re <= 8.6d+154) then
        tmp = -im
    else
        tmp = (0.5d0 + (re * (re * (-0.25d0)))) * 27.0d0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= -4.5e+152) {
		tmp = re * (re * 0.75);
	} else if (re <= 8.6e+154) {
		tmp = -im;
	} else {
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= -4.5e+152:
		tmp = re * (re * 0.75)
	elif re <= 8.6e+154:
		tmp = -im
	else:
		tmp = (0.5 + (re * (re * -0.25))) * 27.0
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= -4.5e+152)
		tmp = Float64(re * Float64(re * 0.75));
	elseif (re <= 8.6e+154)
		tmp = Float64(-im);
	else
		tmp = Float64(Float64(0.5 + Float64(re * Float64(re * -0.25))) * 27.0);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= -4.5e+152)
		tmp = re * (re * 0.75);
	elseif (re <= 8.6e+154)
		tmp = -im;
	else
		tmp = (0.5 + (re * (re * -0.25))) * 27.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, -4.5e+152], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 8.6e+154], (-im), N[(N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 27.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.5 \cdot 10^{+152}:\\
\;\;\;\;re \cdot \left(re \cdot 0.75\right)\\

\mathbf{elif}\;re \leq 8.6 \cdot 10^{+154}:\\
\;\;\;\;-im\\

\mathbf{else}:\\
\;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if re < -4.5000000000000001e152

    1. Initial program 52.9%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified52.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 0.1%

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

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*0.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) \]
      3. distribute-rgt-out24.2%

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

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*24.2%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr35.4%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 35.4%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative35.4%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow235.4%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*35.4%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified35.4%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]

    if -4.5000000000000001e152 < re < 8.5999999999999995e154

    1. Initial program 52.7%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg53.6%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative53.6%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in53.6%

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

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

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

        \[\leadsto \color{blue}{-im} \]
    9. Simplified37.4%

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

    if 8.5999999999999995e154 < re

    1. Initial program 62.3%

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

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

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

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

        \[\leadsto -0.25 \cdot \color{blue}{\left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      2. associate-*r*0.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) \]
      3. distribute-rgt-out30.6%

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

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*30.6%

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

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

      \[\leadsto \color{blue}{27} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification36.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -4.5 \cdot 10^{+152}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{elif}\;re \leq 8.6 \cdot 10^{+154}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \end{array} \]

Alternative 16: 34.7% accurate, 33.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -58000 \lor \neg \left(im \leq 5400000\right):\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -58000.0) (not (<= im 5400000.0))) (* re (* re 0.75)) (- im)))
double code(double re, double im) {
	double tmp;
	if ((im <= -58000.0) || !(im <= 5400000.0)) {
		tmp = re * (re * 0.75);
	} 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 ((im <= (-58000.0d0)) .or. (.not. (im <= 5400000.0d0))) then
        tmp = re * (re * 0.75d0)
    else
        tmp = -im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -58000.0) || !(im <= 5400000.0)) {
		tmp = re * (re * 0.75);
	} else {
		tmp = -im;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -58000.0) or not (im <= 5400000.0):
		tmp = re * (re * 0.75)
	else:
		tmp = -im
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -58000.0) || !(im <= 5400000.0))
		tmp = Float64(re * Float64(re * 0.75));
	else
		tmp = Float64(-im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -58000.0) || ~((im <= 5400000.0)))
		tmp = re * (re * 0.75);
	else
		tmp = -im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -58000.0], N[Not[LessEqual[im, 5400000.0]], $MachinePrecision]], N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision], (-im)]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -58000 \lor \neg \left(im \leq 5400000\right):\\
\;\;\;\;re \cdot \left(re \cdot 0.75\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -58000 or 5.4e6 < 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. sub0-neg100.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)} \]
    4. Taylor expanded in re around 0 0.0%

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

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

        \[\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) \]
      3. distribute-rgt-out76.6%

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

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*76.6%

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

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
    7. Applied egg-rr17.7%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 17.6%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative17.6%

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow217.6%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*17.6%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    10. Simplified17.6%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]

    if -58000 < im < 5.4e6

    1. Initial program 11.0%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg96.3%

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative96.3%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in96.3%

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

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

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

        \[\leadsto \color{blue}{-im} \]
    9. Simplified53.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -58000 \lor \neg \left(im \leq 5400000\right):\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]

Alternative 17: 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 54.1%

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \left(\cos re \cdot im\right)} \]
  5. Step-by-step derivation
    1. mul-1-neg52.2%

      \[\leadsto \color{blue}{-\cos re \cdot im} \]
    2. *-commutative52.2%

      \[\leadsto -\color{blue}{im \cdot \cos re} \]
    3. distribute-lft-neg-in52.2%

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

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

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

      \[\leadsto \color{blue}{-im} \]
  9. Simplified29.6%

    \[\leadsto \color{blue}{-im} \]
  10. Final simplification29.6%

    \[\leadsto -im \]

Alternative 18: 2.9% accurate, 309.0× speedup?

\[\begin{array}{l} \\ -1.5 \end{array} \]
(FPCore (re im) :precision binary64 -1.5)
double code(double re, double im) {
	return -1.5;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = -1.5d0
end function
public static double code(double re, double im) {
	return -1.5;
}
def code(re, im):
	return -1.5
function code(re, im)
	return -1.5
end
function tmp = code(re, im)
	tmp = -1.5;
end
code[re_, im_] := -1.5
\begin{array}{l}

\\
-1.5
\end{array}
Derivation
  1. Initial program 54.1%

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

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

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

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

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

      \[\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) \]
    3. distribute-rgt-out41.3%

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

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

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

      \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
    7. associate-*l*41.3%

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

    \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
  7. Applied egg-rr10.0%

    \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
  8. Taylor expanded in re around 0 2.7%

    \[\leadsto \color{blue}{-1.5} \]
  9. Final simplification2.7%

    \[\leadsto -1.5 \]

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 2023171 
(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))))