math.sin on complex, imaginary part

Percentage Accurate: 54.6% → 99.8%
Time: 10.7s
Alternatives: 11
Speedup: 2.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 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.6% 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.8% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(im \cdot -2 + \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -10 or 4.00000000000000019e-4 < (-.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. neg-sub0100.0%

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

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

    if -10 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 4.00000000000000019e-4

    1. Initial program 9.9%

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

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

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

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

Alternative 2: 99.9% 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 0.0004\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\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 0.0004)))
     (* (* 0.5 (cos re)) t_0)
     (- (* -0.16666666666666666 (* (cos re) (pow im 3.0))) (* 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 <= 0.0004)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = (-0.16666666666666666 * (cos(re) * pow(im, 3.0))) - (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 <= 0.0004d0))) then
        tmp = (0.5d0 * cos(re)) * t_0
    else
        tmp = ((-0.16666666666666666d0) * (cos(re) * (im ** 3.0d0))) - (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 <= 0.0004)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = (-0.16666666666666666 * (Math.cos(re) * Math.pow(im, 3.0))) - (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 <= 0.0004):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = (-0.16666666666666666 * (math.cos(re) * math.pow(im, 3.0))) - (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 <= 0.0004))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(Float64(-0.16666666666666666 * Float64(cos(re) * (im ^ 3.0))) - 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 <= 0.0004)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = (-0.16666666666666666 * (cos(re) * (im ^ 3.0))) - (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, 0.0004]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(-0.16666666666666666 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 3.0], $MachinePrecision]), $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 0.0004\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(\cos re \cdot {im}^{3}\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 4.00000000000000019e-4 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 99.9%

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

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

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

    if -0.0050000000000000001 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 4.00000000000000019e-4

    1. Initial program 9.1%

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

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

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

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

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

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


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

    1. Initial program 99.9%

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

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

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

    if -0.0050000000000000001 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 4.00000000000000019e-4

    1. Initial program 9.1%

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

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

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

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

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

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

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

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

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

Alternative 4: 96.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := {im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \mathbf{if}\;im \leq -4.4 \cdot 10^{+74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.072:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.14:\\ \;\;\;\;\frac{0.5 \cdot \cos re}{im \cdot 0.08333333333333333 + 0.5 \cdot \frac{-1}{im}}\\ \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 (* (pow im 5.0) (* (cos re) -0.008333333333333333))))
   (if (<= im -4.4e+74)
     t_1
     (if (<= im -0.072)
       t_0
       (if (<= im 0.14)
         (/
          (* 0.5 (cos re))
          (+ (* im 0.08333333333333333) (* 0.5 (/ -1.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 = pow(im, 5.0) * (cos(re) * -0.008333333333333333);
	double tmp;
	if (im <= -4.4e+74) {
		tmp = t_1;
	} else if (im <= -0.072) {
		tmp = t_0;
	} else if (im <= 0.14) {
		tmp = (0.5 * cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.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 = (im ** 5.0d0) * (cos(re) * (-0.008333333333333333d0))
    if (im <= (-4.4d+74)) then
        tmp = t_1
    else if (im <= (-0.072d0)) then
        tmp = t_0
    else if (im <= 0.14d0) then
        tmp = (0.5d0 * cos(re)) / ((im * 0.08333333333333333d0) + (0.5d0 * ((-1.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 = Math.pow(im, 5.0) * (Math.cos(re) * -0.008333333333333333);
	double tmp;
	if (im <= -4.4e+74) {
		tmp = t_1;
	} else if (im <= -0.072) {
		tmp = t_0;
	} else if (im <= 0.14) {
		tmp = (0.5 * Math.cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.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 = math.pow(im, 5.0) * (math.cos(re) * -0.008333333333333333)
	tmp = 0
	if im <= -4.4e+74:
		tmp = t_1
	elif im <= -0.072:
		tmp = t_0
	elif im <= 0.14:
		tmp = (0.5 * math.cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.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((im ^ 5.0) * Float64(cos(re) * -0.008333333333333333))
	tmp = 0.0
	if (im <= -4.4e+74)
		tmp = t_1;
	elseif (im <= -0.072)
		tmp = t_0;
	elseif (im <= 0.14)
		tmp = Float64(Float64(0.5 * cos(re)) / Float64(Float64(im * 0.08333333333333333) + Float64(0.5 * Float64(-1.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 = (im ^ 5.0) * (cos(re) * -0.008333333333333333);
	tmp = 0.0;
	if (im <= -4.4e+74)
		tmp = t_1;
	elseif (im <= -0.072)
		tmp = t_0;
	elseif (im <= 0.14)
		tmp = (0.5 * cos(re)) / ((im * 0.08333333333333333) + (0.5 * (-1.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[(N[Power[im, 5.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.4e+74], t$95$1, If[LessEqual[im, -0.072], t$95$0, If[LessEqual[im, 0.14], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] / N[(N[(im * 0.08333333333333333), $MachinePrecision] + N[(0.5 * N[(-1.0 / im), $MachinePrecision]), $MachinePrecision]), $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 := {im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\
\mathbf{if}\;im \leq -4.4 \cdot 10^{+74}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 0.14:\\
\;\;\;\;\frac{0.5 \cdot \cos re}{im \cdot 0.08333333333333333 + 0.5 \cdot \frac{-1}{im}}\\

\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 < -4.4000000000000002e74 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. neg-sub0100.0%

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

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

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

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

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

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

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

    if -4.4000000000000002e74 < im < -0.0719999999999999946 or 0.14000000000000001 < 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. neg-sub0100.0%

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

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

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

    if -0.0719999999999999946 < im < 0.14000000000000001

    1. Initial program 9.9%

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

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

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)\right)} \]
    5. Step-by-step derivation
      1. flip-+60.7%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\frac{\left(-2 \cdot im\right) \cdot \left(-2 \cdot im\right) - \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right) \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)}{-2 \cdot im - \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)}} \]
      2. associate-*r/60.5%

        \[\leadsto \color{blue}{\frac{\left(0.5 \cdot \cos re\right) \cdot \left(\left(-2 \cdot im\right) \cdot \left(-2 \cdot im\right) - \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right) \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)\right)}{-2 \cdot im - \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)}} \]
    6. Applied egg-rr60.5%

      \[\leadsto \color{blue}{\frac{\left(0.5 \cdot \cos re\right) \cdot \left({im}^{2} \cdot 4 - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}\right)}{im \cdot -2 - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}} \]
    7. Step-by-step derivation
      1. associate-/l*60.4%

        \[\leadsto \color{blue}{\frac{0.5 \cdot \cos re}{\frac{im \cdot -2 - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}{{im}^{2} \cdot 4 - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}}}} \]
      2. *-commutative60.4%

        \[\leadsto \frac{0.5 \cdot \cos re}{\frac{\color{blue}{-2 \cdot im} - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}{{im}^{2} \cdot 4 - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}}} \]
      3. *-commutative60.4%

        \[\leadsto \frac{0.5 \cdot \cos re}{\frac{-2 \cdot im - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}{\color{blue}{4 \cdot {im}^{2}} - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}}} \]
    8. Simplified60.4%

      \[\leadsto \color{blue}{\frac{0.5 \cdot \cos re}{\frac{-2 \cdot im - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}{4 \cdot {im}^{2} - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}}}} \]
    9. Taylor expanded in im around 0 99.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.4 \cdot 10^{+74}:\\ \;\;\;\;{im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \mathbf{elif}\;im \leq -0.072:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.14:\\ \;\;\;\;\frac{0.5 \cdot \cos re}{im \cdot 0.08333333333333333 + 0.5 \cdot \frac{-1}{im}}\\ \mathbf{elif}\;im \leq 4.5 \cdot 10^{+61}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \end{array} \]

Alternative 5: 97.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := {im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \mathbf{if}\;im \leq -4.4 \cdot 10^{+74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.122:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 2.6:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - 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 (* (pow im 5.0) (* (cos re) -0.008333333333333333))))
   (if (<= im -4.4e+74)
     t_1
     (if (<= im -0.122)
       t_0
       (if (<= im 2.6)
         (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) 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 = pow(im, 5.0) * (cos(re) * -0.008333333333333333);
	double tmp;
	if (im <= -4.4e+74) {
		tmp = t_1;
	} else if (im <= -0.122) {
		tmp = t_0;
	} else if (im <= 2.6) {
		tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - 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 = (im ** 5.0d0) * (cos(re) * (-0.008333333333333333d0))
    if (im <= (-4.4d+74)) then
        tmp = t_1
    else if (im <= (-0.122d0)) then
        tmp = t_0
    else if (im <= 2.6d0) then
        tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - 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 = Math.pow(im, 5.0) * (Math.cos(re) * -0.008333333333333333);
	double tmp;
	if (im <= -4.4e+74) {
		tmp = t_1;
	} else if (im <= -0.122) {
		tmp = t_0;
	} else if (im <= 2.6) {
		tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - 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 = math.pow(im, 5.0) * (math.cos(re) * -0.008333333333333333)
	tmp = 0
	if im <= -4.4e+74:
		tmp = t_1
	elif im <= -0.122:
		tmp = t_0
	elif im <= 2.6:
		tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - 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((im ^ 5.0) * Float64(cos(re) * -0.008333333333333333))
	tmp = 0.0
	if (im <= -4.4e+74)
		tmp = t_1;
	elseif (im <= -0.122)
		tmp = t_0;
	elseif (im <= 2.6)
		tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - 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 = (im ^ 5.0) * (cos(re) * -0.008333333333333333);
	tmp = 0.0;
	if (im <= -4.4e+74)
		tmp = t_1;
	elseif (im <= -0.122)
		tmp = t_0;
	elseif (im <= 2.6)
		tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - 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[(N[Power[im, 5.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.4e+74], t$95$1, If[LessEqual[im, -0.122], t$95$0, If[LessEqual[im, 2.6], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $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 := {im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\
\mathbf{if}\;im \leq -4.4 \cdot 10^{+74}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 2.6:\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - 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 < -4.4000000000000002e74 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. neg-sub0100.0%

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

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

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

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

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

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

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

    if -4.4000000000000002e74 < im < -0.122 or 2.60000000000000009 < 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. neg-sub0100.0%

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

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

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

    if -0.122 < im < 2.60000000000000009

    1. Initial program 10.6%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 86.7% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.19 \lor \neg \left(im \leq 0.0295\right):\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{0.5 \cdot \cos re}{im \cdot 0.08333333333333333 + 0.5 \cdot \frac{-1}{im}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -0.19 or 0.029499999999999998 < 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. neg-sub0100.0%

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

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

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

    if -0.19 < im < 0.029499999999999998

    1. Initial program 9.9%

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

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

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)\right)} \]
    5. Step-by-step derivation
      1. flip-+60.7%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\frac{\left(-2 \cdot im\right) \cdot \left(-2 \cdot im\right) - \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right) \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)}{-2 \cdot im - \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)}} \]
      2. associate-*r/60.5%

        \[\leadsto \color{blue}{\frac{\left(0.5 \cdot \cos re\right) \cdot \left(\left(-2 \cdot im\right) \cdot \left(-2 \cdot im\right) - \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right) \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)\right)}{-2 \cdot im - \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)}} \]
    6. Applied egg-rr60.5%

      \[\leadsto \color{blue}{\frac{\left(0.5 \cdot \cos re\right) \cdot \left({im}^{2} \cdot 4 - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}\right)}{im \cdot -2 - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}} \]
    7. Step-by-step derivation
      1. associate-/l*60.4%

        \[\leadsto \color{blue}{\frac{0.5 \cdot \cos re}{\frac{im \cdot -2 - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}{{im}^{2} \cdot 4 - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}}}} \]
      2. *-commutative60.4%

        \[\leadsto \frac{0.5 \cdot \cos re}{\frac{\color{blue}{-2 \cdot im} - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}{{im}^{2} \cdot 4 - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}}} \]
      3. *-commutative60.4%

        \[\leadsto \frac{0.5 \cdot \cos re}{\frac{-2 \cdot im - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}{\color{blue}{4 \cdot {im}^{2}} - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}}} \]
    8. Simplified60.4%

      \[\leadsto \color{blue}{\frac{0.5 \cdot \cos re}{\frac{-2 \cdot im - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}{4 \cdot {im}^{2} - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}}}} \]
    9. Taylor expanded in im around 0 99.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -0.19 \lor \neg \left(im \leq 0.0295\right):\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 \cdot \cos re}{im \cdot 0.08333333333333333 + 0.5 \cdot \frac{-1}{im}}\\ \end{array} \]

Alternative 7: 76.3% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{if}\;im \leq -2.4:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 2.6:\\
\;\;\;\;\frac{0.5 \cdot \cos re}{im \cdot 0.08333333333333333 + 0.5 \cdot \frac{-1}{im}}\\

\mathbf{elif}\;im \leq 7 \cdot 10^{+96}:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{2}\right) - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.39999999999999991 or 6.9999999999999998e96 < 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. neg-sub0100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} - im \]
    9. Simplified64.0%

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

    if -2.39999999999999991 < im < 2.60000000000000009

    1. Initial program 10.6%

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

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

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

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)\right)} \]
    5. Step-by-step derivation
      1. flip-+60.4%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\frac{\left(-2 \cdot im\right) \cdot \left(-2 \cdot im\right) - \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right) \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)}{-2 \cdot im - \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)}} \]
      2. associate-*r/60.2%

        \[\leadsto \color{blue}{\frac{\left(0.5 \cdot \cos re\right) \cdot \left(\left(-2 \cdot im\right) \cdot \left(-2 \cdot im\right) - \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right) \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)\right)}{-2 \cdot im - \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)}} \]
    6. Applied egg-rr60.2%

      \[\leadsto \color{blue}{\frac{\left(0.5 \cdot \cos re\right) \cdot \left({im}^{2} \cdot 4 - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}\right)}{im \cdot -2 - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}} \]
    7. Step-by-step derivation
      1. associate-/l*60.1%

        \[\leadsto \color{blue}{\frac{0.5 \cdot \cos re}{\frac{im \cdot -2 - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}{{im}^{2} \cdot 4 - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}}}} \]
      2. *-commutative60.1%

        \[\leadsto \frac{0.5 \cdot \cos re}{\frac{\color{blue}{-2 \cdot im} - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}{{im}^{2} \cdot 4 - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}}} \]
      3. *-commutative60.1%

        \[\leadsto \frac{0.5 \cdot \cos re}{\frac{-2 \cdot im - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}{\color{blue}{4 \cdot {im}^{2}} - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}}} \]
    8. Simplified60.1%

      \[\leadsto \color{blue}{\frac{0.5 \cdot \cos re}{\frac{-2 \cdot im - \mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)}{4 \cdot {im}^{2} - {\left(\mathsf{fma}\left(-0.3333333333333333, {im}^{3}, -0.016666666666666666 \cdot {im}^{5}\right)\right)}^{2}}}} \]
    9. Taylor expanded in im around 0 98.4%

      \[\leadsto \frac{0.5 \cdot \cos re}{\color{blue}{0.08333333333333333 \cdot im - 0.5 \cdot \frac{1}{im}}} \]

    if 2.60000000000000009 < im < 6.9999999999999998e96

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

