math.sin on complex, imaginary part

Percentage Accurate: 54.3% → 99.6%
Time: 19.8s
Alternatives: 20
Speedup: 2.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 20 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.3% 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.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 10^{-6}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right) + \cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e-6)))
     (* (* 0.5 (cos re)) t_0)
     (+
      (* -0.008333333333333333 (* (cos re) (pow im 5.0)))
      (* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e-6)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = (-0.008333333333333333 * (cos(re) * pow(im, 5.0))) + (cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im));
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 1e-6)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = (-0.008333333333333333 * (Math.cos(re) * Math.pow(im, 5.0))) + (Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) - im));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 1e-6):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = (-0.008333333333333333 * (math.cos(re) * math.pow(im, 5.0))) + (math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) - im))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e-6))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(Float64(-0.008333333333333333 * Float64(cos(re) * (im ^ 5.0))) + Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 1e-6)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = (-0.008333333333333333 * (cos(re) * (im ^ 5.0))) + (cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) - im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 1e-6]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(-0.008333333333333333 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $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 10^{-6}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -inf.0 or 9.99999999999999955e-7 < (-.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)) < 9.99999999999999955e-7

    1. Initial program 8.4%

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

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

      \[\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) + -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\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) + -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)} \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 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 10^{-6}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} + \left(-0.008333333333333333 \cdot {im}^{5} - im\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 1e-6)))
     (* (* 0.5 (cos re)) t_0)
     (*
      (cos re)
      (+
       (* -0.16666666666666666 (pow im 3.0))
       (- (* -0.008333333333333333 (pow im 5.0)) im))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e-6)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) + ((-0.008333333333333333 * pow(im, 5.0)) - im));
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 1e-6)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = Math.cos(re) * ((-0.16666666666666666 * Math.pow(im, 3.0)) + ((-0.008333333333333333 * Math.pow(im, 5.0)) - im));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 1e-6):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = math.cos(re) * ((-0.16666666666666666 * math.pow(im, 3.0)) + ((-0.008333333333333333 * math.pow(im, 5.0)) - im))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e-6))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) + Float64(Float64(-0.008333333333333333 * (im ^ 5.0)) - im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 1e-6)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = cos(re) * ((-0.16666666666666666 * (im ^ 3.0)) + ((-0.008333333333333333 * (im ^ 5.0)) - im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 1e-6]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision] - im), $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 10^{-6}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} + \left(-0.008333333333333333 \cdot {im}^{5} - im\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 9.99999999999999955e-7 < (-.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)) < 9.99999999999999955e-7

    1. Initial program 8.4%

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

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

      \[\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) + -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)\right)} \]
    5. Step-by-step derivation
      1. *-commutative99.8%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -0.005 \lor \neg \left(t_0 \leq 10^{-6}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot \left(\cos re \cdot -0.16666666666666666\right) - im \cdot \cos re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 -0.005) (not (<= t_0 1e-6)))
     (* (* 0.5 (cos re)) t_0)
     (- (* (pow im 3.0) (* (cos re) -0.16666666666666666)) (* im (cos re))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -0.005) || !(t_0 <= 1e-6)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = (pow(im, 3.0) * (cos(re) * -0.16666666666666666)) - (im * cos(re));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-im) - exp(im)
    if ((t_0 <= (-0.005d0)) .or. (.not. (t_0 <= 1d-6))) then
        tmp = (0.5d0 * cos(re)) * t_0
    else
        tmp = ((im ** 3.0d0) * (cos(re) * (-0.16666666666666666d0))) - (im * cos(re))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -0.005) || !(t_0 <= 1e-6)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = (Math.pow(im, 3.0) * (Math.cos(re) * -0.16666666666666666)) - (im * Math.cos(re));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -0.005) or not (t_0 <= 1e-6):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = (math.pow(im, 3.0) * (math.cos(re) * -0.16666666666666666)) - (im * math.cos(re))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= -0.005) || !(t_0 <= 1e-6))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(Float64((im ^ 3.0) * Float64(cos(re) * -0.16666666666666666)) - Float64(im * cos(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -0.005) || ~((t_0 <= 1e-6)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = ((im ^ 3.0) * (cos(re) * -0.16666666666666666)) - (im * cos(re));
	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, -0.005], N[Not[LessEqual[t$95$0, 1e-6]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[Power[im, 3.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] - N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -0.0050000000000000001 or 9.99999999999999955e-7 < (-.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 -0.0050000000000000001 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 9.99999999999999955e-7

    1. Initial program 7.7%

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

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

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

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

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

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

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

Alternative 4: 99.8% accurate, 0.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -0.0050000000000000001 or 9.99999999999999955e-7 < (-.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 -0.0050000000000000001 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 9.99999999999999955e-7

    1. Initial program 7.7%

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

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

Alternative 5: 97.0% accurate, 1.4× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -2.3e64 or 4.5e61 < 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) + -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\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) + -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)} \]
      2. +-commutative100.0%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left({im}^{5}, \cos re \cdot -0.008333333333333333, -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)}\right) \]
      8. unsub-neg100.0%

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

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

        \[\leadsto \mathsf{fma}\left({im}^{5}, \cos re \cdot -0.008333333333333333, \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im\right) \]
      11. distribute-lft-out--100.0%

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

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

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

    if -2.3e64 < im < -18

    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 \color{blue}{0.5 \cdot \left(e^{-im} - e^{im}\right) + -0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right)} \]
      2. *-commutative0.0%

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

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow289.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*89.5%

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

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

    if -18 < im < 0.070000000000000007

    1. Initial program 9.7%

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

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

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

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

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

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

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

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

    if 0.070000000000000007 < im < 4.5e61

    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 100.0%

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

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

