math.cos on complex, imaginary part

Percentage Accurate: 65.6% → 99.4%
Time: 8.3s
Alternatives: 10
Speedup: 2.8×

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 10 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.6% 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.4% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
\mathbf{if}\;t_0 \leq -2 \cdot 10^{+110} \lor \neg \left(t_0 \leq 2 \cdot 10^{-10}\right):\\
\;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\

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


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

    1. Initial program 100.0%

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

    if -2e110 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 2.00000000000000007e-10

    1. Initial program 29.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -2 \cdot 10^{+110} \lor \neg \left(e^{-im} - e^{im} \leq 2 \cdot 10^{-10}\right):\\ \;\;\;\;\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: 94.4% accurate, 1.4× speedup?

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

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

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

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

\mathbf{elif}\;im \leq 3.35 \cdot 10^{+100}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4.1000000000000001e93 or 3.3499999999999998e100 < 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 97.0%

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

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

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

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

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

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

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

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

    if -4.1000000000000001e93 < im < -0.00139999999999999999 or 260 < im < 3.3499999999999998e100

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

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

    if -0.00139999999999999999 < im < 260

    1. Initial program 29.9%

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

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in99.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.1 \cdot 10^{+93}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -0.0014:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{elif}\;im \leq 260:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 3.35 \cdot 10^{+100}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \end{array} \]

Alternative 3: 94.7% accurate, 1.4× speedup?

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

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

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

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

\mathbf{elif}\;im \leq 3.35 \cdot 10^{+100}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4.1000000000000001e93 or 3.3499999999999998e100 < 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 97.0%

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

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

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

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

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

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

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

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

    if -4.1000000000000001e93 < im < -0.309999999999999998 or 260 < im < 3.3499999999999998e100

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

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

    if -0.309999999999999998 < im < 260

    1. Initial program 29.9%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.1 \cdot 10^{+93}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq -0.31:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{elif}\;im \leq 260:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 3.35 \cdot 10^{+100}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\ \end{array} \]

Alternative 4: 84.7% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := -0.16666666666666666 \cdot \left(\sin re \cdot {im}^{3}\right)\\
\mathbf{if}\;im \leq -2.4:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 3 \cdot 10^{+18}:\\
\;\;\;\;im \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im \leq 6 \cdot 10^{+99}:\\
\;\;\;\;-2.25 \cdot {re}^{3} + re \cdot 13.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.39999999999999991 or 6.00000000000000029e99 < 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 82.9%

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

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

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

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

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

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

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

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

    if -2.39999999999999991 < im < 3e18

    1. Initial program 31.0%

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

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in97.6%

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

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

    if 3e18 < im < 6.00000000000000029e99

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Applied egg-rr0.9%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{27} \]
    3. Taylor expanded in re around 0 33.9%

      \[\leadsto \color{blue}{-2.25 \cdot {re}^{3} + 13.5 \cdot re} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification87.1%

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

Alternative 5: 77.7% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.3 \cdot 10^{+25}:\\
\;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\

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

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


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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)} \]
    7. Step-by-step derivation
      1. *-commutative61.9%

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

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

    if -1.2999999999999999e25 < im < 2.15e9

    1. Initial program 33.5%

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

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in94.3%

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

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

    if 2.15e9 < 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 65.9%

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

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

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

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

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

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

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

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

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

Alternative 6: 77.7% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.1 \cdot 10^{+25} \lor \neg \left(im \leq 540000000\right):\\
\;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -1.1e25 or 5.4e8 < 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 74.3%

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

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

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

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

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

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

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

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

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

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

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

    if -1.1e25 < im < 5.4e8

    1. Initial program 33.5%

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

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in94.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.1 \cdot 10^{+25} \lor \neg \left(im \leq 540000000\right):\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 7: 58.8% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -1350:\\ \;\;\;\;im \cdot \left(0.0001984126984126984 \cdot {re}^{7}\right)\\ \mathbf{elif}\;im \leq 1220000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -1350.0)
   (* im (* 0.0001984126984126984 (pow re 7.0)))
   (if (<= im 1220000.0) (* im (- (sin re))) (* im (- re)))))
