math.sin on complex, imaginary part

Percentage Accurate: 54.9% → 99.8%
Time: 14.2s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 54.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -400 \lor \neg \left(t_0 \leq 0.2\right):\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(\left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 -400.0) (not (<= t_0 0.2)))
     (* (* (cos re) 0.5) t_0)
     (*
      (cos re)
      (+
       (+
        (* (pow im 7.0) -0.0001984126984126984)
        (* (pow im 5.0) -0.008333333333333333))
       (- (* (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 <= -400.0) || !(t_0 <= 0.2)) {
		tmp = (cos(re) * 0.5) * t_0;
	} else {
		tmp = cos(re) * (((pow(im, 7.0) * -0.0001984126984126984) + (pow(im, 5.0) * -0.008333333333333333)) + ((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 <= (-400.0d0)) .or. (.not. (t_0 <= 0.2d0))) then
        tmp = (cos(re) * 0.5d0) * t_0
    else
        tmp = cos(re) * ((((im ** 7.0d0) * (-0.0001984126984126984d0)) + ((im ** 5.0d0) * (-0.008333333333333333d0))) + (((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 <= -400.0) || !(t_0 <= 0.2)) {
		tmp = (Math.cos(re) * 0.5) * t_0;
	} else {
		tmp = Math.cos(re) * (((Math.pow(im, 7.0) * -0.0001984126984126984) + (Math.pow(im, 5.0) * -0.008333333333333333)) + ((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 <= -400.0) or not (t_0 <= 0.2):
		tmp = (math.cos(re) * 0.5) * t_0
	else:
		tmp = math.cos(re) * (((math.pow(im, 7.0) * -0.0001984126984126984) + (math.pow(im, 5.0) * -0.008333333333333333)) + ((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 <= -400.0) || !(t_0 <= 0.2))
		tmp = Float64(Float64(cos(re) * 0.5) * t_0);
	else
		tmp = Float64(cos(re) * Float64(Float64(Float64((im ^ 7.0) * -0.0001984126984126984) + Float64((im ^ 5.0) * -0.008333333333333333)) + 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 <= -400.0) || ~((t_0 <= 0.2)))
		tmp = (cos(re) * 0.5) * t_0;
	else
		tmp = cos(re) * ((((im ^ 7.0) * -0.0001984126984126984) + ((im ^ 5.0) * -0.008333333333333333)) + (((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, -400.0], N[Not[LessEqual[t$95$0, 0.2]], $MachinePrecision]], N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(\left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right) + \left({im}^{3} \cdot -0.16666666666666666 - 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)) < -400 or 0.20000000000000001 < (-.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 -400 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 0.20000000000000001

    1. Initial program 9.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -400 \lor \neg \left(e^{-im} - e^{im} \leq 0.2\right):\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(\left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)\\ \end{array} \]

Alternative 2: 99.8% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 8.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -400 \lor \neg \left(e^{-im} - e^{im} \leq 0.02\right):\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(im \cdot -2 + \left({im}^{5} \cdot -0.016666666666666666 + {im}^{3} \cdot -0.3333333333333333\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 -400 \lor \neg \left(t_0 \leq 0.001\right):\\ \;\;\;\;\left(\cos re \cdot 0.5\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 -400.0) (not (<= t_0 0.001)))
     (* (* (cos re) 0.5) 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 <= -400.0) || !(t_0 <= 0.001)) {
		tmp = (cos(re) * 0.5) * 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 <= (-400.0d0)) .or. (.not. (t_0 <= 0.001d0))) then
        tmp = (cos(re) * 0.5d0) * 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 <= -400.0) || !(t_0 <= 0.001)) {
		tmp = (Math.cos(re) * 0.5) * 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 <= -400.0) or not (t_0 <= 0.001):
		tmp = (math.cos(re) * 0.5) * 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 <= -400.0) || !(t_0 <= 0.001))
		tmp = Float64(Float64(cos(re) * 0.5) * 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 <= -400.0) || ~((t_0 <= 0.001)))
		tmp = (cos(re) * 0.5) * 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, -400.0], N[Not[LessEqual[t$95$0, 0.001]], $MachinePrecision]], N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $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 -400 \lor \neg \left(t_0 \leq 0.001\right):\\
\;\;\;\;\left(\cos re \cdot 0.5\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)) < -400 or 1e-3 < (-.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 -400 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1e-3

    1. Initial program 8.2%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -400 \lor \neg \left(e^{-im} - e^{im} \leq 0.001\right):\\ \;\;\;\;\left(\cos re \cdot 0.5\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: 99.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \cos re \cdot \left(\left(\log \left(e^{{im}^{3} \cdot -0.16666666666666666}\right) - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (*
  (cos re)
  (+
   (- (log (exp (* (pow im 3.0) -0.16666666666666666))) im)
   (+
    (* (pow im 7.0) -0.0001984126984126984)
    (* (pow im 5.0) -0.008333333333333333)))))
double code(double re, double im) {
	return cos(re) * ((log(exp((pow(im, 3.0) * -0.16666666666666666))) - im) + ((pow(im, 7.0) * -0.0001984126984126984) + (pow(im, 5.0) * -0.008333333333333333)));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = cos(re) * ((log(exp(((im ** 3.0d0) * (-0.16666666666666666d0)))) - im) + (((im ** 7.0d0) * (-0.0001984126984126984d0)) + ((im ** 5.0d0) * (-0.008333333333333333d0))))
end function
public static double code(double re, double im) {
	return Math.cos(re) * ((Math.log(Math.exp((Math.pow(im, 3.0) * -0.16666666666666666))) - im) + ((Math.pow(im, 7.0) * -0.0001984126984126984) + (Math.pow(im, 5.0) * -0.008333333333333333)));
}
def code(re, im):
	return math.cos(re) * ((math.log(math.exp((math.pow(im, 3.0) * -0.16666666666666666))) - im) + ((math.pow(im, 7.0) * -0.0001984126984126984) + (math.pow(im, 5.0) * -0.008333333333333333)))
function code(re, im)
	return Float64(cos(re) * Float64(Float64(log(exp(Float64((im ^ 3.0) * -0.16666666666666666))) - im) + Float64(Float64((im ^ 7.0) * -0.0001984126984126984) + Float64((im ^ 5.0) * -0.008333333333333333))))
end
function tmp = code(re, im)
	tmp = cos(re) * ((log(exp(((im ^ 3.0) * -0.16666666666666666))) - im) + (((im ^ 7.0) * -0.0001984126984126984) + ((im ^ 5.0) * -0.008333333333333333)));
end
code[re_, im_] := N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Log[N[Exp[N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - im), $MachinePrecision] + N[(N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\cos re \cdot \left(\left(\log \left(e^{{im}^{3} \cdot -0.16666666666666666}\right) - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right)
\end{array}
Derivation
  1. Initial program 51.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\left(\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left({im}^{3} \cdot -0.16666666666666666\right)\right)} - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right) \]
    2. log1p-udef98.9%

      \[\leadsto \cos re \cdot \left(\left(\color{blue}{\log \left(1 + \mathsf{expm1}\left({im}^{3} \cdot -0.16666666666666666\right)\right)} - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right) \]
  8. Applied egg-rr98.9%

    \[\leadsto \cos re \cdot \left(\left(\color{blue}{\log \left(1 + \mathsf{expm1}\left({im}^{3} \cdot -0.16666666666666666\right)\right)} - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right) \]
  9. Step-by-step derivation
    1. add-exp-log98.9%

      \[\leadsto \cos re \cdot \left(\left(\log \color{blue}{\left(e^{\log \left(1 + \mathsf{expm1}\left({im}^{3} \cdot -0.16666666666666666\right)\right)}\right)} - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right) \]
    2. log1p-def98.9%

      \[\leadsto \cos re \cdot \left(\left(\log \left(e^{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left({im}^{3} \cdot -0.16666666666666666\right)\right)}}\right) - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right) \]
    3. log1p-expm1-u99.0%

      \[\leadsto \cos re \cdot \left(\left(\log \left(e^{\color{blue}{{im}^{3} \cdot -0.16666666666666666}}\right) - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right) \]
  10. Applied egg-rr99.0%

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

    \[\leadsto \cos re \cdot \left(\left(\log \left(e^{{im}^{3} \cdot -0.16666666666666666}\right) - im\right) + \left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)\right) \]

Alternative 5: 86.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}^{3} \cdot -0.16666666666666666 - im\\ t_2 := t_1 \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \mathbf{if}\;im \leq -1 \cdot 10^{+108}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq -0.015:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.00066:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 10^{+105}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+172}:\\ \;\;\;\;t_2\\ \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 3.0) -0.16666666666666666) im))
        (t_2 (* t_1 (+ (* -0.5 (* re re)) 1.0))))
   (if (<= im -1e+108)
     t_2
     (if (<= im -0.015)
       t_0
       (if (<= im 0.00066)
         (* (cos re) (- im))
         (if (<= im 1e+105) t_0 (if (<= im 5e+172) t_2 t_1)))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double t_1 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double t_2 = t_1 * ((-0.5 * (re * re)) + 1.0);
	double tmp;
	if (im <= -1e+108) {
		tmp = t_2;
	} else if (im <= -0.015) {
		tmp = t_0;
	} else if (im <= 0.00066) {
		tmp = cos(re) * -im;
	} else if (im <= 1e+105) {
		tmp = t_0;
	} else if (im <= 5e+172) {
		tmp = t_2;
	} 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) :: t_2
    real(8) :: tmp
    t_0 = 0.5d0 * (exp(-im) - exp(im))
    t_1 = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
    t_2 = t_1 * (((-0.5d0) * (re * re)) + 1.0d0)
    if (im <= (-1d+108)) then
        tmp = t_2
    else if (im <= (-0.015d0)) then
        tmp = t_0
    else if (im <= 0.00066d0) then
        tmp = cos(re) * -im
    else if (im <= 1d+105) then
        tmp = t_0
    else if (im <= 5d+172) then
        tmp = t_2
    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, 3.0) * -0.16666666666666666) - im;
	double t_2 = t_1 * ((-0.5 * (re * re)) + 1.0);
	double tmp;
	if (im <= -1e+108) {
		tmp = t_2;
	} else if (im <= -0.015) {
		tmp = t_0;
	} else if (im <= 0.00066) {
		tmp = Math.cos(re) * -im;
	} else if (im <= 1e+105) {
		tmp = t_0;
	} else if (im <= 5e+172) {
		tmp = t_2;
	} 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, 3.0) * -0.16666666666666666) - im
	t_2 = t_1 * ((-0.5 * (re * re)) + 1.0)
	tmp = 0
	if im <= -1e+108:
		tmp = t_2
	elif im <= -0.015:
		tmp = t_0
	elif im <= 0.00066:
		tmp = math.cos(re) * -im
	elif im <= 1e+105:
		tmp = t_0
	elif im <= 5e+172:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	t_1 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	t_2 = Float64(t_1 * Float64(Float64(-0.5 * Float64(re * re)) + 1.0))
	tmp = 0.0
	if (im <= -1e+108)
		tmp = t_2;
	elseif (im <= -0.015)
		tmp = t_0;
	elseif (im <= 0.00066)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 1e+105)
		tmp = t_0;
	elseif (im <= 5e+172)
		tmp = t_2;
	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 ^ 3.0) * -0.16666666666666666) - im;
	t_2 = t_1 * ((-0.5 * (re * re)) + 1.0);
	tmp = 0.0;
	if (im <= -1e+108)
		tmp = t_2;
	elseif (im <= -0.015)
		tmp = t_0;
	elseif (im <= 0.00066)
		tmp = cos(re) * -im;
	elseif (im <= 1e+105)
		tmp = t_0;
	elseif (im <= 5e+172)
		tmp = t_2;
	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[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1e+108], t$95$2, If[LessEqual[im, -0.015], t$95$0, If[LessEqual[im, 0.00066], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1e+105], t$95$0, If[LessEqual[im, 5e+172], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;im \leq 10^{+105}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 5 \cdot 10^{+172}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -1e108 or 9.9999999999999994e104 < im < 5.0000000000000001e172

    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) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e108 < im < -0.014999999999999999 or 6.6e-4 < im < 9.9999999999999994e104

    1. Initial program 99.8%

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

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

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

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

    if -0.014999999999999999 < im < 6.6e-4

    1. Initial program 8.8%

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

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

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

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

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

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

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

    if 5.0000000000000001e172 < 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) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1 \cdot 10^{+108}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \mathbf{elif}\;im \leq -0.015:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.00066:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 10^{+105}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+172}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 6: 95.4% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;im \leq -0.0285:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.09999999999999998e44 or 5.5 < 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 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.09999999999999998e44 < im < -0.028500000000000001

    1. Initial program 99.1%

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

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

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

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

    if -0.028500000000000001 < im < 5.5

    1. Initial program 8.8%

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

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

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

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

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

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

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

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

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

