math.cos on complex, imaginary part

Percentage Accurate: 65.3% → 99.6%
Time: 11.7s
Alternatives: 12
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 12 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.3% 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.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 0.01\right):\\ \;\;\;\;t_0 \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 + {im}^{5} \cdot -0.008333333333333333\right) - im \cdot \sin re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 0.01)))
     (* t_0 (* 0.5 (sin re)))
     (-
      (*
       (sin re)
       (+
        (* (pow im 3.0) -0.16666666666666666)
        (* (pow im 5.0) -0.008333333333333333)))
      (* im (sin re))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 0.01)) {
		tmp = t_0 * (0.5 * sin(re));
	} else {
		tmp = (sin(re) * ((pow(im, 3.0) * -0.16666666666666666) + (pow(im, 5.0) * -0.008333333333333333))) - (im * sin(re));
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 0.01)) {
		tmp = t_0 * (0.5 * Math.sin(re));
	} else {
		tmp = (Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) + (Math.pow(im, 5.0) * -0.008333333333333333))) - (im * Math.sin(re));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 0.01):
		tmp = t_0 * (0.5 * math.sin(re))
	else:
		tmp = (math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) + (math.pow(im, 5.0) * -0.008333333333333333))) - (im * math.sin(re))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 0.01))
		tmp = Float64(t_0 * Float64(0.5 * sin(re)));
	else
		tmp = Float64(Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) + Float64((im ^ 5.0) * -0.008333333333333333))) - Float64(im * sin(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 0.01)))
		tmp = t_0 * (0.5 * sin(re));
	else
		tmp = (sin(re) * (((im ^ 3.0) * -0.16666666666666666) + ((im ^ 5.0) * -0.008333333333333333))) - (im * sin(re));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 0.01]], $MachinePrecision]], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 30.0%

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

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

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

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

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

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

        \[\leadsto \left(\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \sin re + \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \sin re}\right) - im \cdot \sin re \]
      6. distribute-rgt-out99.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -\infty \lor \neg \left(e^{-im} - e^{im} \leq 0.01\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}^{5} \cdot -0.008333333333333333\right) - im \cdot \sin re\\ \end{array} \]

Alternative 2: 99.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ t_1 := e^{-im} - e^{im}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 0.01\right):\\ \;\;\;\;t_1 \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(im \cdot -2 + \left({im}^{3} \cdot -0.3333333333333333 + {im}^{5} \cdot -0.016666666666666666\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (sin re))) (t_1 (- (exp (- im)) (exp im))))
   (if (or (<= t_1 (- INFINITY)) (not (<= t_1 0.01)))
     (* t_1 t_0)
     (*
      t_0
      (+
       (* im -2.0)
       (+
        (* (pow im 3.0) -0.3333333333333333)
        (* (pow im 5.0) -0.016666666666666666)))))))
double code(double re, double im) {
	double t_0 = 0.5 * sin(re);
	double t_1 = exp(-im) - exp(im);
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 0.01)) {
		tmp = t_1 * t_0;
	} else {
		tmp = t_0 * ((im * -2.0) + ((pow(im, 3.0) * -0.3333333333333333) + (pow(im, 5.0) * -0.016666666666666666)));
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = 0.5 * Math.sin(re);
	double t_1 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 0.01)) {
		tmp = t_1 * t_0;
	} else {
		tmp = t_0 * ((im * -2.0) + ((Math.pow(im, 3.0) * -0.3333333333333333) + (Math.pow(im, 5.0) * -0.016666666666666666)));
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * math.sin(re)
	t_1 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_1 <= -math.inf) or not (t_1 <= 0.01):
		tmp = t_1 * t_0
	else:
		tmp = t_0 * ((im * -2.0) + ((math.pow(im, 3.0) * -0.3333333333333333) + (math.pow(im, 5.0) * -0.016666666666666666)))
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * sin(re))
	t_1 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 0.01))
		tmp = Float64(t_1 * t_0);
	else
		tmp = Float64(t_0 * Float64(Float64(im * -2.0) + Float64(Float64((im ^ 3.0) * -0.3333333333333333) + Float64((im ^ 5.0) * -0.016666666666666666))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * sin(re);
	t_1 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_1 <= -Inf) || ~((t_1 <= 0.01)))
		tmp = t_1 * t_0;
	else
		tmp = t_0 * ((im * -2.0) + (((im ^ 3.0) * -0.3333333333333333) + ((im ^ 5.0) * -0.016666666666666666)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 0.01]], $MachinePrecision]], N[(t$95$1 * t$95$0), $MachinePrecision], N[(t$95$0 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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


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

    1. Initial program 30.0%

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

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

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

Alternative 3: 99.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 2 \cdot 10^{-6}\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 (- INFINITY)) (not (<= t_0 2e-6)))
     (* 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 <= -((double) INFINITY)) || !(t_0 <= 2e-6)) {
		tmp = t_0 * (0.5 * sin(re));
	} else {
		tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 2e-6)) {
		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 <= -math.inf) or not (t_0 <= 2e-6):
		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 <= Float64(-Inf)) || !(t_0 <= 2e-6))
		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 <= -Inf) || ~((t_0 <= 2e-6)))
		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, (-Infinity)], N[Not[LessEqual[t$95$0, 2e-6]], $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 -\infty \lor \neg \left(t_0 \leq 2 \cdot 10^{-6}\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)) < -inf.0 or 1.99999999999999991e-6 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 99.9%

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

    if -inf.0 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < 1.99999999999999991e-6

    1. Initial program 29.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -2.8 \cdot 10^{+122} \lor \neg \left(im \leq -0.0031\right) \land \left(im \leq 0.235 \lor \neg \left(im \leq 5.6 \cdot 10^{+97}\right)\right):\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -2.8e+122)
         (and (not (<= im -0.0031)) (or (<= im 0.235) (not (<= im 5.6e+97)))))
   (* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
   (* (- (exp (- im)) (exp im)) (* 0.5 re))))
