math.cos on complex, imaginary part

Percentage Accurate: 64.9% → 99.8%
Time: 7.6s
Alternatives: 13
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 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: 64.9% 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.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -5 \lor \neg \left(t_0 \leq 0.0005\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 -5.0) (not (<= t_0 0.0005)))
     (* 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 <= -5.0) || !(t_0 <= 0.0005)) {
		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 <= (-5.0d0)) .or. (.not. (t_0 <= 0.0005d0))) 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 <= -5.0) || !(t_0 <= 0.0005)) {
		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 <= -5.0) or not (t_0 <= 0.0005):
		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 <= -5.0) || !(t_0 <= 0.0005))
		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 <= -5.0) || ~((t_0 <= 0.0005)))
		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, -5.0], N[Not[LessEqual[t$95$0, 0.0005]], $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 -5 \lor \neg \left(t_0 \leq 0.0005\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)) < -5 or 5.0000000000000001e-4 < (-.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 -5 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 5.0000000000000001e-4

    1. Initial program 31.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 -5 \lor \neg \left(e^{-im} - e^{im} \leq 0.0005\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.9% 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 := {im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \mathbf{if}\;im \leq -9 \cdot 10^{+110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.000195:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.95:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;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 (* (pow im 3.0) (* (sin re) -0.16666666666666666))))
   (if (<= im -9e+110)
     t_1
     (if (<= im -0.000195)
       t_0
       (if (<= im 1.95) (* im (- (sin re))) (if (<= im 5.8e+102) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * ((exp(-im) - exp(im)) * re);
	double t_1 = pow(im, 3.0) * (sin(re) * -0.16666666666666666);
	double tmp;
	if (im <= -9e+110) {
		tmp = t_1;
	} else if (im <= -0.000195) {
		tmp = t_0;
	} else if (im <= 1.95) {
		tmp = im * -sin(re);
	} else if (im <= 5.8e+102) {
		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 = (im ** 3.0d0) * (sin(re) * (-0.16666666666666666d0))
    if (im <= (-9d+110)) then
        tmp = t_1
    else if (im <= (-0.000195d0)) then
        tmp = t_0
    else if (im <= 1.95d0) then
        tmp = im * -sin(re)
    else if (im <= 5.8d+102) 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 = Math.pow(im, 3.0) * (Math.sin(re) * -0.16666666666666666);
	double tmp;
	if (im <= -9e+110) {
		tmp = t_1;
	} else if (im <= -0.000195) {
		tmp = t_0;
	} else if (im <= 1.95) {
		tmp = im * -Math.sin(re);
	} else if (im <= 5.8e+102) {
		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 = math.pow(im, 3.0) * (math.sin(re) * -0.16666666666666666)
	tmp = 0
	if im <= -9e+110:
		tmp = t_1
	elif im <= -0.000195:
		tmp = t_0
	elif im <= 1.95:
		tmp = im * -math.sin(re)
	elif im <= 5.8e+102:
		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((im ^ 3.0) * Float64(sin(re) * -0.16666666666666666))
	tmp = 0.0
	if (im <= -9e+110)
		tmp = t_1;
	elseif (im <= -0.000195)
		tmp = t_0;
	elseif (im <= 1.95)
		tmp = Float64(im * Float64(-sin(re)));
	elseif (im <= 5.8e+102)
		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 = (im ^ 3.0) * (sin(re) * -0.16666666666666666);
	tmp = 0.0;
	if (im <= -9e+110)
		tmp = t_1;
	elseif (im <= -0.000195)
		tmp = t_0;
	elseif (im <= 1.95)
		tmp = im * -sin(re);
	elseif (im <= 5.8e+102)
		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[(N[Power[im, 3.0], $MachinePrecision] * N[(N[Sin[re], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -9e+110], t$95$1, If[LessEqual[im, -0.000195], t$95$0, If[LessEqual[im, 1.95], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 5.8e+102], 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 := {im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\
\mathbf{if}\;im \leq -9 \cdot 10^{+110}:\\
\;\;\;\;t_1\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -9.0000000000000005e110 or 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}{-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-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -9.0000000000000005e110 < im < -1.94999999999999996e-4 or 1.94999999999999996 < im < 5.8000000000000005e102

    1. Initial program 99.8%

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

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

    if -1.94999999999999996e-4 < im < 1.94999999999999996

    1. Initial program 31.4%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -9 \cdot 10^{+110}:\\ \;\;\;\;{im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -0.000195:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{elif}\;im \leq 1.95:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \end{array} \]

Alternative 3: 95.2% 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 := {im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \mathbf{if}\;im \leq -9 \cdot 10^{+110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -2.6:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.95:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;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 (* (pow im 3.0) (* (sin re) -0.16666666666666666))))
   (if (<= im -9e+110)
     t_1
     (if (<= im -2.6)
       t_0
       (if (<= im 1.95)
         (* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
         (if (<= im 5.8e+102) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * ((exp(-im) - exp(im)) * re);
	double t_1 = pow(im, 3.0) * (sin(re) * -0.16666666666666666);
	double tmp;
	if (im <= -9e+110) {
		tmp = t_1;
	} else if (im <= -2.6) {
		tmp = t_0;
	} else if (im <= 1.95) {
		tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 5.8e+102) {
		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 = (im ** 3.0d0) * (sin(re) * (-0.16666666666666666d0))
    if (im <= (-9d+110)) then
        tmp = t_1
    else if (im <= (-2.6d0)) then
        tmp = t_0
    else if (im <= 1.95d0) then
        tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    else if (im <= 5.8d+102) 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 = Math.pow(im, 3.0) * (Math.sin(re) * -0.16666666666666666);
	double tmp;
	if (im <= -9e+110) {
		tmp = t_1;
	} else if (im <= -2.6) {
		tmp = t_0;
	} else if (im <= 1.95) {
		tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 5.8e+102) {
		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 = math.pow(im, 3.0) * (math.sin(re) * -0.16666666666666666)
	tmp = 0
	if im <= -9e+110:
		tmp = t_1
	elif im <= -2.6:
		tmp = t_0
	elif im <= 1.95:
		tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	elif im <= 5.8e+102:
		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((im ^ 3.0) * Float64(sin(re) * -0.16666666666666666))
	tmp = 0.0
	if (im <= -9e+110)
		tmp = t_1;
	elseif (im <= -2.6)
		tmp = t_0;
	elseif (im <= 1.95)
		tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	elseif (im <= 5.8e+102)
		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 = (im ^ 3.0) * (sin(re) * -0.16666666666666666);
	tmp = 0.0;
	if (im <= -9e+110)
		tmp = t_1;
	elseif (im <= -2.6)
		tmp = t_0;
	elseif (im <= 1.95)
		tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	elseif (im <= 5.8e+102)
		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[(N[Power[im, 3.0], $MachinePrecision] * N[(N[Sin[re], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -9e+110], t$95$1, If[LessEqual[im, -2.6], t$95$0, If[LessEqual[im, 1.95], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5.8e+102], 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 := {im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\
\mathbf{if}\;im \leq -9 \cdot 10^{+110}:\\
\;\;\;\;t_1\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -9.0000000000000005e110 or 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}{-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-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -9.0000000000000005e110 < im < -2.60000000000000009 or 1.94999999999999996 < 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 75.6%

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

    if -2.60000000000000009 < im < 1.94999999999999996

    1. Initial program 32.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -9 \cdot 10^{+110}:\\ \;\;\;\;{im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq -2.6:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{elif}\;im \leq 1.95:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 5.8 \cdot 10^{+102}:\\ \;\;\;\;0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot \left(\sin re \cdot -0.16666666666666666\right)\\ \end{array} \]

Alternative 4: 83.1% accurate, 1.5× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.39999999999999991 < im < 2.5

    1. Initial program 31.9%

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

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

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

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

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

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

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

Alternative 5: 77.8% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)\\ \mathbf{if}\;im \leq -5.6 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 2050000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+105}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (*
          0.5
          (+
           (* re (* im (* im (* im -0.3333333333333333))))
           (* re (* im -2.0))))))
   (if (<= im -5.6e-5)
     t_0
     (if (<= im 2050000000.0)
       (* im (- (sin re)))
       (if (<= im 1.6e+105)
         (* im (- (* 0.16666666666666666 (pow re 3.0)) re))
         t_0)))))
double code(double re, double im) {
	double t_0 = 0.5 * ((re * (im * (im * (im * -0.3333333333333333)))) + (re * (im * -2.0)));
	double tmp;
	if (im <= -5.6e-5) {
		tmp = t_0;
	} else if (im <= 2050000000.0) {
		tmp = im * -sin(re);
	} else if (im <= 1.6e+105) {
		tmp = im * ((0.16666666666666666 * pow(re, 3.0)) - re);
	} 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.5d0 * ((re * (im * (im * (im * (-0.3333333333333333d0))))) + (re * (im * (-2.0d0))))
    if (im <= (-5.6d-5)) then
        tmp = t_0
    else if (im <= 2050000000.0d0) then
        tmp = im * -sin(re)
    else if (im <= 1.6d+105) then
        tmp = im * ((0.16666666666666666d0 * (re ** 3.0d0)) - re)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * ((re * (im * (im * (im * -0.3333333333333333)))) + (re * (im * -2.0)));
	double tmp;
	if (im <= -5.6e-5) {
		tmp = t_0;
	} else if (im <= 2050000000.0) {
		tmp = im * -Math.sin(re);
	} else if (im <= 1.6e+105) {
		tmp = im * ((0.16666666666666666 * Math.pow(re, 3.0)) - re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * ((re * (im * (im * (im * -0.3333333333333333)))) + (re * (im * -2.0)))
	tmp = 0
	if im <= -5.6e-5:
		tmp = t_0
	elif im <= 2050000000.0:
		tmp = im * -math.sin(re)
	elif im <= 1.6e+105:
		tmp = im * ((0.16666666666666666 * math.pow(re, 3.0)) - re)
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(Float64(re * Float64(im * Float64(im * Float64(im * -0.3333333333333333)))) + Float64(re * Float64(im * -2.0))))
	tmp = 0.0
	if (im <= -5.6e-5)
		tmp = t_0;
	elseif (im <= 2050000000.0)
		tmp = Float64(im * Float64(-sin(re)));
	elseif (im <= 1.6e+105)
		tmp = Float64(im * Float64(Float64(0.16666666666666666 * (re ^ 3.0)) - re));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * ((re * (im * (im * (im * -0.3333333333333333)))) + (re * (im * -2.0)));
	tmp = 0.0;
	if (im <= -5.6e-5)
		tmp = t_0;
	elseif (im <= 2050000000.0)
		tmp = im * -sin(re);
	elseif (im <= 1.6e+105)
		tmp = im * ((0.16666666666666666 * (re ^ 3.0)) - re);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[(re * N[(im * N[(im * N[(im * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(re * N[(im * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.6e-5], t$95$0, If[LessEqual[im, 2050000000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.6e+105], N[(im * N[(N[(0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)\\
\mathbf{if}\;im \leq -5.6 \cdot 10^{-5}:\\
\;\;\;\;t_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -5.59999999999999992e-5 or 1.6e105 < im

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto 0.5 \cdot \left(-0.3333333333333333 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(im \cdot im\right)\right)} + -2 \cdot \left(re \cdot im\right)\right) \]
      3. *-commutative51.3%

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-in51.3%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) + \left(re \cdot im\right) \cdot -2\right)} \]
      2. associate-*l*57.5%

        \[\leadsto 0.5 \cdot \left(\color{blue}{re \cdot \left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right)} + \left(re \cdot im\right) \cdot -2\right) \]
      3. *-commutative57.5%

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

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

        \[\leadsto 0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + \color{blue}{re \cdot \left(im \cdot -2\right)}\right) \]
    7. Applied egg-rr57.5%

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

    if -5.59999999999999992e-5 < im < 2.05e9

    1. Initial program 32.0%

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

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

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

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

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

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

    if 2.05e9 < im < 1.6e105

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.6 \cdot 10^{-5}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)\\ \mathbf{elif}\;im \leq 2050000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+105}:\\ \;\;\;\;im \cdot \left(0.16666666666666666 \cdot {re}^{3} - re\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)\\ \end{array} \]

Alternative 6: 77.5% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)\\ \mathbf{if}\;im \leq -0.000105:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.5 \cdot 10^{+29}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+105}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (*
          0.5
          (+
           (* re (* im (* im (* im -0.3333333333333333))))
           (* re (* im -2.0))))))
   (if (<= im -0.000105)
     t_0
     (if (<= im 1.5e+29)
       (* im (- (sin re)))
       (if (<= im 1.6e+105)
         (* 0.16666666666666666 (* im (pow re 3.0)))
         t_0)))))
double code(double re, double im) {
	double t_0 = 0.5 * ((re * (im * (im * (im * -0.3333333333333333)))) + (re * (im * -2.0)));
	double tmp;
	if (im <= -0.000105) {
		tmp = t_0;
	} else if (im <= 1.5e+29) {
		tmp = im * -sin(re);
	} else if (im <= 1.6e+105) {
		tmp = 0.16666666666666666 * (im * pow(re, 3.0));
	} 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.5d0 * ((re * (im * (im * (im * (-0.3333333333333333d0))))) + (re * (im * (-2.0d0))))
    if (im <= (-0.000105d0)) then
        tmp = t_0
    else if (im <= 1.5d+29) then
        tmp = im * -sin(re)
    else if (im <= 1.6d+105) then
        tmp = 0.16666666666666666d0 * (im * (re ** 3.0d0))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * ((re * (im * (im * (im * -0.3333333333333333)))) + (re * (im * -2.0)));
	double tmp;
	if (im <= -0.000105) {
		tmp = t_0;
	} else if (im <= 1.5e+29) {
		tmp = im * -Math.sin(re);
	} else if (im <= 1.6e+105) {
		tmp = 0.16666666666666666 * (im * Math.pow(re, 3.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * ((re * (im * (im * (im * -0.3333333333333333)))) + (re * (im * -2.0)))
	tmp = 0
	if im <= -0.000105:
		tmp = t_0
	elif im <= 1.5e+29:
		tmp = im * -math.sin(re)
	elif im <= 1.6e+105:
		tmp = 0.16666666666666666 * (im * math.pow(re, 3.0))
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(Float64(re * Float64(im * Float64(im * Float64(im * -0.3333333333333333)))) + Float64(re * Float64(im * -2.0))))
	tmp = 0.0
	if (im <= -0.000105)
		tmp = t_0;
	elseif (im <= 1.5e+29)
		tmp = Float64(im * Float64(-sin(re)));
	elseif (im <= 1.6e+105)
		tmp = Float64(0.16666666666666666 * Float64(im * (re ^ 3.0)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * ((re * (im * (im * (im * -0.3333333333333333)))) + (re * (im * -2.0)));
	tmp = 0.0;
	if (im <= -0.000105)
		tmp = t_0;
	elseif (im <= 1.5e+29)
		tmp = im * -sin(re);
	elseif (im <= 1.6e+105)
		tmp = 0.16666666666666666 * (im * (re ^ 3.0));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[(re * N[(im * N[(im * N[(im * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(re * N[(im * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -0.000105], t$95$0, If[LessEqual[im, 1.5e+29], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.6e+105], N[(0.16666666666666666 * N[(im * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)\\
\mathbf{if}\;im \leq -0.000105:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 1.6 \cdot 10^{+105}:\\
\;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.05e-4 or 1.6e105 < im

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto 0.5 \cdot \left(-0.3333333333333333 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(im \cdot im\right)\right)} + -2 \cdot \left(re \cdot im\right)\right) \]
      3. *-commutative51.3%

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-in51.3%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) + \left(re \cdot im\right) \cdot -2\right)} \]
      2. associate-*l*57.5%

        \[\leadsto 0.5 \cdot \left(\color{blue}{re \cdot \left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right)} + \left(re \cdot im\right) \cdot -2\right) \]
      3. *-commutative57.5%

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

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

        \[\leadsto 0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + \color{blue}{re \cdot \left(im \cdot -2\right)}\right) \]
    7. Applied egg-rr57.5%

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

    if -1.05e-4 < im < 1.5e29

    1. Initial program 34.6%

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

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

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

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

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

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

    if 1.5e29 < im < 1.6e105

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

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

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

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

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

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

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

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

      \[\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. associate-*r*2.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -0.000105:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)\\ \mathbf{elif}\;im \leq 1.5 \cdot 10^{+29}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+105}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)\\ \end{array} \]

Alternative 7: 76.9% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -5.6 \cdot 10^{-5} \lor \neg \left(im \leq 8.2 \cdot 10^{+79}\right):\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -5.6e-5) (not (<= im 8.2e+79)))
   (*
    0.5
    (+ (* re (* im (* im (* im -0.3333333333333333)))) (* re (* im -2.0))))
   (* im (- (sin re)))))
double code(double re, double im) {
	double tmp;
	if ((im <= -5.6e-5) || !(im <= 8.2e+79)) {
		tmp = 0.5 * ((re * (im * (im * (im * -0.3333333333333333)))) + (re * (im * -2.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 <= (-5.6d-5)) .or. (.not. (im <= 8.2d+79))) then
        tmp = 0.5d0 * ((re * (im * (im * (im * (-0.3333333333333333d0))))) + (re * (im * (-2.0d0))))
    else
        tmp = im * -sin(re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -5.6e-5) || !(im <= 8.2e+79)) {
		tmp = 0.5 * ((re * (im * (im * (im * -0.3333333333333333)))) + (re * (im * -2.0)));
	} else {
		tmp = im * -Math.sin(re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -5.6e-5) or not (im <= 8.2e+79):
		tmp = 0.5 * ((re * (im * (im * (im * -0.3333333333333333)))) + (re * (im * -2.0)))
	else:
		tmp = im * -math.sin(re)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -5.6e-5) || !(im <= 8.2e+79))
		tmp = Float64(0.5 * Float64(Float64(re * Float64(im * Float64(im * Float64(im * -0.3333333333333333)))) + Float64(re * Float64(im * -2.0))));
	else
		tmp = Float64(im * Float64(-sin(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -5.6e-5) || ~((im <= 8.2e+79)))
		tmp = 0.5 * ((re * (im * (im * (im * -0.3333333333333333)))) + (re * (im * -2.0)));
	else
		tmp = im * -sin(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -5.6e-5], N[Not[LessEqual[im, 8.2e+79]], $MachinePrecision]], N[(0.5 * N[(N[(re * N[(im * N[(im * N[(im * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(re * N[(im * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.6 \cdot 10^{-5} \lor \neg \left(im \leq 8.2 \cdot 10^{+79}\right):\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -5.59999999999999992e-5 or 8.2e79 < im

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto 0.5 \cdot \left(-0.3333333333333333 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(im \cdot im\right)\right)} + -2 \cdot \left(re \cdot im\right)\right) \]
      3. *-commutative49.6%

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-in49.6%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) + \left(re \cdot im\right) \cdot -2\right)} \]
      2. associate-*l*55.4%

        \[\leadsto 0.5 \cdot \left(\color{blue}{re \cdot \left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right)} + \left(re \cdot im\right) \cdot -2\right) \]
      3. *-commutative55.4%

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

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

        \[\leadsto 0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + \color{blue}{re \cdot \left(im \cdot -2\right)}\right) \]
    7. Applied egg-rr55.4%

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

    if -5.59999999999999992e-5 < im < 8.2e79

    1. Initial program 39.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.6 \cdot 10^{-5} \lor \neg \left(im \leq 8.2 \cdot 10^{+79}\right):\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 8: 53.5% accurate, 18.1× speedup?

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

\\
0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)
\end{array}
Derivation
  1. Initial program 66.2%

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\left(-0.3333333333333333 \cdot \left(re \cdot {im}^{3}\right) + -2 \cdot \left(re \cdot im\right)\right)} \]
  4. Step-by-step derivation
    1. cube-mult50.9%

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

      \[\leadsto 0.5 \cdot \left(-0.3333333333333333 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(im \cdot im\right)\right)} + -2 \cdot \left(re \cdot im\right)\right) \]
    3. *-commutative48.3%

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

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
  6. Step-by-step derivation
    1. distribute-lft-in48.3%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) + \left(re \cdot im\right) \cdot -2\right)} \]
    2. associate-*l*50.9%

      \[\leadsto 0.5 \cdot \left(\color{blue}{re \cdot \left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right)} + \left(re \cdot im\right) \cdot -2\right) \]
    3. *-commutative50.9%

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

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

      \[\leadsto 0.5 \cdot \left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + \color{blue}{re \cdot \left(im \cdot -2\right)}\right) \]
  7. Applied egg-rr50.9%

    \[\leadsto 0.5 \cdot \color{blue}{\left(re \cdot \left(im \cdot \left(im \cdot \left(im \cdot -0.3333333333333333\right)\right)\right) + re \cdot \left(im \cdot -2\right)\right)} \]
  8. Final simplification50.9%

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

Alternative 9: 50.3% accurate, 23.7× speedup?

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

\\
0.5 \cdot \left(\left(im \cdot re\right) \cdot \left(-2 + -0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right)
\end{array}
Derivation
  1. Initial program 66.2%

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\left(-0.3333333333333333 \cdot \left(re \cdot {im}^{3}\right) + -2 \cdot \left(re \cdot im\right)\right)} \]
  4. Step-by-step derivation
    1. cube-mult50.9%

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

      \[\leadsto 0.5 \cdot \left(-0.3333333333333333 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(im \cdot im\right)\right)} + -2 \cdot \left(re \cdot im\right)\right) \]
    3. *-commutative48.3%

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

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
  6. Final simplification48.3%

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

Alternative 10: 33.2% accurate, 77.0× speedup?

\[\begin{array}{l} \\ \left(-im\right) \cdot re \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(Float64(-im) * re)
end
function tmp = code(re, im)
	tmp = -im * re;
end
code[re_, im_] := N[((-im) * re), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 2.7% accurate, 308.0× speedup?

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

\\
-1.5
\end{array}
Derivation
  1. Initial program 66.2%

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

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

    \[\leadsto 0.5 \cdot \color{blue}{-3} \]
  4. Final simplification3.0%

    \[\leadsto -1.5 \]

Alternative 12: 2.8% accurate, 308.0× speedup?

\[\begin{array}{l} \\ -4.96145150637606 \cdot 10^{-8} \end{array} \]
(FPCore (re im) :precision binary64 -4.96145150637606e-8)
double code(double re, double im) {
	return -4.96145150637606e-8;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = -4.96145150637606d-8
end function
public static double code(double re, double im) {
	return -4.96145150637606e-8;
}
def code(re, im):
	return -4.96145150637606e-8
function code(re, im)
	return -4.96145150637606e-8
end
function tmp = code(re, im)
	tmp = -4.96145150637606e-8;
end
code[re_, im_] := -4.96145150637606e-8
\begin{array}{l}

\\
-4.96145150637606 \cdot 10^{-8}
\end{array}
Derivation
  1. Initial program 66.2%

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

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

    \[\leadsto 0.5 \cdot \color{blue}{-9.92290301275212 \cdot 10^{-8}} \]
  4. Final simplification3.0%

    \[\leadsto -4.96145150637606 \cdot 10^{-8} \]

Alternative 13: 14.2% accurate, 308.0× speedup?

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

\\
0
\end{array}
Derivation
  1. Initial program 66.2%

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

    \[\leadsto \color{blue}{0.5 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot re\right)} \]
  3. Applied egg-rr14.7%

    \[\leadsto 0.5 \cdot \color{blue}{0} \]
  4. Final simplification14.7%

    \[\leadsto 0 \]

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