Alternative 6: 95.6% accurate, 1.4× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.7e93 or 4.5e61 < 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) + -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\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) + -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)} \]
      2. +-commutative100.0%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left({im}^{5}, \cos re \cdot -0.008333333333333333, -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)}\right) \]
      8. unsub-neg100.0%

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

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

        \[\leadsto \mathsf{fma}\left({im}^{5}, \cos re \cdot -0.008333333333333333, \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im\right) \]
      11. distribute-lft-out--100.0%

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

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

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

    if -1.7e93 < im < -2e12 or 3.00000000000000008e-5 < im < 4.5e61

    1. Initial program 98.7%

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

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

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

    if -2e12 < im < 3.00000000000000008e-5

    1. Initial program 9.4%

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

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

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

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

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

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

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

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

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

Alternative 7: 95.8% accurate, 1.4× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.7e93 or 4.5e61 < 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) + -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\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) + -0.008333333333333333 \cdot \left(\cos re \cdot {im}^{5}\right)} \]
      2. +-commutative100.0%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left({im}^{5}, \cos re \cdot -0.008333333333333333, -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)}\right) \]
      8. unsub-neg100.0%

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

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

        \[\leadsto \mathsf{fma}\left({im}^{5}, \cos re \cdot -0.008333333333333333, \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im\right) \]
      11. distribute-lft-out--100.0%

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

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

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

    if -1.7e93 < im < -2e12 or 0.28000000000000003 < im < 4.5e61

    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 87.5%

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

    if -2e12 < im < 0.28000000000000003

    1. Initial program 11.1%

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

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

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

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

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

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

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

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

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

Alternative 8: 89.7% accurate, 1.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -3.2999999999999998 or 3.2999999999999998 < 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 76.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({im}^{5}, -0.008333333333333333 \cdot \cos re, -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)\right)} \]
      6. *-commutative76.2%

        \[\leadsto \mathsf{fma}\left({im}^{5}, \color{blue}{\cos re \cdot -0.008333333333333333}, -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + -1 \cdot \left(\cos re \cdot im\right)\right) \]
      7. mul-1-neg76.2%

        \[\leadsto \mathsf{fma}\left({im}^{5}, \cos re \cdot -0.008333333333333333, -0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) + \color{blue}{\left(-\cos re \cdot im\right)}\right) \]
      8. unsub-neg76.2%

        \[\leadsto \mathsf{fma}\left({im}^{5}, \cos re \cdot -0.008333333333333333, \color{blue}{-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\right) - \cos re \cdot im}\right) \]
      9. *-commutative76.2%

        \[\leadsto \mathsf{fma}\left({im}^{5}, \cos re \cdot -0.008333333333333333, \color{blue}{\left(\cos re \cdot {im}^{3}\right) \cdot -0.16666666666666666} - \cos re \cdot im\right) \]
      10. associate-*l*76.2%

        \[\leadsto \mathsf{fma}\left({im}^{5}, \cos re \cdot -0.008333333333333333, \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)} - \cos re \cdot im\right) \]
      11. distribute-lft-out--76.2%

        \[\leadsto \mathsf{fma}\left({im}^{5}, \cos re \cdot -0.008333333333333333, \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)}\right) \]
    6. Simplified76.2%

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

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

    if -3.2999999999999998 < im < 3.2999999999999998

    1. Initial program 9.0%

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

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

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

Alternative 9: 77.7% accurate, 2.6× speedup?

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

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

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

