math.cos on complex, imaginary part

Percentage Accurate: 65.4% → 99.7%
Time: 9.0s
Alternatives: 13
Speedup: 2.7×

Specification

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

\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-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 13 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: 65.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.6× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := e^{-im_m} - e^{im_m}\\ im_s \cdot \begin{array}{l} \mathbf{if}\;t_0 \leq -1:\\ \;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im_m}^{3} \cdot -0.16666666666666666 - im_m\right)\\ \end{array} \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (- (exp (- im_m)) (exp im_m))))
   (*
    im_s
    (if (<= t_0 -1.0)
      (* t_0 (* 0.5 (sin re)))
      (* (sin re) (- (* (pow im_m 3.0) -0.16666666666666666) im_m))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = exp(-im_m) - exp(im_m);
	double tmp;
	if (t_0 <= -1.0) {
		tmp = t_0 * (0.5 * sin(re));
	} else {
		tmp = sin(re) * ((pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-im_m) - exp(im_m)
    if (t_0 <= (-1.0d0)) then
        tmp = t_0 * (0.5d0 * sin(re))
    else
        tmp = sin(re) * (((im_m ** 3.0d0) * (-0.16666666666666666d0)) - im_m)
    end if
    code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = Math.exp(-im_m) - Math.exp(im_m);
	double tmp;
	if (t_0 <= -1.0) {
		tmp = t_0 * (0.5 * Math.sin(re));
	} else {
		tmp = Math.sin(re) * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = math.exp(-im_m) - math.exp(im_m)
	tmp = 0
	if t_0 <= -1.0:
		tmp = t_0 * (0.5 * math.sin(re))
	else:
		tmp = math.sin(re) * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m)
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(exp(Float64(-im_m)) - exp(im_m))
	tmp = 0.0
	if (t_0 <= -1.0)
		tmp = Float64(t_0 * Float64(0.5 * sin(re)));
	else
		tmp = Float64(sin(re) * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - im_m));
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	t_0 = exp(-im_m) - exp(im_m);
	tmp = 0.0;
	if (t_0 <= -1.0)
		tmp = t_0 * (0.5 * sin(re));
	else
		tmp = sin(re) * (((im_m ^ 3.0) * -0.16666666666666666) - im_m);
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[t$95$0, -1.0], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := e^{-im_m} - e^{im_m}\\
im_s \cdot \begin{array}{l}
\mathbf{if}\;t_0 \leq -1:\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -1

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]

    if -1 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 54.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 91.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -1:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 2: 93.1% accurate, 1.0× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := \left(e^{-im_m} - e^{im_m}\right) \cdot \left(0.5 \cdot re\right)\\ t_1 := {im_m}^{3} \cdot -0.16666666666666666\\ im_s \cdot \begin{array}{l} \mathbf{if}\;im_m \leq 0.26:\\ \;\;\;\;\sin re \cdot \left(t_1 - im_m\right)\\ \mathbf{elif}\;im_m \leq 1.45 \cdot 10^{+55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im_m \leq 10^{+84}:\\ \;\;\;\;0.16666666666666666 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(im_m \cdot {re}^{3}\right)\right)\\ \mathbf{elif}\;im_m \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot t_1\\ \end{array} \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* (- (exp (- im_m)) (exp im_m)) (* 0.5 re)))
        (t_1 (* (pow im_m 3.0) -0.16666666666666666)))
   (*
    im_s
    (if (<= im_m 0.26)
      (* (sin re) (- t_1 im_m))
      (if (<= im_m 1.45e+55)
        t_0
        (if (<= im_m 1e+84)
          (* 0.16666666666666666 (log1p (expm1 (* im_m (pow re 3.0)))))
          (if (<= im_m 5.8e+102) t_0 (* (sin re) t_1))))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = (exp(-im_m) - exp(im_m)) * (0.5 * re);
	double t_1 = pow(im_m, 3.0) * -0.16666666666666666;
	double tmp;
	if (im_m <= 0.26) {
		tmp = sin(re) * (t_1 - im_m);
	} else if (im_m <= 1.45e+55) {
		tmp = t_0;
	} else if (im_m <= 1e+84) {
		tmp = 0.16666666666666666 * log1p(expm1((im_m * pow(re, 3.0))));
	} else if (im_m <= 5.8e+102) {
		tmp = t_0;
	} else {
		tmp = sin(re) * t_1;
	}
	return im_s * tmp;
}
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = (Math.exp(-im_m) - Math.exp(im_m)) * (0.5 * re);
	double t_1 = Math.pow(im_m, 3.0) * -0.16666666666666666;
	double tmp;
	if (im_m <= 0.26) {
		tmp = Math.sin(re) * (t_1 - im_m);
	} else if (im_m <= 1.45e+55) {
		tmp = t_0;
	} else if (im_m <= 1e+84) {
		tmp = 0.16666666666666666 * Math.log1p(Math.expm1((im_m * Math.pow(re, 3.0))));
	} else if (im_m <= 5.8e+102) {
		tmp = t_0;
	} else {
		tmp = Math.sin(re) * t_1;
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = (math.exp(-im_m) - math.exp(im_m)) * (0.5 * re)
	t_1 = math.pow(im_m, 3.0) * -0.16666666666666666
	tmp = 0
	if im_m <= 0.26:
		tmp = math.sin(re) * (t_1 - im_m)
	elif im_m <= 1.45e+55:
		tmp = t_0
	elif im_m <= 1e+84:
		tmp = 0.16666666666666666 * math.log1p(math.expm1((im_m * math.pow(re, 3.0))))
	elif im_m <= 5.8e+102:
		tmp = t_0
	else:
		tmp = math.sin(re) * t_1
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(Float64(exp(Float64(-im_m)) - exp(im_m)) * Float64(0.5 * re))
	t_1 = Float64((im_m ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im_m <= 0.26)
		tmp = Float64(sin(re) * Float64(t_1 - im_m));
	elseif (im_m <= 1.45e+55)
		tmp = t_0;
	elseif (im_m <= 1e+84)
		tmp = Float64(0.16666666666666666 * log1p(expm1(Float64(im_m * (re ^ 3.0)))));
	elseif (im_m <= 5.8e+102)
		tmp = t_0;
	else
		tmp = Float64(sin(re) * t_1);
	end
	return Float64(im_s * tmp)
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 0.26], N[(N[Sin[re], $MachinePrecision] * N[(t$95$1 - im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 1.45e+55], t$95$0, If[LessEqual[im$95$m, 1e+84], N[(0.16666666666666666 * N[Log[1 + N[(Exp[N[(im$95$m * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 5.8e+102], t$95$0, N[(N[Sin[re], $MachinePrecision] * t$95$1), $MachinePrecision]]]]]), $MachinePrecision]]]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := \left(e^{-im_m} - e^{im_m}\right) \cdot \left(0.5 \cdot re\right)\\
t_1 := {im_m}^{3} \cdot -0.16666666666666666\\
im_s \cdot \begin{array}{l}
\mathbf{if}\;im_m \leq 0.26:\\
\;\;\;\;\sin re \cdot \left(t_1 - im_m\right)\\

\mathbf{elif}\;im_m \leq 1.45 \cdot 10^{+55}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im_m \leq 10^{+84}:\\
\;\;\;\;0.16666666666666666 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(im_m \cdot {re}^{3}\right)\right)\\

\mathbf{elif}\;im_m \leq 5.8 \cdot 10^{+102}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\sin re \cdot t_1\\


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

    1. Initial program 54.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 91.1%

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

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

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

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

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

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

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

    if 0.26000000000000001 < im < 1.4499999999999999e55 or 1.00000000000000006e84 < im < 5.8000000000000005e102

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 100.0%

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

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

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

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

    if 1.4499999999999999e55 < im < 1.00000000000000006e84

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 3.6%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0 50.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)} \]
    9. Step-by-step derivation
      1. log1p-expm1-u100.0%

        \[\leadsto 0.16666666666666666 \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot {re}^{3}\right)\right)} \]
    10. Applied egg-rr100.0%

      \[\leadsto 0.16666666666666666 \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot {re}^{3}\right)\right)} \]

    if 5.8000000000000005e102 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.26:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.45 \cdot 10^{+55}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 10^{+84}:\\ \;\;\;\;0.16666666666666666 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot {re}^{3}\right)\right)\\ \mathbf{elif}\;im \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \]