Alternative 7: 95.2% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;im \leq -0.01:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.09999999999999998e44 or 4.0999999999999996 < 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 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.09999999999999998e44 < im < -0.0100000000000000002

    1. Initial program 99.1%

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

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

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

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

    if -0.0100000000000000002 < im < 4.0999999999999996

    1. Initial program 8.8%

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

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

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

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

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

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

      \[\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.1 \cdot 10^{+44}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{elif}\;im \leq -0.01:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 4.1:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \end{array} \]

Alternative 8: 81.6% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{7} \cdot -0.0001984126984126984\\ t_1 := {im}^{3} \cdot -0.16666666666666666 - im\\ t_2 := t_1 \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \mathbf{if}\;im \leq -5 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq -4.5:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 5.8:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+175}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 7.0) -0.0001984126984126984))
        (t_1 (- (* (pow im 3.0) -0.16666666666666666) im))
        (t_2 (* t_1 (+ (* -0.5 (* re re)) 1.0))))
   (if (<= im -5e+110)
     t_2
     (if (<= im -4.5)
       t_0
       (if (<= im 5.8)
         (* (cos re) (- im))
         (if (<= im 5e+102) t_0 (if (<= im 2e+175) t_2 t_1)))))))
double code(double re, double im) {
	double t_0 = pow(im, 7.0) * -0.0001984126984126984;
	double t_1 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double t_2 = t_1 * ((-0.5 * (re * re)) + 1.0);
	double tmp;
	if (im <= -5e+110) {
		tmp = t_2;
	} else if (im <= -4.5) {
		tmp = t_0;
	} else if (im <= 5.8) {
		tmp = cos(re) * -im;
	} else if (im <= 5e+102) {
		tmp = t_0;
	} else if (im <= 2e+175) {
		tmp = t_2;
	} 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) :: t_2
    real(8) :: tmp
    t_0 = (im ** 7.0d0) * (-0.0001984126984126984d0)
    t_1 = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
    t_2 = t_1 * (((-0.5d0) * (re * re)) + 1.0d0)
    if (im <= (-5d+110)) then
        tmp = t_2
    else if (im <= (-4.5d0)) then
        tmp = t_0
    else if (im <= 5.8d0) then
        tmp = cos(re) * -im
    else if (im <= 5d+102) then
        tmp = t_0
    else if (im <= 2d+175) then
        tmp = t_2
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 7.0) * -0.0001984126984126984;
	double t_1 = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
	double t_2 = t_1 * ((-0.5 * (re * re)) + 1.0);
	double tmp;
	if (im <= -5e+110) {
		tmp = t_2;
	} else if (im <= -4.5) {
		tmp = t_0;
	} else if (im <= 5.8) {
		tmp = Math.cos(re) * -im;
	} else if (im <= 5e+102) {
		tmp = t_0;
	} else if (im <= 2e+175) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 7.0) * -0.0001984126984126984
	t_1 = (math.pow(im, 3.0) * -0.16666666666666666) - im
	t_2 = t_1 * ((-0.5 * (re * re)) + 1.0)
	tmp = 0
	if im <= -5e+110:
		tmp = t_2
	elif im <= -4.5:
		tmp = t_0
	elif im <= 5.8:
		tmp = math.cos(re) * -im
	elif im <= 5e+102:
		tmp = t_0
	elif im <= 2e+175:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 7.0) * -0.0001984126984126984)
	t_1 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	t_2 = Float64(t_1 * Float64(Float64(-0.5 * Float64(re * re)) + 1.0))
	tmp = 0.0
	if (im <= -5e+110)
		tmp = t_2;
	elseif (im <= -4.5)
		tmp = t_0;
	elseif (im <= 5.8)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 5e+102)
		tmp = t_0;
	elseif (im <= 2e+175)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 7.0) * -0.0001984126984126984;
	t_1 = ((im ^ 3.0) * -0.16666666666666666) - im;
	t_2 = t_1 * ((-0.5 * (re * re)) + 1.0);
	tmp = 0.0;
	if (im <= -5e+110)
		tmp = t_2;
	elseif (im <= -4.5)
		tmp = t_0;
	elseif (im <= 5.8)
		tmp = cos(re) * -im;
	elseif (im <= 5e+102)
		tmp = t_0;
	elseif (im <= 2e+175)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5e+110], t$95$2, If[LessEqual[im, -4.5], t$95$0, If[LessEqual[im, 5.8], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 5e+102], t$95$0, If[LessEqual[im, 2e+175], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;im \leq 5 \cdot 10^{+102}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 2 \cdot 10^{+175}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -4.99999999999999978e110 or 5e102 < im < 1.9999999999999999e175

    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) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.99999999999999978e110 < im < -4.5 or 5.79999999999999982 < im < 5e102

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {im}^{7} \cdot \color{blue}{-0.0001984126984126984} \]

    if -4.5 < im < 5.79999999999999982

    1. Initial program 10.1%

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

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

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

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

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

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

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

    if 1.9999999999999999e175 < 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) + -1 \cdot \left(\cos re \cdot im\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5 \cdot 10^{+110}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \mathbf{elif}\;im \leq -4.5:\\ \;\;\;\;{im}^{7} \cdot -0.0001984126984126984\\ \mathbf{elif}\;im \leq 5.8:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+102}:\\ \;\;\;\;{im}^{7} \cdot -0.0001984126984126984\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+175}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 9: 81.1% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -7.2 \lor \neg \left(im \leq 5.5\right):\\