\mathbf{elif}\;im \leq 1.65 \cdot 10^{+78}:\\
\;\;\;\;{re}^{4} \cdot \left(im \cdot -0.041666666666666664\right) - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -9.6e23 or 1.65e78 < 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 79.9%

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

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

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

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

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

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

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

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

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

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

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

    if -9.6e23 < im < 600

    1. Initial program 13.0%

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

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

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

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

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

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

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

    if 600 < im < 1.65e78

    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 3.4%

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

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

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

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

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

      \[\leadsto \color{blue}{-0.041666666666666664 \cdot \left({re}^{4} \cdot im\right) + \left(-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)\right)} \]
    8. Step-by-step derivation
      1. neg-mul-116.5%

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \left({re}^{2} \cdot im\right) + -0.041666666666666664 \cdot \left({re}^{4} \cdot im\right)\right) - im} \]
      6. associate-*r*16.5%

        \[\leadsto \left(\color{blue}{\left(0.5 \cdot {re}^{2}\right) \cdot im} + -0.041666666666666664 \cdot \left({re}^{4} \cdot im\right)\right) - im \]
      7. associate-*r*16.5%

        \[\leadsto \left(\left(0.5 \cdot {re}^{2}\right) \cdot im + \color{blue}{\left(-0.041666666666666664 \cdot {re}^{4}\right) \cdot im}\right) - im \]
      8. distribute-rgt-out16.5%

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

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

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5 + -0.041666666666666664 \cdot {re}^{4}\right) - im \]
      11. associate-*l*16.5%

        \[\leadsto im \cdot \left(\color{blue}{re \cdot \left(re \cdot 0.5\right)} + -0.041666666666666664 \cdot {re}^{4}\right) - im \]
      12. *-commutative16.5%

        \[\leadsto im \cdot \left(re \cdot \left(re \cdot 0.5\right) + \color{blue}{{re}^{4} \cdot -0.041666666666666664}\right) - im \]
    9. Simplified16.5%

      \[\leadsto \color{blue}{im \cdot \left(re \cdot \left(re \cdot 0.5\right) + {re}^{4} \cdot -0.041666666666666664\right) - im} \]
    10. Taylor expanded in re around inf 37.9%

      \[\leadsto \color{blue}{-0.041666666666666664 \cdot \left({re}^{4} \cdot im\right)} - im \]
    11. Step-by-step derivation
      1. *-commutative37.9%

        \[\leadsto \color{blue}{\left({re}^{4} \cdot im\right) \cdot -0.041666666666666664} - im \]
      2. associate-*l*37.9%

        \[\leadsto \color{blue}{{re}^{4} \cdot \left(im \cdot -0.041666666666666664\right)} - im \]
    12. Simplified37.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -9.6 \cdot 10^{+23}:\\ \;\;\;\;\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + \left(re \cdot re\right) \cdot -0.5\right)\\ \mathbf{elif}\;im \leq 600:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.65 \cdot 10^{+78}:\\ \;\;\;\;{re}^{4} \cdot \left(im \cdot -0.041666666666666664\right) - im\\ \mathbf{else}:\\ \;\;\;\;\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(1 + \left(re \cdot re\right) \cdot -0.5\right)\\ \end{array} \]

Alternative 10: 76.3% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -0.16666666666666666 \cdot {im}^{3}\\ \mathbf{if}\;im \leq -3.4 \cdot 10^{+52}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 510:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 6.8 \cdot 10^{+85}:\\ \;\;\;\;{re}^{4} \cdot \left(im \cdot -0.041666666666666664\right) - im\\ \mathbf{else}:\\ \;\;\;\;t_0 - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* -0.16666666666666666 (pow im 3.0))))
   (if (<= im -3.4e+52)
     t_0
     (if (<= im 510.0)
       (* (cos re) (- im))
       (if (<= im 6.8e+85)
         (- (* (pow re 4.0) (* im -0.041666666666666664)) im)
         (- t_0 im))))))
double code(double re, double im) {
	double t_0 = -0.16666666666666666 * pow(im, 3.0);
	double tmp;
	if (im <= -3.4e+52) {
		tmp = t_0;
	} else if (im <= 510.0) {
		tmp = cos(re) * -im;
	} else if (im <= 6.8e+85) {
		tmp = (pow(re, 4.0) * (im * -0.041666666666666664)) - im;
	} else {
		tmp = t_0 - im;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-0.16666666666666666d0) * (im ** 3.0d0)
    if (im <= (-3.4d+52)) then
        tmp = t_0
    else if (im <= 510.0d0) then
        tmp = cos(re) * -im
    else if (im <= 6.8d+85) then
        tmp = ((re ** 4.0d0) * (im * (-0.041666666666666664d0))) - im
    else
        tmp = t_0 - im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = -0.16666666666666666 * Math.pow(im, 3.0);
	double tmp;
	if (im <= -3.4e+52) {
		tmp = t_0;
	} else if (im <= 510.0) {
		tmp = Math.cos(re) * -im;
	} else if (im <= 6.8e+85) {
		tmp = (Math.pow(re, 4.0) * (im * -0.041666666666666664)) - im;
	} else {
		tmp = t_0 - im;
	}
	return tmp;
}
def code(re, im):
	t_0 = -0.16666666666666666 * math.pow(im, 3.0)
	tmp = 0
	if im <= -3.4e+52:
		tmp = t_0
	elif im <= 510.0:
		tmp = math.cos(re) * -im
	elif im <= 6.8e+85:
		tmp = (math.pow(re, 4.0) * (im * -0.041666666666666664)) - im
	else:
		tmp = t_0 - im
	return tmp