Alternative 3: 94.4% accurate, 1.4× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := \left(e^{-im_m} - e^{im_m}\right) \cdot \left(0.5 \cdot re\right)\\ t_1 := {im_m}^{3} \cdot -0.16666666666666666\\ t_2 := t_1 - im_m\\ im_s \cdot \begin{array}{l} \mathbf{if}\;im_m \leq 0.115:\\ \;\;\;\;\sin re \cdot t_2\\ \mathbf{elif}\;im_m \leq 1.8 \cdot 10^{+55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im_m \leq 7.5 \cdot 10^{+67}:\\ \;\;\;\;t_2 \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\ \mathbf{elif}\;im_m \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot t_1\\ \end{array} \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* (- (exp (- im_m)) (exp im_m)) (* 0.5 re)))
        (t_1 (* (pow im_m 3.0) -0.16666666666666666))
        (t_2 (- t_1 im_m)))
   (*
    im_s
    (if (<= im_m 0.115)
      (* (sin re) t_2)
      (if (<= im_m 1.8e+55)
        t_0
        (if (<= im_m 7.5e+67)
          (* t_2 (+ re (* -0.16666666666666666 (pow re 3.0))))
          (if (<= im_m 5.8e+102) t_0 (* (sin re) t_1))))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = (exp(-im_m) - exp(im_m)) * (0.5 * re);
	double t_1 = pow(im_m, 3.0) * -0.16666666666666666;
	double t_2 = t_1 - im_m;
	double tmp;
	if (im_m <= 0.115) {
		tmp = sin(re) * t_2;
	} else if (im_m <= 1.8e+55) {
		tmp = t_0;
	} else if (im_m <= 7.5e+67) {
		tmp = t_2 * (re + (-0.16666666666666666 * pow(re, 3.0)));
	} else if (im_m <= 5.8e+102) {
		tmp = t_0;
	} else {
		tmp = sin(re) * t_1;
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = (exp(-im_m) - exp(im_m)) * (0.5d0 * re)
    t_1 = (im_m ** 3.0d0) * (-0.16666666666666666d0)
    t_2 = t_1 - im_m
    if (im_m <= 0.115d0) then
        tmp = sin(re) * t_2
    else if (im_m <= 1.8d+55) then
        tmp = t_0
    else if (im_m <= 7.5d+67) then
        tmp = t_2 * (re + ((-0.16666666666666666d0) * (re ** 3.0d0)))
    else if (im_m <= 5.8d+102) then
        tmp = t_0
    else
        tmp = sin(re) * t_1
    end if
    code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = (Math.exp(-im_m) - Math.exp(im_m)) * (0.5 * re);
	double t_1 = Math.pow(im_m, 3.0) * -0.16666666666666666;
	double t_2 = t_1 - im_m;
	double tmp;
	if (im_m <= 0.115) {
		tmp = Math.sin(re) * t_2;
	} else if (im_m <= 1.8e+55) {
		tmp = t_0;
	} else if (im_m <= 7.5e+67) {
		tmp = t_2 * (re + (-0.16666666666666666 * Math.pow(re, 3.0)));
	} else if (im_m <= 5.8e+102) {
		tmp = t_0;
	} else {
		tmp = Math.sin(re) * t_1;
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = (math.exp(-im_m) - math.exp(im_m)) * (0.5 * re)
	t_1 = math.pow(im_m, 3.0) * -0.16666666666666666
	t_2 = t_1 - im_m
	tmp = 0
	if im_m <= 0.115:
		tmp = math.sin(re) * t_2
	elif im_m <= 1.8e+55:
		tmp = t_0
	elif im_m <= 7.5e+67:
		tmp = t_2 * (re + (-0.16666666666666666 * math.pow(re, 3.0)))
	elif im_m <= 5.8e+102:
		tmp = t_0
	else:
		tmp = math.sin(re) * t_1
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(Float64(exp(Float64(-im_m)) - exp(im_m)) * Float64(0.5 * re))
	t_1 = Float64((im_m ^ 3.0) * -0.16666666666666666)
	t_2 = Float64(t_1 - im_m)
	tmp = 0.0
	if (im_m <= 0.115)
		tmp = Float64(sin(re) * t_2);
	elseif (im_m <= 1.8e+55)
		tmp = t_0;
	elseif (im_m <= 7.5e+67)
		tmp = Float64(t_2 * Float64(re + Float64(-0.16666666666666666 * (re ^ 3.0))));
	elseif (im_m <= 5.8e+102)
		tmp = t_0;
	else
		tmp = Float64(sin(re) * t_1);
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	t_0 = (exp(-im_m) - exp(im_m)) * (0.5 * re);
	t_1 = (im_m ^ 3.0) * -0.16666666666666666;
	t_2 = t_1 - im_m;
	tmp = 0.0;
	if (im_m <= 0.115)
		tmp = sin(re) * t_2;
	elseif (im_m <= 1.8e+55)
		tmp = t_0;
	elseif (im_m <= 7.5e+67)
		tmp = t_2 * (re + (-0.16666666666666666 * (re ^ 3.0)));
	elseif (im_m <= 5.8e+102)
		tmp = t_0;
	else
		tmp = sin(re) * t_1;
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - im$95$m), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 0.115], N[(N[Sin[re], $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[im$95$m, 1.8e+55], t$95$0, If[LessEqual[im$95$m, 7.5e+67], N[(t$95$2 * N[(re + N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 5.8e+102], t$95$0, N[(N[Sin[re], $MachinePrecision] * t$95$1), $MachinePrecision]]]]]), $MachinePrecision]]]]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := \left(e^{-im_m} - e^{im_m}\right) \cdot \left(0.5 \cdot re\right)\\
t_1 := {im_m}^{3} \cdot -0.16666666666666666\\
t_2 := t_1 - im_m\\
im_s \cdot \begin{array}{l}
\mathbf{if}\;im_m \leq 0.115:\\
\;\;\;\;\sin re \cdot t_2\\