\;\;\;\;{im}^{7} \cdot -0.0001984126984126984\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {im}^{7} \cdot \color{blue}{-0.0001984126984126984} \]

    if -7.20000000000000018 < im < 5.5

    1. Initial program 10.1%

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

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

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

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

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

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

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

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

Alternative 10: 57.5% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -1.75 \cdot 10^{+43}:\\ \;\;\;\;\left(re \cdot im\right) \cdot \left(re \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 660:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -1.75e+43)
   (- (* (* re im) (* re 0.5)) im)
   (if (<= im 660.0) (* (cos re) (- im)) (+ 13.5 (* (* re re) -6.75)))))
double code(double re, double im) {
	double tmp;
	if (im <= -1.75e+43) {
		tmp = ((re * im) * (re * 0.5)) - im;
	} else if (im <= 660.0) {
		tmp = cos(re) * -im;
	} else {
		tmp = 13.5 + ((re * re) * -6.75);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= (-1.75d+43)) then
        tmp = ((re * im) * (re * 0.5d0)) - im
    else if (im <= 660.0d0) then
        tmp = cos(re) * -im
    else
        tmp = 13.5d0 + ((re * re) * (-6.75d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -1.75e+43) {
		tmp = ((re * im) * (re * 0.5)) - im;
	} else if (im <= 660.0) {
		tmp = Math.cos(re) * -im;
	} else {
		tmp = 13.5 + ((re * re) * -6.75);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -1.75e+43:
		tmp = ((re * im) * (re * 0.5)) - im
	elif im <= 660.0:
		tmp = math.cos(re) * -im
	else:
		tmp = 13.5 + ((re * re) * -6.75)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -1.75e+43)
		tmp = Float64(Float64(Float64(re * im) * Float64(re * 0.5)) - im);
	elseif (im <= 660.0)
		tmp = Float64(cos(re) * Float64(-im));
	else
		tmp = Float64(13.5 + Float64(Float64(re * re) * -6.75));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -1.75e+43)
		tmp = ((re * im) * (re * 0.5)) - im;
	elseif (im <= 660.0)
		tmp = cos(re) * -im;
	else
		tmp = 13.5 + ((re * re) * -6.75);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -1.75e+43], N[(N[(N[(re * im), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 660.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(13.5 + N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

\mathbf{else}:\\
\;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\


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

    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.4%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im} \]
    10. Taylor expanded in re around 0 27.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(re \cdot \left(im \cdot 0.5\right)\right) \cdot re} - im \]
      6. associate-*r*27.7%

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

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

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

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

    if -1.7500000000000001e43 < im < 660

    1. Initial program 14.4%

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

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

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

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

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

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

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

    if 660 < 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. Applied egg-rr0.6%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{27} \]
    5. Taylor expanded in re around 0 16.6%

      \[\leadsto \color{blue}{13.5 + -6.75 \cdot {re}^{2}} \]
    6. Step-by-step derivation
      1. *-commutative16.6%

        \[\leadsto 13.5 + \color{blue}{{re}^{2} \cdot -6.75} \]
      2. unpow216.6%

        \[\leadsto 13.5 + \color{blue}{\left(re \cdot re\right)} \cdot -6.75 \]
    7. Simplified16.6%

      \[\leadsto \color{blue}{13.5 + \left(re \cdot re\right) \cdot -6.75} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification62.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.75 \cdot 10^{+43}:\\ \;\;\;\;\left(re \cdot im\right) \cdot \left(re \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 660:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\ \end{array} \]

Alternative 11: 34.0% accurate, 27.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -8.6 \cdot 10^{+42} \lor \neg \left(im \leq 680\right):\\ \;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -8.6e+42) (not (<= im 680.0)))
   (+ 13.5 (* (* re re) -6.75))
   (- im)))