double code(double re, double im) {
	double tmp;
	if (im <= -1350.0) {
		tmp = im * (0.0001984126984126984 * pow(re, 7.0));
	} else if (im <= 1220000.0) {
		tmp = im * -sin(re);
	} else {
		tmp = im * -re;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= (-1350.0d0)) then
        tmp = im * (0.0001984126984126984d0 * (re ** 7.0d0))
    else if (im <= 1220000.0d0) then
        tmp = im * -sin(re)
    else
        tmp = im * -re
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -1350.0) {
		tmp = im * (0.0001984126984126984 * Math.pow(re, 7.0));
	} else if (im <= 1220000.0) {
		tmp = im * -Math.sin(re);
	} else {
		tmp = im * -re;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -1350.0:
		tmp = im * (0.0001984126984126984 * math.pow(re, 7.0))
	elif im <= 1220000.0:
		tmp = im * -math.sin(re)
	else:
		tmp = im * -re
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -1350.0)
		tmp = Float64(im * Float64(0.0001984126984126984 * (re ^ 7.0)));
	elseif (im <= 1220000.0)
		tmp = Float64(im * Float64(-sin(re)));
	else
		tmp = Float64(im * Float64(-re));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -1350.0)
		tmp = im * (0.0001984126984126984 * (re ^ 7.0));
	elseif (im <= 1220000.0)
		tmp = im * -sin(re);
	else
		tmp = im * -re;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -1350.0], N[(im * N[(0.0001984126984126984 * N[Power[re, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1220000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(im * (-re)), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1350:\\
\;\;\;\;im \cdot \left(0.0001984126984126984 \cdot {re}^{7}\right)\\

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

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


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

    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(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg4.7%

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in4.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1350 < im < 1.22e6

    1. Initial program 31.0%

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

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

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

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

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

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

    if 1.22e6 < 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.2%

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in4.2%

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

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

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

        \[\leadsto \color{blue}{-re \cdot im} \]
      2. distribute-rgt-neg-in22.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1350:\\ \;\;\;\;im \cdot \left(0.0001984126984126984 \cdot {re}^{7}\right)\\ \mathbf{elif}\;im \leq 1220000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-re\right)\\ \end{array} \]

Alternative 8: 54.5% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 5200:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 5200.0) (* im (- (sin re))) (* im (- re))))
double code(double re, double im) {
	double tmp;
	if (im <= 5200.0) {
		tmp = im * -sin(re);
	} else {
		tmp = im * -re;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 5200.0d0) then
        tmp = im * -sin(re)
    else
        tmp = im * -re
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 5200.0) {
		tmp = im * -Math.sin(re);
	} else {
		tmp = im * -re;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 5200.0:
		tmp = im * -math.sin(re)
	else:
		tmp = im * -re
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 5200.0)
		tmp = Float64(im * Float64(-sin(re)));
	else
		tmp = Float64(im * Float64(-re));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 5200.0)
		tmp = im * -sin(re);
	else
		tmp = im * -re;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 5200.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(im * (-re)), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 52.9%

      \[\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(\sin re \cdot im\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg68.2%

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in68.2%

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

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

    if 5200 < 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.2%

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

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

        \[\leadsto -\color{blue}{im \cdot \sin re} \]
      3. distribute-rgt-neg-in4.2%

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

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

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

        \[\leadsto \color{blue}{-re \cdot im} \]
      2. distribute-rgt-neg-in22.4%

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

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

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

Alternative 9: 33.0% accurate, 77.0× speedup?

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

\\
im \cdot \left(-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 52.9%

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

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

      \[\leadsto -\color{blue}{im \cdot \sin re} \]
    3. distribute-rgt-neg-in52.9%

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

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

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

      \[\leadsto \color{blue}{-re \cdot im} \]
    2. distribute-rgt-neg-in33.9%

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

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

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

Alternative 10: 3.2% accurate, 102.7× speedup?

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

\\
re \cdot 13.5
\end{array}
Derivation
  1. Initial program 64.2%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Applied egg-rr3.3%

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

    \[\leadsto \color{blue}{13.5 \cdot re} \]
  4. Step-by-step derivation
    1. *-commutative3.0%

      \[\leadsto \color{blue}{re \cdot 13.5} \]
  5. Simplified3.0%

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

    \[\leadsto re \cdot 13.5 \]

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