Alternative 8: 76.1% accurate, 2.7× speedup?

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

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

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

\mathbf{elif}\;im \leq 3.7 \cdot 10^{+96}:\\
\;\;\;\;0.5 \cdot \left(im \cdot {re}^{2}\right) - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.24999999999999999e55 or 3.69999999999999991e96 < 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. neg-sub0100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} - im \]
    9. Simplified71.2%

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

    if -2.24999999999999999e55 < im < 460

    1. Initial program 19.1%

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

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

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

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

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

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

    if 460 < im < 3.69999999999999991e96

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.25 \cdot 10^{+55}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 460:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 3.7 \cdot 10^{+96}:\\ \;\;\;\;0.5 \cdot \left(im \cdot {re}^{2}\right) - im\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 9: 75.2% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.4 \cdot 10^{+50} \lor \neg \left(im \leq 4.2 \cdot 10^{+65}\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -6.39999999999999966e50 or 4.19999999999999983e65 < 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. neg-sub0100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} - im \]
    9. Simplified66.9%

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

    if -6.39999999999999966e50 < im < 4.19999999999999983e65

    1. Initial program 30.6%

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

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

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

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

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

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

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

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

Alternative 10: 51.8% accurate, 3.0× speedup?

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

\\
\cos re \cdot \left(-im\right)
\end{array}
Derivation
  1. Initial program 59.9%

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

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

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

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

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

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

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

Alternative 11: 29.9% 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 59.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto -im \]

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