double code(double re, double im) {
	double tmp;
	if ((im <= -8.6e+42) || !(im <= 680.0)) {
		tmp = 13.5 + ((re * re) * -6.75);
	} else {
		tmp = -im;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-8.6d+42)) .or. (.not. (im <= 680.0d0))) then
        tmp = 13.5d0 + ((re * re) * (-6.75d0))
    else
        tmp = -im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -8.6e+42) || !(im <= 680.0)) {
		tmp = 13.5 + ((re * re) * -6.75);
	} else {
		tmp = -im;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -8.6e+42) or not (im <= 680.0):
		tmp = 13.5 + ((re * re) * -6.75)
	else:
		tmp = -im
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -8.6e+42) || !(im <= 680.0))
		tmp = Float64(13.5 + Float64(Float64(re * re) * -6.75));
	else
		tmp = Float64(-im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -8.6e+42) || ~((im <= 680.0)))
		tmp = 13.5 + ((re * re) * -6.75);
	else
		tmp = -im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -8.6e+42], N[Not[LessEqual[im, 680.0]], $MachinePrecision]], N[(13.5 + N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]), $MachinePrecision], (-im)]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -8.6 \cdot 10^{+42} \lor \neg \left(im \leq 680\right):\\
\;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -8.5999999999999996e42 or 680 < 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. Applied egg-rr1.8%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{27} \]
    5. Taylor expanded in re around 0 16.3%

      \[\leadsto \color{blue}{13.5 + -6.75 \cdot {re}^{2}} \]
    6. Step-by-step derivation
      1. *-commutative16.3%

        \[\leadsto 13.5 + \color{blue}{{re}^{2} \cdot -6.75} \]
      2. unpow216.3%

        \[\leadsto 13.5 + \color{blue}{\left(re \cdot re\right)} \cdot -6.75 \]
    7. Simplified16.3%

      \[\leadsto \color{blue}{13.5 + \left(re \cdot re\right) \cdot -6.75} \]

    if -8.5999999999999996e42 < im < 680

    1. Initial program 14.4%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-im} \]
    9. Simplified54.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -8.6 \cdot 10^{+42} \lor \neg \left(im \leq 680\right):\\ \;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]