double code(double re, double im) {
	double tmp;
	if ((im <= -2.8e+122) || (!(im <= -0.0031) && ((im <= 0.235) || !(im <= 5.6e+97)))) {
		tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else {
		tmp = (exp(-im) - exp(im)) * (0.5 * 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.8d+122)) .or. (.not. (im <= (-0.0031d0))) .and. (im <= 0.235d0) .or. (.not. (im <= 5.6d+97))) then
        tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    else
        tmp = (exp(-im) - exp(im)) * (0.5d0 * re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -2.8e+122) || (!(im <= -0.0031) && ((im <= 0.235) || !(im <= 5.6e+97)))) {
		tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else {
		tmp = (Math.exp(-im) - Math.exp(im)) * (0.5 * re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -2.8e+122) or (not (im <= -0.0031) and ((im <= 0.235) or not (im <= 5.6e+97))):
		tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	else:
		tmp = (math.exp(-im) - math.exp(im)) * (0.5 * re)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -2.8e+122) || (!(im <= -0.0031) && ((im <= 0.235) || !(im <= 5.6e+97))))
		tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	else
		tmp = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 * re));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -2.8e+122) || (~((im <= -0.0031)) && ((im <= 0.235) || ~((im <= 5.6e+97)))))
		tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	else
		tmp = (exp(-im) - exp(im)) * (0.5 * re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -2.8e+122], And[N[Not[LessEqual[im, -0.0031]], $MachinePrecision], Or[LessEqual[im, 0.235], N[Not[LessEqual[im, 5.6e+97]], $MachinePrecision]]]], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.8 \cdot 10^{+122} \lor \neg \left(im \leq -0.0031\right) \land \left(im \leq 0.235 \lor \neg \left(im \leq 5.6 \cdot 10^{+97}\right)\right):\\
\;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -2.8e122 or -0.00309999999999999989 < im < 0.23499999999999999 or 5.5999999999999998e97 < im

    1. Initial program 58.8%

      \[\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(im \cdot \sin re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \sin re\right)} \]
    3. Step-by-step derivation
      1. +-commutative99.1%

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

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

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

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

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

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

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

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

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

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

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

    if -2.8e122 < im < -0.00309999999999999989 or 0.23499999999999999 < im < 5.5999999999999998e97

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.8 \cdot 10^{+122} \lor \neg \left(im \leq -0.0031\right) \land \left(im \leq 0.235 \lor \neg \left(im \leq 5.6 \cdot 10^{+97}\right)\right):\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \end{array} \]

Alternative 5: 79.9% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.00027:\\
\;\;\;\;re \cdot \left(\sqrt{{im}^{6} \cdot 0.027777777777777776} - im\right)\\

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

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


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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt54.8%

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

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

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

        \[\leadsto re \cdot \left(\sqrt{\color{blue}{\left({im}^{3} \cdot {im}^{3}\right) \cdot \left(-0.16666666666666666 \cdot -0.16666666666666666\right)}} - im\right) \]
      5. pow-sqr61.8%

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

        \[\leadsto re \cdot \left(\sqrt{{im}^{\color{blue}{6}} \cdot \left(-0.16666666666666666 \cdot -0.16666666666666666\right)} - im\right) \]
      7. metadata-eval61.8%

        \[\leadsto re \cdot \left(\sqrt{{im}^{6} \cdot \color{blue}{0.027777777777777776}} - im\right) \]
    9. Applied egg-rr61.8%

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

    if -2.70000000000000003e-4 < im < 2.4e23

    1. Initial program 31.7%

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

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

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

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

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

    if 2.4e23 < im

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto re \cdot \left(\color{blue}{\frac{\left(-0.16666666666666666 \cdot {im}^{2}\right) \cdot \left({im}^{2} + 0\right)}{im}} - im\right) \]
    9. Step-by-step derivation
      1. associate-/l*57.5%

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

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

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

        \[\leadsto re \cdot \left(\frac{\color{blue}{-0.16666666666666666 \cdot \left({im}^{2} \cdot {im}^{2}\right)}}{im} - im\right) \]
      5. unpow260.7%

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

        \[\leadsto re \cdot \left(\frac{-0.16666666666666666 \cdot \color{blue}{\left(im \cdot \left(im \cdot {im}^{2}\right)\right)}}{im} - im\right) \]
      7. unpow260.7%

        \[\leadsto re \cdot \left(\frac{-0.16666666666666666 \cdot \left(im \cdot \left(im \cdot \color{blue}{\left(im \cdot im\right)}\right)\right)}{im} - im\right) \]
      8. cube-mult60.7%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -0.00027:\\ \;\;\;\;re \cdot \left(\sqrt{{im}^{6} \cdot 0.027777777777777776} - im\right)\\ \mathbf{elif}\;im \leq 2.4 \cdot 10^{+23}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(\frac{-0.16666666666666666}{\frac{im}{im \cdot {im}^{3}}} - im\right)\\ \end{array} \]