function code(re, im)
	t_0 = Float64(-0.16666666666666666 * (im ^ 3.0))
	tmp = 0.0
	if (im <= -3.4e+52)
		tmp = t_0;
	elseif (im <= 510.0)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 6.8e+85)
		tmp = Float64(Float64((re ^ 4.0) * Float64(im * -0.041666666666666664)) - im);
	else
		tmp = Float64(t_0 - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = -0.16666666666666666 * (im ^ 3.0);
	tmp = 0.0;
	if (im <= -3.4e+52)
		tmp = t_0;
	elseif (im <= 510.0)
		tmp = cos(re) * -im;
	elseif (im <= 6.8e+85)
		tmp = ((re ^ 4.0) * (im * -0.041666666666666664)) - im;
	else
		tmp = t_0 - im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3.4e+52], t$95$0, If[LessEqual[im, 510.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 6.8e+85], N[(N[(N[Power[re, 4.0], $MachinePrecision] * N[(im * -0.041666666666666664), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(t$95$0 - im), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 6.8 \cdot 10^{+85}:\\
\;\;\;\;{re}^{4} \cdot \left(im \cdot -0.041666666666666664\right) - im\\

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


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

    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 88.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-neg88.1%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around inf 69.8%

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

    if -3.4e52 < im < 510

    1. Initial program 19.4%

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

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

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

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

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

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

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

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

    if 510 < im < 6.8000000000000007e85

    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 3.4%

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

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

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

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

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

      \[\leadsto \color{blue}{-0.041666666666666664 \cdot \left({re}^{4} \cdot im\right) + \left(-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)\right)} \]
    8. Step-by-step derivation
      1. neg-mul-116.5%

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot \left({re}^{2} \cdot im\right) + -0.041666666666666664 \cdot \left({re}^{4} \cdot im\right)\right) - im} \]
      6. associate-*r*16.5%

        \[\leadsto \left(\color{blue}{\left(0.5 \cdot {re}^{2}\right) \cdot im} + -0.041666666666666664 \cdot \left({re}^{4} \cdot im\right)\right) - im \]
      7. associate-*r*16.5%

        \[\leadsto \left(\left(0.5 \cdot {re}^{2}\right) \cdot im + \color{blue}{\left(-0.041666666666666664 \cdot {re}^{4}\right) \cdot im}\right) - im \]
      8. distribute-rgt-out16.5%

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

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

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5 + -0.041666666666666664 \cdot {re}^{4}\right) - im \]
      11. associate-*l*16.5%

        \[\leadsto im \cdot \left(\color{blue}{re \cdot \left(re \cdot 0.5\right)} + -0.041666666666666664 \cdot {re}^{4}\right) - im \]
      12. *-commutative16.5%

        \[\leadsto im \cdot \left(re \cdot \left(re \cdot 0.5\right) + \color{blue}{{re}^{4} \cdot -0.041666666666666664}\right) - im \]
    9. Simplified16.5%

      \[\leadsto \color{blue}{im \cdot \left(re \cdot \left(re \cdot 0.5\right) + {re}^{4} \cdot -0.041666666666666664\right) - im} \]
    10. Taylor expanded in re around inf 37.9%

      \[\leadsto \color{blue}{-0.041666666666666664 \cdot \left({re}^{4} \cdot im\right)} - im \]
    11. Step-by-step derivation
      1. *-commutative37.9%

        \[\leadsto \color{blue}{\left({re}^{4} \cdot im\right) \cdot -0.041666666666666664} - im \]
      2. associate-*l*37.9%

        \[\leadsto \color{blue}{{re}^{4} \cdot \left(im \cdot -0.041666666666666664\right)} - im \]
    12. Simplified37.9%

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

    if 6.8000000000000007e85 < 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 90.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-neg90.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.4 \cdot 10^{+52}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\ \mathbf{elif}\;im \leq 510:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 6.8 \cdot 10^{+85}:\\ \;\;\;\;{re}^{4} \cdot \left(im \cdot -0.041666666666666664\right) - im\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3} - im\\ \end{array} \]

Alternative 11: 74.7% accurate, 2.8× speedup?

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

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

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

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


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

    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 88.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-neg88.1%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around inf 69.8%

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

    if -8.1999999999999999e52 < im < 6.9000000000000003e-18

    1. Initial program 18.1%

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

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

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

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

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

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

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

    if 6.9000000000000003e-18 < im

    1. Initial program 97.4%

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 68.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-neg68.5%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -8.2 \cdot 10^{+52}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\ \mathbf{elif}\;im \leq 6.9 \cdot 10^{-18}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3} - im\\ \end{array} \]

Alternative 12: 52.9% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -2000000000000 \lor \neg \left(im \leq 3.4\right):\\
\;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. 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 69.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-neg69.1%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around inf 48.8%

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

    if -2e12 < im < 3.39999999999999991

    1. Initial program 11.1%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-im} \]
    9. Simplified50.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2000000000000 \lor \neg \left(im \leq 3.4\right):\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]

Alternative 13: 75.1% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.5 \cdot 10^{+54} \lor \neg \left(im \leq 1600000000000\right):\\
\;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -2.50000000000000003e54 or 1.6e12 < 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.7%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around inf 54.8%

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

    if -2.50000000000000003e54 < im < 1.6e12

    1. Initial program 19.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.5 \cdot 10^{+54} \lor \neg \left(im \leq 1600000000000\right):\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \end{array} \]