Alternative 12: 36.4% accurate, 27.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 1.4999999999999999e191

    1. Initial program 51.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im} \]
    10. Taylor expanded in re around 0 40.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(re \cdot \left(im \cdot 0.5\right)\right) \cdot re} - im \]
      6. associate-*r*40.9%

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

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

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

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

    if 1.4999999999999999e191 < re

    1. Initial program 52.4%

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

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

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

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{27} \]
    5. Taylor expanded in re around 0 28.0%

      \[\leadsto \color{blue}{13.5 + -6.75 \cdot {re}^{2}} \]
    6. Step-by-step derivation
      1. *-commutative28.0%

        \[\leadsto 13.5 + \color{blue}{{re}^{2} \cdot -6.75} \]
      2. unpow228.0%

        \[\leadsto 13.5 + \color{blue}{\left(re \cdot re\right)} \cdot -6.75 \]
    7. Simplified28.0%

      \[\leadsto \color{blue}{13.5 + \left(re \cdot re\right) \cdot -6.75} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification39.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.5 \cdot 10^{+191}:\\ \;\;\;\;\left(re \cdot im\right) \cdot \left(re \cdot 0.5\right) - im\\ \mathbf{else}:\\ \;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\ \end{array} \]

Alternative 13: 29.3% 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 51.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-im} \]
  9. Simplified33.1%

    \[\leadsto \color{blue}{-im} \]
  10. Final simplification33.1%

    \[\leadsto -im \]

Alternative 14: 2.8% accurate, 309.0× speedup?

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

\\
13.5
\end{array}
Derivation
  1. Initial program 51.2%

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

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

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

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{27} \]
  5. Taylor expanded in re around 0 3.0%

    \[\leadsto \color{blue}{13.5} \]
  6. Final simplification3.0%

    \[\leadsto 13.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 2023182 
(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))))