Alternative 6: 84.3% accurate, 1.5× speedup?

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

\\
\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)
\end{array}
Derivation
  1. Initial program 65.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 78.8% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.0031 \lor \neg \left(im \leq 4.6 \cdot 10^{+22}\right):\\
\;\;\;\;re \cdot \left(\frac{-0.16666666666666666}{\frac{im}{im \cdot {im}^{3}}} - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -0.00309999999999999989 or 4.6000000000000004e22 < 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 74.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto re \cdot \left(\color{blue}{\frac{\left(-0.16666666666666666 \cdot {im}^{2}\right) \cdot \left({im}^{2} + 0\right)}{im}} - im\right) \]
    9. Step-by-step derivation
      1. associate-/l*56.1%

        \[\leadsto re \cdot \left(\color{blue}{\frac{-0.16666666666666666 \cdot {im}^{2}}{\frac{im}{{im}^{2} + 0}}} - im\right) \]
      2. +-rgt-identity56.1%

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

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

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

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

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

        \[\leadsto re \cdot \left(\frac{-0.16666666666666666 \cdot \left(im \cdot \left(im \cdot \color{blue}{\left(im \cdot im\right)}\right)\right)}{im} - im\right) \]
      8. cube-mult58.3%

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

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

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

    if -0.00309999999999999989 < im < 4.6000000000000004e22

    1. Initial program 31.7%

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

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

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

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

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

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

Alternative 8: 77.0% accurate, 2.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -0.00239999999999999979 or 7.5000000000000002e22 < 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 74.2%

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

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

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

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

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

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

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

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

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

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

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

    if -0.00239999999999999979 < im < 7.5000000000000002e22

    1. Initial program 31.7%

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

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

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

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

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

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

Alternative 9: 76.8% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -1.32 \cdot 10^{+51} \lor \neg \left(im \leq 3.75 \cdot 10^{+22}\right):\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -1.32e+51) (not (<= im 3.75e+22)))
   (* -0.16666666666666666 (* re (pow im 3.0)))
   (* (- im) (sin re))))
double code(double re, double im) {
	double tmp;
	if ((im <= -1.32e+51) || !(im <= 3.75e+22)) {
		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.32d+51)) .or. (.not. (im <= 3.75d+22))) 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.32e+51) || !(im <= 3.75e+22)) {
		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.32e+51) or not (im <= 3.75e+22):
		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.32e+51) || !(im <= 3.75e+22))
		tmp = Float64(-0.16666666666666666 * Float64(re * (im ^ 3.0)));
	else
		tmp = Float64(Float64(-im) * sin(re));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -1.32e+51) || ~((im <= 3.75e+22)))
		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.32e+51], N[Not[LessEqual[im, 3.75e+22]], $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.32 \cdot 10^{+51} \lor \neg \left(im \leq 3.75 \cdot 10^{+22}\right):\\
\;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -1.32e51 or 3.7500000000000001e22 < im

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.32e51 < im < 3.7500000000000001e22

    1. Initial program 37.1%

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

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

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

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

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

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

Alternative 10: 76.8% accurate, 2.8× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5e50 < im < 1.85000000000000006e23

    1. Initial program 37.1%

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

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

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

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

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

    if 1.85000000000000006e23 < im

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 57.2% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.6 \cdot 10^{+61} \lor \neg \left(im \leq 6 \cdot 10^{+22}\right):\\
\;\;\;\;\left(-im\right) \cdot re\\

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


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

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

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

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

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

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

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

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

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

    if -3.6000000000000001e61 < im < 6e22

    1. Initial program 38.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.6 \cdot 10^{+61} \lor \neg \left(im \leq 6 \cdot 10^{+22}\right):\\ \;\;\;\;\left(-im\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \end{array} \]

Alternative 12: 33.5% 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 65.8%

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

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

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

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

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

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

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

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

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

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

Developer target: 99.8% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\sin re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023305 
(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))))