Alternative 14: 38.4% accurate, 20.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -5.5 \cdot 10^{+155}:\\ \;\;\;\;\frac{im \cdot im}{im \cdot \left(re \cdot \left(re \cdot -0.5\right)\right) - im}\\ \mathbf{elif}\;im \leq 9 \cdot 10^{+76}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right) + -1\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -5.5e+155)
   (/ (* im im) (- (* im (* re (* re -0.5))) im))
   (if (<= im 9e+76) (- im) (* im (+ (* 0.5 (* re re)) -1.0)))))
double code(double re, double im) {
	double tmp;
	if (im <= -5.5e+155) {
		tmp = (im * im) / ((im * (re * (re * -0.5))) - im);
	} else if (im <= 9e+76) {
		tmp = -im;
	} else {
		tmp = 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) :: tmp
    if (im <= (-5.5d+155)) then
        tmp = (im * im) / ((im * (re * (re * (-0.5d0)))) - im)
    else if (im <= 9d+76) then
        tmp = -im
    else
        tmp = im * ((0.5d0 * (re * re)) + (-1.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -5.5e+155) {
		tmp = (im * im) / ((im * (re * (re * -0.5))) - im);
	} else if (im <= 9e+76) {
		tmp = -im;
	} else {
		tmp = im * ((0.5 * (re * re)) + -1.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -5.5e+155:
		tmp = (im * im) / ((im * (re * (re * -0.5))) - im)
	elif im <= 9e+76:
		tmp = -im
	else:
		tmp = im * ((0.5 * (re * re)) + -1.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -5.5e+155)
		tmp = Float64(Float64(im * im) / Float64(Float64(im * Float64(re * Float64(re * -0.5))) - im));
	elseif (im <= 9e+76)
		tmp = Float64(-im);
	else
		tmp = Float64(im * Float64(Float64(0.5 * Float64(re * re)) + -1.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -5.5e+155)
		tmp = (im * im) / ((im * (re * (re * -0.5))) - im);
	elseif (im <= 9e+76)
		tmp = -im;
	else
		tmp = im * ((0.5 * (re * re)) + -1.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -5.5e+155], N[(N[(im * im), $MachinePrecision] / N[(N[(im * N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 9e+76], (-im), N[(im * N[(N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.5 \cdot 10^{+155}:\\
\;\;\;\;\frac{im \cdot im}{im \cdot \left(re \cdot \left(re \cdot -0.5\right)\right) - im}\\

\mathbf{elif}\;im \leq 9 \cdot 10^{+76}:\\
\;\;\;\;-im\\

\mathbf{else}:\\
\;\;\;\;im \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 < -5.5000000000000001e155

    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 7.5%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)} \]
    8. Step-by-step derivation
      1. neg-mul-126.8%

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

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

        \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right) - im} \]
      4. *-commutative26.8%

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

        \[\leadsto \color{blue}{{re}^{2} \cdot \left(im \cdot 0.5\right)} - im \]
      6. unpow226.8%

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

        \[\leadsto \left(re \cdot re\right) \cdot \color{blue}{\left(0.5 \cdot im\right)} - im \]
      8. associate-*l*26.8%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(0.5 \cdot im\right)\right)} - im \]
      9. *-commutative26.8%

        \[\leadsto re \cdot \left(re \cdot \color{blue}{\left(im \cdot 0.5\right)}\right) - im \]
    9. Simplified26.8%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im} \]
    10. Step-by-step derivation
      1. flip--47.2%

        \[\leadsto \color{blue}{\frac{\left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) \cdot \left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) - im \cdot im}{re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) + im}} \]
      2. frac-2neg47.2%

        \[\leadsto \color{blue}{\frac{-\left(\left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) \cdot \left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) - im \cdot im\right)}{-\left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) + im\right)}} \]
    11. Applied egg-rr0.0%

      \[\leadsto \color{blue}{\frac{-\left({re}^{4} \cdot \left(0.25 \cdot \left(im \cdot im\right)\right) - im \cdot im\right)}{-\mathsf{fma}\left(re, \left(re \cdot 0.5\right) \cdot im, im\right)}} \]
    12. Step-by-step derivation
      1. Simplified0.0%

        \[\leadsto \color{blue}{\frac{\left({re}^{4} \cdot -0.25\right) \cdot \left(im \cdot im\right) + im \cdot im}{im \cdot \left(\left(-0.5 \cdot re\right) \cdot re\right) - im}} \]
      2. Taylor expanded in re around 0 61.1%

        \[\leadsto \frac{\color{blue}{{im}^{2}}}{im \cdot \left(\left(-0.5 \cdot re\right) \cdot re\right) - im} \]
      3. Step-by-step derivation
        1. unpow261.1%

          \[\leadsto \frac{\color{blue}{im \cdot im}}{im \cdot \left(\left(-0.5 \cdot re\right) \cdot re\right) - im} \]
      4. Simplified61.1%

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

      if -5.5000000000000001e155 < im < 8.9999999999999995e76

      1. Initial program 33.9%

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

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

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

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

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

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

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

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

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

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

      if 8.9999999999999995e76 < 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 6.1%

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

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

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

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

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

        \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)} \]
      8. Step-by-step derivation
        1. neg-mul-135.0%

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

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

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

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

          \[\leadsto \color{blue}{{re}^{2} \cdot \left(im \cdot 0.5\right)} - im \]
        6. unpow235.0%

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

          \[\leadsto \left(re \cdot re\right) \cdot \color{blue}{\left(0.5 \cdot im\right)} - im \]
        8. associate-*l*35.0%

          \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(0.5 \cdot im\right)\right)} - im \]
        9. *-commutative35.0%

          \[\leadsto re \cdot \left(re \cdot \color{blue}{\left(im \cdot 0.5\right)}\right) - im \]
      9. Simplified35.0%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im} \]
      10. Step-by-step derivation
        1. flip--27.2%

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

          \[\leadsto \color{blue}{\frac{-\left(\left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) \cdot \left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) - im \cdot im\right)}{-\left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) + im\right)}} \]
      11. Applied egg-rr5.6%

        \[\leadsto \color{blue}{\frac{-\left({re}^{4} \cdot \left(0.25 \cdot \left(im \cdot im\right)\right) - im \cdot im\right)}{-\mathsf{fma}\left(re, \left(re \cdot 0.5\right) \cdot im, im\right)}} \]
      12. Step-by-step derivation
        1. Simplified5.6%

          \[\leadsto \color{blue}{\frac{\left({re}^{4} \cdot -0.25\right) \cdot \left(im \cdot im\right) + im \cdot im}{im \cdot \left(\left(-0.5 \cdot re\right) \cdot re\right) - im}} \]
        2. Taylor expanded in re around 0 35.0%

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

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

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

            \[\leadsto \color{blue}{\left(0.5 \cdot {re}^{2}\right) \cdot im} + \left(-im\right) \]
          4. neg-mul-135.0%

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

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

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

            \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5 + -1\right) \]
        4. Simplified35.0%

          \[\leadsto \color{blue}{im \cdot \left(\left(re \cdot re\right) \cdot 0.5 + -1\right)} \]
      13. Recombined 3 regimes into one program.
      14. Final simplification41.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.5 \cdot 10^{+155}:\\ \;\;\;\;\frac{im \cdot im}{im \cdot \left(re \cdot \left(re \cdot -0.5\right)\right) - im}\\ \mathbf{elif}\;im \leq 9 \cdot 10^{+76}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right) + -1\right)\\ \end{array} \]

      Alternative 15: 36.3% accurate, 27.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -17 \lor \neg \left(im \leq 4.1 \cdot 10^{+89}\right):\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (or (<= im -17.0) (not (<= im 4.1e+89))) (* im (* 0.5 (* re re))) (- im)))
      double code(double re, double im) {
      	double tmp;
      	if ((im <= -17.0) || !(im <= 4.1e+89)) {
      		tmp = im * (0.5 * (re * re));
      	} else {
      		tmp = -im;
      	}
      	return tmp;
      }
      
      real(8) function code(re, im)
          real(8), intent (in) :: re
          real(8), intent (in) :: im
          real(8) :: tmp
          if ((im <= (-17.0d0)) .or. (.not. (im <= 4.1d+89))) then
              tmp = im * (0.5d0 * (re * re))
          else
              tmp = -im
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double tmp;
      	if ((im <= -17.0) || !(im <= 4.1e+89)) {
      		tmp = im * (0.5 * (re * re));
      	} else {
      		tmp = -im;
      	}
      	return tmp;
      }
      
      def code(re, im):
      	tmp = 0
      	if (im <= -17.0) or not (im <= 4.1e+89):
      		tmp = im * (0.5 * (re * re))
      	else:
      		tmp = -im
      	return tmp
      
      function code(re, im)
      	tmp = 0.0
      	if ((im <= -17.0) || !(im <= 4.1e+89))
      		tmp = Float64(im * Float64(0.5 * Float64(re * re)));
      	else
      		tmp = Float64(-im);
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	tmp = 0.0;
      	if ((im <= -17.0) || ~((im <= 4.1e+89)))
      		tmp = im * (0.5 * (re * re));
      	else
      		tmp = -im;
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := If[Or[LessEqual[im, -17.0], N[Not[LessEqual[im, 4.1e+89]], $MachinePrecision]], N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-im)]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;im \leq -17 \lor \neg \left(im \leq 4.1 \cdot 10^{+89}\right):\\
      \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;-im\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if im < -17 or 4.09999999999999985e89 < 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.9%

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

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

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

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

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

          \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)} \]
        8. Step-by-step derivation
          1. neg-mul-124.9%

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

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

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

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

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

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

            \[\leadsto \left(re \cdot re\right) \cdot \color{blue}{\left(0.5 \cdot im\right)} - im \]
          8. associate-*l*24.9%

            \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(0.5 \cdot im\right)\right)} - im \]
          9. *-commutative24.9%

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

          \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im} \]
        10. Step-by-step derivation
          1. flip--27.9%

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

            \[\leadsto \color{blue}{\frac{-\left(\left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) \cdot \left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) - im \cdot im\right)}{-\left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) + im\right)}} \]
        11. Applied egg-rr4.6%

          \[\leadsto \color{blue}{\frac{-\left({re}^{4} \cdot \left(0.25 \cdot \left(im \cdot im\right)\right) - im \cdot im\right)}{-\mathsf{fma}\left(re, \left(re \cdot 0.5\right) \cdot im, im\right)}} \]
        12. Step-by-step derivation
          1. Simplified4.6%

            \[\leadsto \color{blue}{\frac{\left({re}^{4} \cdot -0.25\right) \cdot \left(im \cdot im\right) + im \cdot im}{im \cdot \left(\left(-0.5 \cdot re\right) \cdot re\right) - im}} \]
          2. Taylor expanded in re around inf 22.6%

            \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right)} \]
          3. Step-by-step derivation
            1. *-commutative22.6%

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

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

              \[\leadsto \color{blue}{im \cdot \left({re}^{2} \cdot 0.5\right)} \]
            4. unpow222.6%

              \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) \]
          4. Simplified22.6%

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

          if -17 < im < 4.09999999999999985e89

          1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -17 \lor \neg \left(im \leq 4.1 \cdot 10^{+89}\right):\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]

        Alternative 16: 35.8% accurate, 34.3× speedup?

        \[\begin{array}{l} \\ im \cdot \left(0.5 \cdot \left(re \cdot re\right) + -1\right) \end{array} \]
        (FPCore (re im) :precision binary64 (* im (+ (* 0.5 (* re re)) -1.0)))
        double code(double re, double im) {
        	return im * ((0.5 * (re * re)) + -1.0);
        }
        
        real(8) function code(re, im)
            real(8), intent (in) :: re
            real(8), intent (in) :: im
            code = im * ((0.5d0 * (re * re)) + (-1.0d0))
        end function
        
        public static double code(double re, double im) {
        	return im * ((0.5 * (re * re)) + -1.0);
        }
        
        def code(re, im):
        	return im * ((0.5 * (re * re)) + -1.0)
        
        function code(re, im)
        	return Float64(im * Float64(Float64(0.5 * Float64(re * re)) + -1.0))
        end
        
        function tmp = code(re, im)
        	tmp = im * ((0.5 * (re * re)) + -1.0);
        end
        
        code[re_, im_] := N[(im * N[(N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        im \cdot \left(0.5 \cdot \left(re \cdot re\right) + -1\right)
        \end{array}
        
        Derivation
        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.7%

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

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

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

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

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

          \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)} \]
        8. Step-by-step derivation
          1. neg-mul-134.5%

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

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

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

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

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

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

            \[\leadsto \left(re \cdot re\right) \cdot \color{blue}{\left(0.5 \cdot im\right)} - im \]
          8. associate-*l*34.5%

            \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(0.5 \cdot im\right)\right)} - im \]
          9. *-commutative34.5%

            \[\leadsto re \cdot \left(re \cdot \color{blue}{\left(im \cdot 0.5\right)}\right) - im \]
        9. Simplified34.5%

          \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im} \]
        10. Step-by-step derivation
          1. flip--22.9%

            \[\leadsto \color{blue}{\frac{\left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) \cdot \left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) - im \cdot im}{re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) + im}} \]
          2. frac-2neg22.9%

            \[\leadsto \color{blue}{\frac{-\left(\left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) \cdot \left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right)\right) - im \cdot im\right)}{-\left(re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) + im\right)}} \]
        11. Applied egg-rr13.0%

          \[\leadsto \color{blue}{\frac{-\left({re}^{4} \cdot \left(0.25 \cdot \left(im \cdot im\right)\right) - im \cdot im\right)}{-\mathsf{fma}\left(re, \left(re \cdot 0.5\right) \cdot im, im\right)}} \]
        12. Step-by-step derivation
          1. Simplified12.9%

            \[\leadsto \color{blue}{\frac{\left({re}^{4} \cdot -0.25\right) \cdot \left(im \cdot im\right) + im \cdot im}{im \cdot \left(\left(-0.5 \cdot re\right) \cdot re\right) - im}} \]
          2. Taylor expanded in re around 0 34.5%

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

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

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

              \[\leadsto \color{blue}{\left(0.5 \cdot {re}^{2}\right) \cdot im} + \left(-im\right) \]
            4. neg-mul-134.5%

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

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

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

              \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5 + -1\right) \]
          4. Simplified34.5%

            \[\leadsto \color{blue}{im \cdot \left(\left(re \cdot re\right) \cdot 0.5 + -1\right)} \]
          5. Final simplification34.5%

            \[\leadsto im \cdot \left(0.5 \cdot \left(re \cdot re\right) + -1\right) \]

          Alternative 17: 35.9% accurate, 34.3× speedup?

          \[\begin{array}{l} \\ re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im \end{array} \]
          (FPCore (re im) :precision binary64 (- (* re (* re (* im 0.5))) im))
          double code(double re, double im) {
          	return (re * (re * (im * 0.5))) - im;
          }
          
          real(8) function code(re, im)
              real(8), intent (in) :: re
              real(8), intent (in) :: im
              code = (re * (re * (im * 0.5d0))) - im
          end function
          
          public static double code(double re, double im) {
          	return (re * (re * (im * 0.5))) - im;
          }
          
          def code(re, im):
          	return (re * (re * (im * 0.5))) - im
          
          function code(re, im)
          	return Float64(Float64(re * Float64(re * Float64(im * 0.5))) - im)
          end
          
          function tmp = code(re, im)
          	tmp = (re * (re * (im * 0.5))) - im;
          end
          
          code[re_, im_] := N[(N[(re * N[(re * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im
          \end{array}
          
          Derivation
          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.7%

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

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

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

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

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

            \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)} \]
          8. Step-by-step derivation
            1. neg-mul-134.5%

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

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

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

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

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

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

              \[\leadsto \left(re \cdot re\right) \cdot \color{blue}{\left(0.5 \cdot im\right)} - im \]
            8. associate-*l*34.5%

              \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(0.5 \cdot im\right)\right)} - im \]
            9. *-commutative34.5%

              \[\leadsto re \cdot \left(re \cdot \color{blue}{\left(im \cdot 0.5\right)}\right) - im \]
          9. Simplified34.5%

            \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im} \]
          10. Final simplification34.5%

            \[\leadsto re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im \]

          Alternative 18: 30.7% accurate, 43.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{+94}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \end{array} \end{array} \]
          (FPCore (re im)
           :precision binary64
           (if (<= im 2.6e+94) (- im) (* re (* re 0.75))))
          double code(double re, double im) {
          	double tmp;
          	if (im <= 2.6e+94) {
          		tmp = -im;
          	} else {
          		tmp = re * (re * 0.75);
          	}
          	return tmp;
          }
          
          real(8) function code(re, im)
              real(8), intent (in) :: re
              real(8), intent (in) :: im
              real(8) :: tmp
              if (im <= 2.6d+94) then
                  tmp = -im
              else
                  tmp = re * (re * 0.75d0)
              end if
              code = tmp
          end function
          
          public static double code(double re, double im) {
          	double tmp;
          	if (im <= 2.6e+94) {
          		tmp = -im;
          	} else {
          		tmp = re * (re * 0.75);
          	}
          	return tmp;
          }
          
          def code(re, im):
          	tmp = 0
          	if im <= 2.6e+94:
          		tmp = -im
          	else:
          		tmp = re * (re * 0.75)
          	return tmp
          
          function code(re, im)
          	tmp = 0.0
          	if (im <= 2.6e+94)
          		tmp = Float64(-im);
          	else
          		tmp = Float64(re * Float64(re * 0.75));
          	end
          	return tmp
          end
          
          function tmp_2 = code(re, im)
          	tmp = 0.0;
          	if (im <= 2.6e+94)
          		tmp = -im;
          	else
          		tmp = re * (re * 0.75);
          	end
          	tmp_2 = tmp;
          end
          
          code[re_, im_] := If[LessEqual[im, 2.6e+94], (-im), N[(re * N[(re * 0.75), $MachinePrecision]), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;im \leq 2.6 \cdot 10^{+94}:\\
          \;\;\;\;-im\\
          
          \mathbf{else}:\\
          \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if im < 2.5999999999999999e94

            1. Initial program 45.3%

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

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

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

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

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

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

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

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

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

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

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

            if 2.5999999999999999e94 < 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 \color{blue}{0.5 \cdot \left(e^{-im} - e^{im}\right) + -0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right)} \]
              2. *-commutative0.0%

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

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

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

                \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
              6. unpow271.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*71.4%

                \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
            6. Simplified71.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-rr27.5%

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

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

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

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

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

              \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
          3. Recombined 2 regimes into one program.
          4. Final simplification32.0%

            \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{+94}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \end{array} \]

          Alternative 19: 29.4% accurate, 154.5× speedup?

          \[\begin{array}{l} \\ -im \end{array} \]
          (FPCore (re im) :precision binary64 (- im))
          double code(double re, double im) {
          	return -im;
          }
          
          real(8) function code(re, im)
              real(8), intent (in) :: re
              real(8), intent (in) :: im
              code = -im
          end function
          
          public static double code(double re, double im) {
          	return -im;
          }
          
          def code(re, im):
          	return -im
          
          function code(re, im)
          	return Float64(-im)
          end
          
          function tmp = code(re, im)
          	tmp = -im;
          end
          
          code[re_, im_] := (-im)
          
          \begin{array}{l}
          
          \\
          -im
          \end{array}
          
          Derivation
          1. Initial program 52.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.7%

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{-im} \]
          10. Final simplification28.8%

            \[\leadsto -im \]

          Alternative 20: 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 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 re around 0 2.9%

            \[\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. +-commutative2.9%

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

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

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

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

              \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
            6. unpow238.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*38.5%

              \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
          6. Simplified38.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-rr7.3%

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

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

            \[\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 2023187 
          (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))))