\mathbf{elif}\;im_m \leq 1.8 \cdot 10^{+55}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im_m \leq 7.5 \cdot 10^{+67}:\\
\;\;\;\;t_2 \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\

\mathbf{elif}\;im_m \leq 5.8 \cdot 10^{+102}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\sin re \cdot t_1\\


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

    1. Initial program 54.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 91.1%

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

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

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

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

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

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

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

    if 0.115000000000000005 < im < 1.79999999999999994e55 or 7.5000000000000005e67 < im < 5.8000000000000005e102

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 100.0%

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

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

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

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

    if 1.79999999999999994e55 < im < 7.5000000000000005e67

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 5.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re \cdot \left(\left(-im\right) + {im}^{3} \cdot -0.16666666666666666\right)} \]
    5. Taylor expanded in re around 0 50.0%

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

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

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

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

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

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

    if 5.8000000000000005e102 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.115:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+55}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+67}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\ \mathbf{elif}\;im \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \]

Alternative 4: 94.1% accurate, 1.4× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := \left(e^{-im_m} - e^{im_m}\right) \cdot \left(0.5 \cdot re\right)\\ im_s \cdot \begin{array}{l} \mathbf{if}\;im_m \leq 1.9 \cdot 10^{-5}:\\ \;\;\;\;im_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im_m \leq 1.8 \cdot 10^{+55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im_m \leq 1.05 \cdot 10^{+68}:\\ \;\;\;\;im_m \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{elif}\;im_m \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im_m}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* (- (exp (- im_m)) (exp im_m)) (* 0.5 re))))
   (*
    im_s
    (if (<= im_m 1.9e-5)
      (* im_m (- (sin re)))
      (if (<= im_m 1.8e+55)
        t_0
        (if (<= im_m 1.05e+68)
          (* im_m (- (* 0.16666666666666666 (pow re 3.0)) re))
          (if (<= im_m 5.8e+102)
            t_0
            (* (sin re) (* (pow im_m 3.0) -0.16666666666666666)))))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = (exp(-im_m) - exp(im_m)) * (0.5 * re);
	double tmp;
	if (im_m <= 1.9e-5) {
		tmp = im_m * -sin(re);
	} else if (im_m <= 1.8e+55) {
		tmp = t_0;
	} else if (im_m <= 1.05e+68) {
		tmp = im_m * ((0.16666666666666666 * pow(re, 3.0)) - re);
	} else if (im_m <= 5.8e+102) {
		tmp = t_0;
	} else {
		tmp = sin(re) * (pow(im_m, 3.0) * -0.16666666666666666);
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (exp(-im_m) - exp(im_m)) * (0.5d0 * re)
    if (im_m <= 1.9d-5) then
        tmp = im_m * -sin(re)
    else if (im_m <= 1.8d+55) then
        tmp = t_0
    else if (im_m <= 1.05d+68) then
        tmp = im_m * ((0.16666666666666666d0 * (re ** 3.0d0)) - re)
    else if (im_m <= 5.8d+102) then
        tmp = t_0
    else
        tmp = sin(re) * ((im_m ** 3.0d0) * (-0.16666666666666666d0))
    end if
    code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = (Math.exp(-im_m) - Math.exp(im_m)) * (0.5 * re);
	double tmp;
	if (im_m <= 1.9e-5) {
		tmp = im_m * -Math.sin(re);
	} else if (im_m <= 1.8e+55) {
		tmp = t_0;
	} else if (im_m <= 1.05e+68) {
		tmp = im_m * ((0.16666666666666666 * Math.pow(re, 3.0)) - re);
	} else if (im_m <= 5.8e+102) {
		tmp = t_0;
	} else {
		tmp = Math.sin(re) * (Math.pow(im_m, 3.0) * -0.16666666666666666);
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = (math.exp(-im_m) - math.exp(im_m)) * (0.5 * re)
	tmp = 0
	if im_m <= 1.9e-5:
		tmp = im_m * -math.sin(re)
	elif im_m <= 1.8e+55:
		tmp = t_0
	elif im_m <= 1.05e+68:
		tmp = im_m * ((0.16666666666666666 * math.pow(re, 3.0)) - re)
	elif im_m <= 5.8e+102:
		tmp = t_0
	else:
		tmp = math.sin(re) * (math.pow(im_m, 3.0) * -0.16666666666666666)
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(Float64(exp(Float64(-im_m)) - exp(im_m)) * Float64(0.5 * re))
	tmp = 0.0
	if (im_m <= 1.9e-5)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif (im_m <= 1.8e+55)
		tmp = t_0;
	elseif (im_m <= 1.05e+68)
		tmp = Float64(im_m * Float64(Float64(0.16666666666666666 * (re ^ 3.0)) - re));
	elseif (im_m <= 5.8e+102)
		tmp = t_0;
	else
		tmp = Float64(sin(re) * Float64((im_m ^ 3.0) * -0.16666666666666666));
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	t_0 = (exp(-im_m) - exp(im_m)) * (0.5 * re);
	tmp = 0.0;
	if (im_m <= 1.9e-5)
		tmp = im_m * -sin(re);
	elseif (im_m <= 1.8e+55)
		tmp = t_0;
	elseif (im_m <= 1.05e+68)
		tmp = im_m * ((0.16666666666666666 * (re ^ 3.0)) - re);
	elseif (im_m <= 5.8e+102)
		tmp = t_0;
	else
		tmp = sin(re) * ((im_m ^ 3.0) * -0.16666666666666666);
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 1.9e-5], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 1.8e+55], t$95$0, If[LessEqual[im$95$m, 1.05e+68], N[(im$95$m * N[(N[(0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 5.8e+102], t$95$0, N[(N[Sin[re], $MachinePrecision] * N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := \left(e^{-im_m} - e^{im_m}\right) \cdot \left(0.5 \cdot re\right)\\
im_s \cdot \begin{array}{l}
\mathbf{if}\;im_m \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;im_m \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im_m \leq 1.8 \cdot 10^{+55}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im_m \leq 1.05 \cdot 10^{+68}:\\
\;\;\;\;im_m \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\

\mathbf{elif}\;im_m \leq 5.8 \cdot 10^{+102}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < 1.9000000000000001e-5

    1. Initial program 53.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 68.0%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    4. Simplified68.0%

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

    if 1.9000000000000001e-5 < im < 1.79999999999999994e55 or 1.05e68 < im < 5.8000000000000005e102

    1. Initial program 97.3%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 97.3%

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

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

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

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

    if 1.79999999999999994e55 < im < 1.05e68

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 3.6%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0 50.0%

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

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

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

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

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

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

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

    if 5.8000000000000005e102 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.9 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+55}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 1.05 \cdot 10^{+68}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{elif}\;im \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \]

Alternative 5: 94.3% accurate, 1.4× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := \left(e^{-im_m} - e^{im_m}\right) \cdot \left(0.5 \cdot re\right)\\ t_1 := {im_m}^{3} \cdot -0.16666666666666666\\ im_s \cdot \begin{array}{l} \mathbf{if}\;im_m \leq 0.054:\\ \;\;\;\;\sin re \cdot \left(t_1 - im_m\right)\\ \mathbf{elif}\;im_m \leq 1.8 \cdot 10^{+55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im_m \leq 3.5 \cdot 10^{+68}:\\ \;\;\;\;im_m \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{elif}\;im_m \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot t_1\\ \end{array} \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* (- (exp (- im_m)) (exp im_m)) (* 0.5 re)))
        (t_1 (* (pow im_m 3.0) -0.16666666666666666)))
   (*
    im_s
    (if (<= im_m 0.054)
      (* (sin re) (- t_1 im_m))
      (if (<= im_m 1.8e+55)
        t_0
        (if (<= im_m 3.5e+68)
          (* im_m (- (* 0.16666666666666666 (pow re 3.0)) re))
          (if (<= im_m 5.8e+102) t_0 (* (sin re) t_1))))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = (exp(-im_m) - exp(im_m)) * (0.5 * re);
	double t_1 = pow(im_m, 3.0) * -0.16666666666666666;
	double tmp;
	if (im_m <= 0.054) {
		tmp = sin(re) * (t_1 - im_m);
	} else if (im_m <= 1.8e+55) {
		tmp = t_0;
	} else if (im_m <= 3.5e+68) {
		tmp = im_m * ((0.16666666666666666 * pow(re, 3.0)) - re);
	} else if (im_m <= 5.8e+102) {
		tmp = t_0;
	} else {
		tmp = sin(re) * t_1;
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (exp(-im_m) - exp(im_m)) * (0.5d0 * re)
    t_1 = (im_m ** 3.0d0) * (-0.16666666666666666d0)
    if (im_m <= 0.054d0) then
        tmp = sin(re) * (t_1 - im_m)
    else if (im_m <= 1.8d+55) then
        tmp = t_0
    else if (im_m <= 3.5d+68) then
        tmp = im_m * ((0.16666666666666666d0 * (re ** 3.0d0)) - re)
    else if (im_m <= 5.8d+102) then
        tmp = t_0
    else
        tmp = sin(re) * t_1
    end if
    code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = (Math.exp(-im_m) - Math.exp(im_m)) * (0.5 * re);
	double t_1 = Math.pow(im_m, 3.0) * -0.16666666666666666;
	double tmp;
	if (im_m <= 0.054) {
		tmp = Math.sin(re) * (t_1 - im_m);
	} else if (im_m <= 1.8e+55) {
		tmp = t_0;
	} else if (im_m <= 3.5e+68) {
		tmp = im_m * ((0.16666666666666666 * Math.pow(re, 3.0)) - re);
	} else if (im_m <= 5.8e+102) {
		tmp = t_0;
	} else {
		tmp = Math.sin(re) * t_1;
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = (math.exp(-im_m) - math.exp(im_m)) * (0.5 * re)
	t_1 = math.pow(im_m, 3.0) * -0.16666666666666666
	tmp = 0
	if im_m <= 0.054:
		tmp = math.sin(re) * (t_1 - im_m)
	elif im_m <= 1.8e+55:
		tmp = t_0
	elif im_m <= 3.5e+68:
		tmp = im_m * ((0.16666666666666666 * math.pow(re, 3.0)) - re)
	elif im_m <= 5.8e+102:
		tmp = t_0
	else:
		tmp = math.sin(re) * t_1
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(Float64(exp(Float64(-im_m)) - exp(im_m)) * Float64(0.5 * re))
	t_1 = Float64((im_m ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im_m <= 0.054)
		tmp = Float64(sin(re) * Float64(t_1 - im_m));
	elseif (im_m <= 1.8e+55)
		tmp = t_0;
	elseif (im_m <= 3.5e+68)
		tmp = Float64(im_m * Float64(Float64(0.16666666666666666 * (re ^ 3.0)) - re));
	elseif (im_m <= 5.8e+102)
		tmp = t_0;
	else
		tmp = Float64(sin(re) * t_1);
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	t_0 = (exp(-im_m) - exp(im_m)) * (0.5 * re);
	t_1 = (im_m ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im_m <= 0.054)
		tmp = sin(re) * (t_1 - im_m);
	elseif (im_m <= 1.8e+55)
		tmp = t_0;
	elseif (im_m <= 3.5e+68)
		tmp = im_m * ((0.16666666666666666 * (re ^ 3.0)) - re);
	elseif (im_m <= 5.8e+102)
		tmp = t_0;
	else
		tmp = sin(re) * t_1;
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 0.054], N[(N[Sin[re], $MachinePrecision] * N[(t$95$1 - im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 1.8e+55], t$95$0, If[LessEqual[im$95$m, 3.5e+68], N[(im$95$m * N[(N[(0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 5.8e+102], t$95$0, N[(N[Sin[re], $MachinePrecision] * t$95$1), $MachinePrecision]]]]]), $MachinePrecision]]]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := \left(e^{-im_m} - e^{im_m}\right) \cdot \left(0.5 \cdot re\right)\\
t_1 := {im_m}^{3} \cdot -0.16666666666666666\\
im_s \cdot \begin{array}{l}
\mathbf{if}\;im_m \leq 0.054:\\
\;\;\;\;\sin re \cdot \left(t_1 - im_m\right)\\

\mathbf{elif}\;im_m \leq 1.8 \cdot 10^{+55}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im_m \leq 3.5 \cdot 10^{+68}:\\
\;\;\;\;im_m \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\

\mathbf{elif}\;im_m \leq 5.8 \cdot 10^{+102}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\sin re \cdot t_1\\


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

    1. Initial program 54.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 91.1%

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

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

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

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

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

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

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

    if 0.0539999999999999994 < im < 1.79999999999999994e55 or 3.49999999999999977e68 < im < 5.8000000000000005e102

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in re around 0 100.0%

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

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

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

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

    if 1.79999999999999994e55 < im < 3.49999999999999977e68

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 3.6%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0 50.0%

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

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

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

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

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

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

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

    if 5.8000000000000005e102 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.054:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+55}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 3.5 \cdot 10^{+68}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{elif}\;im \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \]

Alternative 6: 84.2% accurate, 1.5× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ im_s \cdot \begin{array}{l} \mathbf{if}\;im_m \leq 1.3 \cdot 10^{+32}:\\ \;\;\;\;im_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im_m \leq 1.75 \cdot 10^{+73}:\\ \;\;\;\;im_m \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im_m}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 1.3e+32)
    (* im_m (- (sin re)))
    (if (<= im_m 1.75e+73)
      (* im_m (- (* 0.16666666666666666 (pow re 3.0)) re))
      (* (sin re) (* (pow im_m 3.0) -0.16666666666666666))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 1.3e+32) {
		tmp = im_m * -sin(re);
	} else if (im_m <= 1.75e+73) {
		tmp = im_m * ((0.16666666666666666 * pow(re, 3.0)) - re);
	} else {
		tmp = sin(re) * (pow(im_m, 3.0) * -0.16666666666666666);
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 1.3d+32) then
        tmp = im_m * -sin(re)
    else if (im_m <= 1.75d+73) then
        tmp = im_m * ((0.16666666666666666d0 * (re ** 3.0d0)) - re)
    else
        tmp = sin(re) * ((im_m ** 3.0d0) * (-0.16666666666666666d0))
    end if
    code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 1.3e+32) {
		tmp = im_m * -Math.sin(re);
	} else if (im_m <= 1.75e+73) {
		tmp = im_m * ((0.16666666666666666 * Math.pow(re, 3.0)) - re);
	} else {
		tmp = Math.sin(re) * (Math.pow(im_m, 3.0) * -0.16666666666666666);
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 1.3e+32:
		tmp = im_m * -math.sin(re)
	elif im_m <= 1.75e+73:
		tmp = im_m * ((0.16666666666666666 * math.pow(re, 3.0)) - re)
	else:
		tmp = math.sin(re) * (math.pow(im_m, 3.0) * -0.16666666666666666)
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 1.3e+32)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif (im_m <= 1.75e+73)
		tmp = Float64(im_m * Float64(Float64(0.16666666666666666 * (re ^ 3.0)) - re));
	else
		tmp = Float64(sin(re) * Float64((im_m ^ 3.0) * -0.16666666666666666));
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 1.3e+32)
		tmp = im_m * -sin(re);
	elseif (im_m <= 1.75e+73)
		tmp = im_m * ((0.16666666666666666 * (re ^ 3.0)) - re);
	else
		tmp = sin(re) * ((im_m ^ 3.0) * -0.16666666666666666);
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 1.3e+32], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 1.75e+73], N[(im$95$m * N[(N[(0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
im_s \cdot \begin{array}{l}
\mathbf{if}\;im_m \leq 1.3 \cdot 10^{+32}:\\
\;\;\;\;im_m \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im_m \leq 1.75 \cdot 10^{+73}:\\
\;\;\;\;im_m \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 1.3000000000000001e32

    1. Initial program 55.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 66.6%

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

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

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

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

    if 1.3000000000000001e32 < im < 1.75000000000000001e73

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 3.2%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0 34.2%

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

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

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

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

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

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

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

    if 1.75000000000000001e73 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 98.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \sin re\right)} \]
    6. Step-by-step derivation
      1. *-commutative98.0%

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right)} \]
    7. Simplified98.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.3 \cdot 10^{+32}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.75 \cdot 10^{+73}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \]

Alternative 7: 59.6% accurate, 2.7× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ im_s \cdot \begin{array}{l} \mathbf{if}\;im_m \leq 1.3 \cdot 10^{+32}:\\ \;\;\;\;im_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im_m \leq 2.8 \cdot 10^{+209} \lor \neg \left(im_m \leq 1.6 \cdot 10^{+293}\right):\\ \;\;\;\;0.16666666666666666 \cdot \left(im_m \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;im_m \cdot \left(-re\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 1.3e+32)
    (* im_m (- (sin re)))
    (if (or (<= im_m 2.8e+209) (not (<= im_m 1.6e+293)))
      (* 0.16666666666666666 (* im_m (pow re 3.0)))
      (* im_m (- re))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 1.3e+32) {
		tmp = im_m * -sin(re);
	} else if ((im_m <= 2.8e+209) || !(im_m <= 1.6e+293)) {
		tmp = 0.16666666666666666 * (im_m * pow(re, 3.0));
	} else {
		tmp = im_m * -re;
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 1.3d+32) then
        tmp = im_m * -sin(re)
    else if ((im_m <= 2.8d+209) .or. (.not. (im_m <= 1.6d+293))) then
        tmp = 0.16666666666666666d0 * (im_m * (re ** 3.0d0))
    else
        tmp = im_m * -re
    end if
    code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 1.3e+32) {
		tmp = im_m * -Math.sin(re);
	} else if ((im_m <= 2.8e+209) || !(im_m <= 1.6e+293)) {
		tmp = 0.16666666666666666 * (im_m * Math.pow(re, 3.0));
	} else {
		tmp = im_m * -re;
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 1.3e+32:
		tmp = im_m * -math.sin(re)
	elif (im_m <= 2.8e+209) or not (im_m <= 1.6e+293):
		tmp = 0.16666666666666666 * (im_m * math.pow(re, 3.0))
	else:
		tmp = im_m * -re
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 1.3e+32)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif ((im_m <= 2.8e+209) || !(im_m <= 1.6e+293))
		tmp = Float64(0.16666666666666666 * Float64(im_m * (re ^ 3.0)));
	else
		tmp = Float64(im_m * Float64(-re));
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 1.3e+32)
		tmp = im_m * -sin(re);
	elseif ((im_m <= 2.8e+209) || ~((im_m <= 1.6e+293)))
		tmp = 0.16666666666666666 * (im_m * (re ^ 3.0));
	else
		tmp = im_m * -re;
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 1.3e+32], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[Or[LessEqual[im$95$m, 2.8e+209], N[Not[LessEqual[im$95$m, 1.6e+293]], $MachinePrecision]], N[(0.16666666666666666 * N[(im$95$m * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im$95$m * (-re)), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
im_s \cdot \begin{array}{l}
\mathbf{if}\;im_m \leq 1.3 \cdot 10^{+32}:\\
\;\;\;\;im_m \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im_m \leq 2.8 \cdot 10^{+209} \lor \neg \left(im_m \leq 1.6 \cdot 10^{+293}\right):\\
\;\;\;\;0.16666666666666666 \cdot \left(im_m \cdot {re}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 1.3000000000000001e32

    1. Initial program 55.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 66.6%

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

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

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

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

    if 1.3000000000000001e32 < im < 2.80000000000000013e209 or 1.6e293 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 4.7%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    4. Simplified4.7%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0 13.2%

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

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

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

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

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

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

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

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

    if 2.80000000000000013e209 < im < 1.6e293

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 5.0%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0 27.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.3 \cdot 10^{+32}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 2.8 \cdot 10^{+209} \lor \neg \left(im \leq 1.6 \cdot 10^{+293}\right):\\ \;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-re\right)\\ \end{array} \]

Alternative 8: 76.2% accurate, 2.7× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ im_s \cdot \begin{array}{l} \mathbf{if}\;im_m \leq 1.3 \cdot 10^{+32}:\\ \;\;\;\;im_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im_m \leq 2.7 \cdot 10^{+103}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im_m \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im_m}^{3} \cdot -0.16666666666666666 - im_m\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 1.3e+32)
    (* im_m (- (sin re)))
    (if (<= im_m 2.7e+103)
      (* 0.16666666666666666 (* im_m (pow re 3.0)))
      (* re (- (* (pow im_m 3.0) -0.16666666666666666) im_m))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 1.3e+32) {
		tmp = im_m * -sin(re);
	} else if (im_m <= 2.7e+103) {
		tmp = 0.16666666666666666 * (im_m * pow(re, 3.0));
	} else {
		tmp = re * ((pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 1.3d+32) then
        tmp = im_m * -sin(re)
    else if (im_m <= 2.7d+103) then
        tmp = 0.16666666666666666d0 * (im_m * (re ** 3.0d0))
    else
        tmp = re * (((im_m ** 3.0d0) * (-0.16666666666666666d0)) - im_m)
    end if
    code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 1.3e+32) {
		tmp = im_m * -Math.sin(re);
	} else if (im_m <= 2.7e+103) {
		tmp = 0.16666666666666666 * (im_m * Math.pow(re, 3.0));
	} else {
		tmp = re * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 1.3e+32:
		tmp = im_m * -math.sin(re)
	elif im_m <= 2.7e+103:
		tmp = 0.16666666666666666 * (im_m * math.pow(re, 3.0))
	else:
		tmp = re * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m)
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 1.3e+32)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif (im_m <= 2.7e+103)
		tmp = Float64(0.16666666666666666 * Float64(im_m * (re ^ 3.0)));
	else
		tmp = Float64(re * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - im_m));
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 1.3e+32)
		tmp = im_m * -sin(re);
	elseif (im_m <= 2.7e+103)
		tmp = 0.16666666666666666 * (im_m * (re ^ 3.0));
	else
		tmp = re * (((im_m ^ 3.0) * -0.16666666666666666) - im_m);
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 1.3e+32], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 2.7e+103], N[(0.16666666666666666 * N[(im$95$m * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
im_s \cdot \begin{array}{l}
\mathbf{if}\;im_m \leq 1.3 \cdot 10^{+32}:\\
\;\;\;\;im_m \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im_m \leq 2.7 \cdot 10^{+103}:\\
\;\;\;\;0.16666666666666666 \cdot \left(im_m \cdot {re}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 1.3000000000000001e32

    1. Initial program 55.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 66.6%

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

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

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

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

    if 1.3000000000000001e32 < im < 2.69999999999999993e103

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 3.4%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0 18.4%

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

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

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

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

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

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

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

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

    if 2.69999999999999993e103 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re \cdot \left(\left(-im\right) + {im}^{3} \cdot -0.16666666666666666\right)} \]
    5. Taylor expanded in re around 0 73.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.3 \cdot 10^{+32}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+103}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 9: 76.3% accurate, 2.7× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ im_s \cdot \begin{array}{l} \mathbf{if}\;im_m \leq 2.4 \cdot 10^{+32}:\\ \;\;\;\;im_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im_m \leq 2.7 \cdot 10^{+103}:\\ \;\;\;\;im_m \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im_m}^{3} \cdot -0.16666666666666666 - im_m\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 2.4e+32)
    (* im_m (- (sin re)))
    (if (<= im_m 2.7e+103)
      (* im_m (- (* 0.16666666666666666 (pow re 3.0)) re))
      (* re (- (* (pow im_m 3.0) -0.16666666666666666) im_m))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2.4e+32) {
		tmp = im_m * -sin(re);
	} else if (im_m <= 2.7e+103) {
		tmp = im_m * ((0.16666666666666666 * pow(re, 3.0)) - re);
	} else {
		tmp = re * ((pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 2.4d+32) then
        tmp = im_m * -sin(re)
    else if (im_m <= 2.7d+103) then
        tmp = im_m * ((0.16666666666666666d0 * (re ** 3.0d0)) - re)
    else
        tmp = re * (((im_m ** 3.0d0) * (-0.16666666666666666d0)) - im_m)
    end if
    code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2.4e+32) {
		tmp = im_m * -Math.sin(re);
	} else if (im_m <= 2.7e+103) {
		tmp = im_m * ((0.16666666666666666 * Math.pow(re, 3.0)) - re);
	} else {
		tmp = re * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 2.4e+32:
		tmp = im_m * -math.sin(re)
	elif im_m <= 2.7e+103:
		tmp = im_m * ((0.16666666666666666 * math.pow(re, 3.0)) - re)
	else:
		tmp = re * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m)
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 2.4e+32)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif (im_m <= 2.7e+103)
		tmp = Float64(im_m * Float64(Float64(0.16666666666666666 * (re ^ 3.0)) - re));
	else
		tmp = Float64(re * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - im_m));
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 2.4e+32)
		tmp = im_m * -sin(re);
	elseif (im_m <= 2.7e+103)
		tmp = im_m * ((0.16666666666666666 * (re ^ 3.0)) - re);
	else
		tmp = re * (((im_m ^ 3.0) * -0.16666666666666666) - im_m);
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 2.4e+32], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 2.7e+103], N[(im$95$m * N[(N[(0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision], N[(re * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
im_s \cdot \begin{array}{l}
\mathbf{if}\;im_m \leq 2.4 \cdot 10^{+32}:\\
\;\;\;\;im_m \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im_m \leq 2.7 \cdot 10^{+103}:\\
\;\;\;\;im_m \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 2.39999999999999991e32

    1. Initial program 55.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 66.6%

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

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

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

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

    if 2.39999999999999991e32 < im < 2.69999999999999993e103

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 3.4%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0 18.4%

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

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

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

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

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

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

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

    if 2.69999999999999993e103 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re \cdot \left(\left(-im\right) + {im}^{3} \cdot -0.16666666666666666\right)} \]
    5. Taylor expanded in re around 0 73.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.4 \cdot 10^{+32}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+103}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 10: 60.3% accurate, 2.9× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ im_s \cdot \begin{array}{l} \mathbf{if}\;im_m \leq 2300000:\\ \;\;\;\;im_m \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(im_m \cdot {re}^{3}\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 2300000.0)
    (* im_m (- (sin re)))
    (* -0.16666666666666666 (* im_m (pow re 3.0))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2300000.0) {
		tmp = im_m * -sin(re);
	} else {
		tmp = -0.16666666666666666 * (im_m * pow(re, 3.0));
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 2300000.0d0) then
        tmp = im_m * -sin(re)
    else
        tmp = (-0.16666666666666666d0) * (im_m * (re ** 3.0d0))
    end if
    code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2300000.0) {
		tmp = im_m * -Math.sin(re);
	} else {
		tmp = -0.16666666666666666 * (im_m * Math.pow(re, 3.0));
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 2300000.0:
		tmp = im_m * -math.sin(re)
	else:
		tmp = -0.16666666666666666 * (im_m * math.pow(re, 3.0))
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 2300000.0)
		tmp = Float64(im_m * Float64(-sin(re)));
	else
		tmp = Float64(-0.16666666666666666 * Float64(im_m * (re ^ 3.0)));
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 2300000.0)
		tmp = im_m * -sin(re);
	else
		tmp = -0.16666666666666666 * (im_m * (re ^ 3.0));
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 2300000.0], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(-0.16666666666666666 * N[(im$95$m * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
im_s \cdot \begin{array}{l}
\mathbf{if}\;im_m \leq 2300000:\\
\;\;\;\;im_m \cdot \left(-\sin re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 2.3e6

    1. Initial program 54.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 67.5%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    4. Simplified67.5%

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

    if 2.3e6 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 4.7%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    4. Simplified4.7%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0 9.6%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-re\right) \cdot im} + im \cdot \left({re}^{3} \cdot 0.16666666666666666\right) \]
      3. add-sqr-sqrt6.5%

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

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

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

        \[\leadsto \color{blue}{\left(\sqrt{re} \cdot \sqrt{re}\right)} \cdot im + im \cdot \left({re}^{3} \cdot 0.16666666666666666\right) \]
      7. add-sqr-sqrt22.6%

        \[\leadsto \color{blue}{re} \cdot im + im \cdot \left({re}^{3} \cdot 0.16666666666666666\right) \]
      8. add-sqr-sqrt5.9%

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

        \[\leadsto re \cdot im + im \cdot \color{blue}{\sqrt{\left({re}^{3} \cdot 0.16666666666666666\right) \cdot \left({re}^{3} \cdot 0.16666666666666666\right)}} \]
      10. swap-sqr6.1%

        \[\leadsto re \cdot im + im \cdot \sqrt{\color{blue}{\left({re}^{3} \cdot {re}^{3}\right) \cdot \left(0.16666666666666666 \cdot 0.16666666666666666\right)}} \]
      11. metadata-eval6.1%

        \[\leadsto re \cdot im + im \cdot \sqrt{\left({re}^{3} \cdot {re}^{3}\right) \cdot \color{blue}{0.027777777777777776}} \]
      12. metadata-eval6.1%

        \[\leadsto re \cdot im + im \cdot \sqrt{\left({re}^{3} \cdot {re}^{3}\right) \cdot \color{blue}{\left(-0.16666666666666666 \cdot -0.16666666666666666\right)}} \]
      13. swap-sqr6.1%

        \[\leadsto re \cdot im + im \cdot \sqrt{\color{blue}{\left({re}^{3} \cdot -0.16666666666666666\right) \cdot \left({re}^{3} \cdot -0.16666666666666666\right)}} \]
      14. sqrt-unprod0.4%

        \[\leadsto re \cdot im + im \cdot \color{blue}{\left(\sqrt{{re}^{3} \cdot -0.16666666666666666} \cdot \sqrt{{re}^{3} \cdot -0.16666666666666666}\right)} \]
      15. add-sqr-sqrt6.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2300000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\ \end{array} \]

Alternative 11: 56.0% accurate, 2.9× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ im_s \cdot \begin{array}{l} \mathbf{if}\;im_m \leq 9.5 \cdot 10^{+142}:\\ \;\;\;\;im_m \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;im_m \cdot \left(-re\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= im_m 9.5e+142) (* im_m (- (sin re))) (* im_m (- re)))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 9.5e+142) {
		tmp = im_m * -sin(re);
	} else {
		tmp = im_m * -re;
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 9.5d+142) then
        tmp = im_m * -sin(re)
    else
        tmp = im_m * -re
    end if
    code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 9.5e+142) {
		tmp = im_m * -Math.sin(re);
	} else {
		tmp = im_m * -re;
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 9.5e+142:
		tmp = im_m * -math.sin(re)
	else:
		tmp = im_m * -re
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 9.5e+142)
		tmp = Float64(im_m * Float64(-sin(re)));
	else
		tmp = Float64(im_m * Float64(-re));
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 9.5e+142)
		tmp = im_m * -sin(re);
	else
		tmp = im_m * -re;
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 9.5e+142], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(im$95$m * (-re)), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
im_s \cdot \begin{array}{l}
\mathbf{if}\;im_m \leq 9.5 \cdot 10^{+142}:\\
\;\;\;\;im_m \cdot \left(-\sin re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 9.50000000000000001e142

    1. Initial program 57.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 63.4%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    4. Simplified63.4%

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

    if 9.50000000000000001e142 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 5.1%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0 24.3%

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

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

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

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

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

Alternative 12: 33.5% accurate, 50.8× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ im_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 5.4 \cdot 10^{+229}:\\ \;\;\;\;im_m \cdot \left(-re\right)\\ \mathbf{else}:\\ \;\;\;\;im_m \cdot re\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 5.4e+229) (* im_m (- re)) (* im_m re))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 5.4e+229) {
		tmp = im_m * -re;
	} else {
		tmp = im_m * re;
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (re <= 5.4d+229) then
        tmp = im_m * -re
    else
        tmp = im_m * re
    end if
    code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 5.4e+229) {
		tmp = im_m * -re;
	} else {
		tmp = im_m * re;
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if re <= 5.4e+229:
		tmp = im_m * -re
	else:
		tmp = im_m * re
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (re <= 5.4e+229)
		tmp = Float64(im_m * Float64(-re));
	else
		tmp = Float64(im_m * re);
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (re <= 5.4e+229)
		tmp = im_m * -re;
	else
		tmp = im_m * re;
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 5.4e+229], N[(im$95$m * (-re)), $MachinePrecision], N[(im$95$m * re), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
im_s \cdot \begin{array}{l}
\mathbf{if}\;re \leq 5.4 \cdot 10^{+229}:\\
\;\;\;\;im_m \cdot \left(-re\right)\\

\mathbf{else}:\\
\;\;\;\;im_m \cdot re\\


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

    1. Initial program 66.7%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 52.6%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0 34.4%

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

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

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

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

    if 5.4000000000000001e229 < re

    1. Initial program 39.8%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Taylor expanded in im around 0 68.2%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    4. Simplified68.2%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0 5.4%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-re\right) \cdot im} + im \cdot \left({re}^{3} \cdot 0.16666666666666666\right) \]
      3. add-sqr-sqrt0.0%

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

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

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

        \[\leadsto \color{blue}{\left(\sqrt{re} \cdot \sqrt{re}\right)} \cdot im + im \cdot \left({re}^{3} \cdot 0.16666666666666666\right) \]
      7. add-sqr-sqrt17.9%

        \[\leadsto \color{blue}{re} \cdot im + im \cdot \left({re}^{3} \cdot 0.16666666666666666\right) \]
      8. add-sqr-sqrt17.9%

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

        \[\leadsto re \cdot im + im \cdot \color{blue}{\sqrt{\left({re}^{3} \cdot 0.16666666666666666\right) \cdot \left({re}^{3} \cdot 0.16666666666666666\right)}} \]
      10. swap-sqr17.9%

        \[\leadsto re \cdot im + im \cdot \sqrt{\color{blue}{\left({re}^{3} \cdot {re}^{3}\right) \cdot \left(0.16666666666666666 \cdot 0.16666666666666666\right)}} \]
      11. metadata-eval17.9%

        \[\leadsto re \cdot im + im \cdot \sqrt{\left({re}^{3} \cdot {re}^{3}\right) \cdot \color{blue}{0.027777777777777776}} \]
      12. metadata-eval17.9%

        \[\leadsto re \cdot im + im \cdot \sqrt{\left({re}^{3} \cdot {re}^{3}\right) \cdot \color{blue}{\left(-0.16666666666666666 \cdot -0.16666666666666666\right)}} \]
      13. swap-sqr17.9%

        \[\leadsto re \cdot im + im \cdot \sqrt{\color{blue}{\left({re}^{3} \cdot -0.16666666666666666\right) \cdot \left({re}^{3} \cdot -0.16666666666666666\right)}} \]
      14. sqrt-unprod0.0%

        \[\leadsto re \cdot im + im \cdot \color{blue}{\left(\sqrt{{re}^{3} \cdot -0.16666666666666666} \cdot \sqrt{{re}^{3} \cdot -0.16666666666666666}\right)} \]
      15. add-sqr-sqrt5.2%

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

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

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

      \[\leadsto \color{blue}{im \cdot re} \]
    11. Step-by-step derivation
      1. *-commutative14.7%

        \[\leadsto \color{blue}{re \cdot im} \]
    12. Simplified14.7%

      \[\leadsto \color{blue}{re \cdot im} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification32.6%

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

Alternative 13: 20.8% accurate, 102.7× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ im_s \cdot \left(im_m \cdot re\right) \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m) :precision binary64 (* im_s (* im_m re)))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	return im_s * (im_m * re);
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = im_s * (im_m * re)
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	return im_s * (im_m * re);
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	return im_s * (im_m * re)
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	return Float64(im_s * Float64(im_m * re))
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp = code(im_s, re, im_m)
	tmp = im_s * (im_m * re);
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * N[(im$95$m * re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

\\
im_s \cdot \left(im_m \cdot re\right)
\end{array}
Derivation
  1. Initial program 64.2%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Taylor expanded in im around 0 54.0%

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

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

      \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
  4. Simplified54.0%

    \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
  5. Taylor expanded in re around 0 29.5%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(-re\right) \cdot im} + im \cdot \left({re}^{3} \cdot 0.16666666666666666\right) \]
    3. add-sqr-sqrt16.1%

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

      \[\leadsto \color{blue}{\sqrt{\left(-re\right) \cdot \left(-re\right)}} \cdot im + im \cdot \left({re}^{3} \cdot 0.16666666666666666\right) \]
    5. sqr-neg23.5%

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

      \[\leadsto \color{blue}{\left(\sqrt{re} \cdot \sqrt{re}\right)} \cdot im + im \cdot \left({re}^{3} \cdot 0.16666666666666666\right) \]
    7. add-sqr-sqrt25.0%

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

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

      \[\leadsto re \cdot im + im \cdot \color{blue}{\sqrt{\left({re}^{3} \cdot 0.16666666666666666\right) \cdot \left({re}^{3} \cdot 0.16666666666666666\right)}} \]
    10. swap-sqr18.7%

      \[\leadsto re \cdot im + im \cdot \sqrt{\color{blue}{\left({re}^{3} \cdot {re}^{3}\right) \cdot \left(0.16666666666666666 \cdot 0.16666666666666666\right)}} \]
    11. metadata-eval18.7%

      \[\leadsto re \cdot im + im \cdot \sqrt{\left({re}^{3} \cdot {re}^{3}\right) \cdot \color{blue}{0.027777777777777776}} \]
    12. metadata-eval18.7%

      \[\leadsto re \cdot im + im \cdot \sqrt{\left({re}^{3} \cdot {re}^{3}\right) \cdot \color{blue}{\left(-0.16666666666666666 \cdot -0.16666666666666666\right)}} \]
    13. swap-sqr18.7%

      \[\leadsto re \cdot im + im \cdot \sqrt{\color{blue}{\left({re}^{3} \cdot -0.16666666666666666\right) \cdot \left({re}^{3} \cdot -0.16666666666666666\right)}} \]
    14. sqrt-unprod14.2%

      \[\leadsto re \cdot im + im \cdot \color{blue}{\left(\sqrt{{re}^{3} \cdot -0.16666666666666666} \cdot \sqrt{{re}^{3} \cdot -0.16666666666666666}\right)} \]
    15. add-sqr-sqrt17.5%

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

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

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

    \[\leadsto \color{blue}{im \cdot re} \]
  11. Step-by-step derivation
    1. *-commutative21.9%

      \[\leadsto \color{blue}{re \cdot im} \]
  12. Simplified21.9%

    \[\leadsto \color{blue}{re \cdot im} \]
  13. Final simplification21.9%

    \[\leadsto im \cdot re \]

Developer target: 99.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|im\right| < 1:\\ \;\;\;\;-\sin 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 \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (< (fabs im) 1.0)
   (-
    (*
     (sin re)
     (+
      (+ im (* (* (* 0.16666666666666666 im) im) im))
      (* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
   (* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
double code(double re, double im) {
	double tmp;
	if (fabs(im) < 1.0) {
		tmp = -(sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
	} else {
		tmp = (0.5 * sin(re)) * (exp(-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 = -(sin(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
    else
        tmp = (0.5d0 * sin(re)) * (exp(-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.sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
	} else {
		tmp = (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if math.fabs(im) < 1.0:
		tmp = -(math.sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)))
	else:
		tmp = (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (abs(im) < 1.0)
		tmp = Float64(-Float64(sin(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 * sin(re)) * Float64(exp(Float64(-im)) - exp(im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (abs(im) < 1.0)
		tmp = -(sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
	else
		tmp = (0.5 * sin(re)) * (exp(-im) - exp(im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Sin[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[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\sin 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 \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023334 
(FPCore (re im)
  :name "math.cos on complex, imaginary part"
  :precision binary64

  :herbie-target
  (if (< (fabs im) 1.0) (- (* (sin re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))

  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))