math.cos on complex, imaginary part

Percentage Accurate: 65.5% → 99.7%
Time: 16.7s
Alternatives: 15
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 15 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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.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.02\right):\\ \;\;\;\;t_1 \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(im \cdot -2 + \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\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.02)))
     (* t_1 t_0)
     (*
      t_0
      (+
       (* im -2.0)
       (+
        (* -0.3333333333333333 (pow im 3.0))
        (* -0.016666666666666666 (pow im 5.0))))))))
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.02)) {
		tmp = t_1 * t_0;
	} else {
		tmp = t_0 * ((im * -2.0) + ((-0.3333333333333333 * pow(im, 3.0)) + (-0.016666666666666666 * pow(im, 5.0))));
	}
	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.02)) {
		tmp = t_1 * t_0;
	} else {
		tmp = t_0 * ((im * -2.0) + ((-0.3333333333333333 * Math.pow(im, 3.0)) + (-0.016666666666666666 * Math.pow(im, 5.0))));
	}
	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.02):
		tmp = t_1 * t_0
	else:
		tmp = t_0 * ((im * -2.0) + ((-0.3333333333333333 * math.pow(im, 3.0)) + (-0.016666666666666666 * math.pow(im, 5.0))))
	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.02))
		tmp = Float64(t_1 * t_0);
	else
		tmp = Float64(t_0 * Float64(Float64(im * -2.0) + Float64(Float64(-0.3333333333333333 * (im ^ 3.0)) + Float64(-0.016666666666666666 * (im ^ 5.0)))));
	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.02)))
		tmp = t_1 * t_0;
	else
		tmp = t_0 * ((im * -2.0) + ((-0.3333333333333333 * (im ^ 3.0)) + (-0.016666666666666666 * (im ^ 5.0))));
	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.02]], $MachinePrecision]], N[(t$95$1 * t$95$0), $MachinePrecision], N[(t$95$0 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.016666666666666666 * N[Power[im, 5.0], $MachinePrecision]), $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.02\right):\\
\;\;\;\;t_1 \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(im \cdot -2 + \left(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\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.0200000000000000004 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 99.2%

      \[\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.0200000000000000004

    1. Initial program 32.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -\infty \lor \neg \left(e^{-im} - e^{im} \leq 0.02\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(-0.3333333333333333 \cdot {im}^{3} + -0.016666666666666666 \cdot {im}^{5}\right)\right)\\ \end{array} \]

Alternative 2: 99.2% 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^{-15}\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-15)))
     (* 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-15)) {
		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-15)) {
		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-15):
		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-15))
		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-15)))
		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-15]], $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^{-15}\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 2.0000000000000002e-15 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 99.2%

      \[\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)) < 2.0000000000000002e-15

    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 99.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. +-commutative99.8%

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

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

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

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

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

        \[\leadsto \sin re \cdot \left(\color{blue}{{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.5%

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ t_1 := -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \mathbf{if}\;im \leq -2.1 \cdot 10^{+98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.058:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.14:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (- (exp (- im)) (exp im)) (* 0.5 re)))
        (t_1 (* -0.008333333333333333 (* (sin re) (pow im 5.0)))))
   (if (<= im -2.1e+98)
     t_1
     (if (<= im -0.058)
       t_0
       (if (<= im 0.14)
         (* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
         (if (<= im 4.4e+61) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = (exp(-im) - exp(im)) * (0.5 * re);
	double t_1 = -0.008333333333333333 * (sin(re) * pow(im, 5.0));
	double tmp;
	if (im <= -2.1e+98) {
		tmp = t_1;
	} else if (im <= -0.058) {
		tmp = t_0;
	} else if (im <= 0.14) {
		tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 4.4e+61) {
		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 = (exp(-im) - exp(im)) * (0.5d0 * re)
    t_1 = (-0.008333333333333333d0) * (sin(re) * (im ** 5.0d0))
    if (im <= (-2.1d+98)) then
        tmp = t_1
    else if (im <= (-0.058d0)) then
        tmp = t_0
    else if (im <= 0.14d0) then
        tmp = sin(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    else if (im <= 4.4d+61) 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 = (Math.exp(-im) - Math.exp(im)) * (0.5 * re);
	double t_1 = -0.008333333333333333 * (Math.sin(re) * Math.pow(im, 5.0));
	double tmp;
	if (im <= -2.1e+98) {
		tmp = t_1;
	} else if (im <= -0.058) {
		tmp = t_0;
	} else if (im <= 0.14) {
		tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 4.4e+61) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.exp(-im) - math.exp(im)) * (0.5 * re)
	t_1 = -0.008333333333333333 * (math.sin(re) * math.pow(im, 5.0))
	tmp = 0
	if im <= -2.1e+98:
		tmp = t_1
	elif im <= -0.058:
		tmp = t_0
	elif im <= 0.14:
		tmp = math.sin(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	elif im <= 4.4e+61:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 * re))
	t_1 = Float64(-0.008333333333333333 * Float64(sin(re) * (im ^ 5.0)))
	tmp = 0.0
	if (im <= -2.1e+98)
		tmp = t_1;
	elseif (im <= -0.058)
		tmp = t_0;
	elseif (im <= 0.14)
		tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	elseif (im <= 4.4e+61)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (exp(-im) - exp(im)) * (0.5 * re);
	t_1 = -0.008333333333333333 * (sin(re) * (im ^ 5.0));
	tmp = 0.0;
	if (im <= -2.1e+98)
		tmp = t_1;
	elseif (im <= -0.058)
		tmp = t_0;
	elseif (im <= 0.14)
		tmp = sin(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	elseif (im <= 4.4e+61)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.1e+98], t$95$1, If[LessEqual[im, -0.058], t$95$0, If[LessEqual[im, 0.14], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.4e+61], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
t_1 := -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+98}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.10000000000000004e98 or 4.4000000000000001e61 < 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 \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. Taylor expanded in im around inf 100.0%

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

    if -2.10000000000000004e98 < im < -0.0580000000000000029 or 0.14000000000000001 < im < 4.4000000000000001e61

    1. Initial program 97.1%

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

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

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

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

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

    if -0.0580000000000000029 < im < 0.14000000000000001

    1. Initial program 32.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.1 \cdot 10^{+98}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq -0.058:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 0.14:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \end{array} \]

Alternative 4: 93.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := re \cdot \sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}\\ t_1 := -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \mathbf{if}\;im \leq -2.1 \cdot 10^{+98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -64000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 90000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* re (cbrt (* (pow im 15.0) -5.787037037037037e-7))))
        (t_1 (* -0.008333333333333333 (* (sin re) (pow im 5.0)))))
   (if (<= im -2.1e+98)
     t_1
     (if (<= im -64000.0)
       t_0
       (if (<= im 90000.0)
         (* im (- (sin re)))
         (if (<= im 4.4e+61) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = re * cbrt((pow(im, 15.0) * -5.787037037037037e-7));
	double t_1 = -0.008333333333333333 * (sin(re) * pow(im, 5.0));
	double tmp;
	if (im <= -2.1e+98) {
		tmp = t_1;
	} else if (im <= -64000.0) {
		tmp = t_0;
	} else if (im <= 90000.0) {
		tmp = im * -sin(re);
	} else if (im <= 4.4e+61) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = re * Math.cbrt((Math.pow(im, 15.0) * -5.787037037037037e-7));
	double t_1 = -0.008333333333333333 * (Math.sin(re) * Math.pow(im, 5.0));
	double tmp;
	if (im <= -2.1e+98) {
		tmp = t_1;
	} else if (im <= -64000.0) {
		tmp = t_0;
	} else if (im <= 90000.0) {
		tmp = im * -Math.sin(re);
	} else if (im <= 4.4e+61) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(re * cbrt(Float64((im ^ 15.0) * -5.787037037037037e-7)))
	t_1 = Float64(-0.008333333333333333 * Float64(sin(re) * (im ^ 5.0)))
	tmp = 0.0
	if (im <= -2.1e+98)
		tmp = t_1;
	elseif (im <= -64000.0)
		tmp = t_0;
	elseif (im <= 90000.0)
		tmp = Float64(im * Float64(-sin(re)));
	elseif (im <= 4.4e+61)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(re * N[Power[N[(N[Power[im, 15.0], $MachinePrecision] * -5.787037037037037e-7), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.1e+98], t$95$1, If[LessEqual[im, -64000.0], t$95$0, If[LessEqual[im, 90000.0], N[(im * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 4.4e+61], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := re \cdot \sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}\\
t_1 := -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+98}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.10000000000000004e98 or 4.4000000000000001e61 < 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 \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. Taylor expanded in im around inf 100.0%

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

    if -2.10000000000000004e98 < im < -64000 or 9e4 < im < 4.4000000000000001e61

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

      \[\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. Taylor expanded in im around inf 28.1%

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

      \[\leadsto \color{blue}{-0.008333333333333333 \cdot \left({im}^{5} \cdot re\right)} \]
    5. Step-by-step derivation
      1. *-commutative37.8%

        \[\leadsto \color{blue}{\left({im}^{5} \cdot re\right) \cdot -0.008333333333333333} \]
      2. *-commutative37.8%

        \[\leadsto \color{blue}{\left(re \cdot {im}^{5}\right)} \cdot -0.008333333333333333 \]
      3. associate-*l*37.8%

        \[\leadsto \color{blue}{re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)} \]
    6. Simplified37.8%

      \[\leadsto \color{blue}{re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)} \]
    7. Step-by-step derivation
      1. add-cbrt-cube75.6%

        \[\leadsto re \cdot \color{blue}{\sqrt[3]{\left(\left({im}^{5} \cdot -0.008333333333333333\right) \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\right) \cdot \left({im}^{5} \cdot -0.008333333333333333\right)}} \]
      2. pow1/353.9%

        \[\leadsto re \cdot \color{blue}{{\left(\left(\left({im}^{5} \cdot -0.008333333333333333\right) \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\right) \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\right)}^{0.3333333333333333}} \]
      3. pow353.9%

        \[\leadsto re \cdot {\color{blue}{\left({\left({im}^{5} \cdot -0.008333333333333333\right)}^{3}\right)}}^{0.3333333333333333} \]
      4. unpow-prod-down53.9%

        \[\leadsto re \cdot {\color{blue}{\left({\left({im}^{5}\right)}^{3} \cdot {-0.008333333333333333}^{3}\right)}}^{0.3333333333333333} \]
      5. pow353.9%

        \[\leadsto re \cdot {\left(\color{blue}{\left(\left({im}^{5} \cdot {im}^{5}\right) \cdot {im}^{5}\right)} \cdot {-0.008333333333333333}^{3}\right)}^{0.3333333333333333} \]
      6. pow-prod-up53.9%

        \[\leadsto re \cdot {\left(\left(\color{blue}{{im}^{\left(5 + 5\right)}} \cdot {im}^{5}\right) \cdot {-0.008333333333333333}^{3}\right)}^{0.3333333333333333} \]
      7. metadata-eval53.9%

        \[\leadsto re \cdot {\left(\left({im}^{\color{blue}{10}} \cdot {im}^{5}\right) \cdot {-0.008333333333333333}^{3}\right)}^{0.3333333333333333} \]
      8. pow-prod-up53.9%

        \[\leadsto re \cdot {\left(\color{blue}{{im}^{\left(10 + 5\right)}} \cdot {-0.008333333333333333}^{3}\right)}^{0.3333333333333333} \]
      9. metadata-eval53.9%

        \[\leadsto re \cdot {\left({im}^{\color{blue}{15}} \cdot {-0.008333333333333333}^{3}\right)}^{0.3333333333333333} \]
      10. metadata-eval53.9%

        \[\leadsto re \cdot {\left({im}^{15} \cdot \color{blue}{-5.787037037037037 \cdot 10^{-7}}\right)}^{0.3333333333333333} \]
    8. Applied egg-rr53.9%

      \[\leadsto re \cdot \color{blue}{{\left({im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}\right)}^{0.3333333333333333}} \]
    9. Step-by-step derivation
      1. unpow1/375.6%

        \[\leadsto re \cdot \color{blue}{\sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}} \]
    10. Simplified75.6%

      \[\leadsto re \cdot \color{blue}{\sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}} \]

    if -64000 < im < 9e4

    1. Initial program 33.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.1 \cdot 10^{+98}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq -64000:\\ \;\;\;\;re \cdot \sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}\\ \mathbf{elif}\;im \leq 90000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\ \;\;\;\;re \cdot \sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \end{array} \]

Alternative 5: 93.6% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := re \cdot \sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}\\ t_1 := -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \mathbf{if}\;im \leq -2.1 \cdot 10^{+98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -31000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 920:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* re (cbrt (* (pow im 15.0) -5.787037037037037e-7))))
        (t_1 (* -0.008333333333333333 (* (sin re) (pow im 5.0)))))
   (if (<= im -2.1e+98)
     t_1
     (if (<= im -31000.0)
       t_0
       (if (<= im 920.0)
         (* (sin re) (- (* (pow im 3.0) -0.16666666666666666) im))
         (if (<= im 4.4e+61) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = re * cbrt((pow(im, 15.0) * -5.787037037037037e-7));
	double t_1 = -0.008333333333333333 * (sin(re) * pow(im, 5.0));
	double tmp;
	if (im <= -2.1e+98) {
		tmp = t_1;
	} else if (im <= -31000.0) {
		tmp = t_0;
	} else if (im <= 920.0) {
		tmp = sin(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 4.4e+61) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = re * Math.cbrt((Math.pow(im, 15.0) * -5.787037037037037e-7));
	double t_1 = -0.008333333333333333 * (Math.sin(re) * Math.pow(im, 5.0));
	double tmp;
	if (im <= -2.1e+98) {
		tmp = t_1;
	} else if (im <= -31000.0) {
		tmp = t_0;
	} else if (im <= 920.0) {
		tmp = Math.sin(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 4.4e+61) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(re * cbrt(Float64((im ^ 15.0) * -5.787037037037037e-7)))
	t_1 = Float64(-0.008333333333333333 * Float64(sin(re) * (im ^ 5.0)))
	tmp = 0.0
	if (im <= -2.1e+98)
		tmp = t_1;
	elseif (im <= -31000.0)
		tmp = t_0;
	elseif (im <= 920.0)
		tmp = Float64(sin(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	elseif (im <= 4.4e+61)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(re * N[Power[N[(N[Power[im, 15.0], $MachinePrecision] * -5.787037037037037e-7), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.1e+98], t$95$1, If[LessEqual[im, -31000.0], t$95$0, If[LessEqual[im, 920.0], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.4e+61], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := re \cdot \sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}\\
t_1 := -0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\
\mathbf{if}\;im \leq -2.1 \cdot 10^{+98}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.10000000000000004e98 or 4.4000000000000001e61 < 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 \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. Taylor expanded in im around inf 100.0%

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

    if -2.10000000000000004e98 < im < -31000 or 920 < im < 4.4000000000000001e61

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

      \[\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. Taylor expanded in im around inf 28.1%

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

      \[\leadsto \color{blue}{-0.008333333333333333 \cdot \left({im}^{5} \cdot re\right)} \]
    5. Step-by-step derivation
      1. *-commutative37.8%

        \[\leadsto \color{blue}{\left({im}^{5} \cdot re\right) \cdot -0.008333333333333333} \]
      2. *-commutative37.8%

        \[\leadsto \color{blue}{\left(re \cdot {im}^{5}\right)} \cdot -0.008333333333333333 \]
      3. associate-*l*37.8%

        \[\leadsto \color{blue}{re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)} \]
    6. Simplified37.8%

      \[\leadsto \color{blue}{re \cdot \left({im}^{5} \cdot -0.008333333333333333\right)} \]
    7. Step-by-step derivation
      1. add-cbrt-cube75.6%

        \[\leadsto re \cdot \color{blue}{\sqrt[3]{\left(\left({im}^{5} \cdot -0.008333333333333333\right) \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\right) \cdot \left({im}^{5} \cdot -0.008333333333333333\right)}} \]
      2. pow1/353.9%

        \[\leadsto re \cdot \color{blue}{{\left(\left(\left({im}^{5} \cdot -0.008333333333333333\right) \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\right) \cdot \left({im}^{5} \cdot -0.008333333333333333\right)\right)}^{0.3333333333333333}} \]
      3. pow353.9%

        \[\leadsto re \cdot {\color{blue}{\left({\left({im}^{5} \cdot -0.008333333333333333\right)}^{3}\right)}}^{0.3333333333333333} \]
      4. unpow-prod-down53.9%

        \[\leadsto re \cdot {\color{blue}{\left({\left({im}^{5}\right)}^{3} \cdot {-0.008333333333333333}^{3}\right)}}^{0.3333333333333333} \]
      5. pow353.9%

        \[\leadsto re \cdot {\left(\color{blue}{\left(\left({im}^{5} \cdot {im}^{5}\right) \cdot {im}^{5}\right)} \cdot {-0.008333333333333333}^{3}\right)}^{0.3333333333333333} \]
      6. pow-prod-up53.9%

        \[\leadsto re \cdot {\left(\left(\color{blue}{{im}^{\left(5 + 5\right)}} \cdot {im}^{5}\right) \cdot {-0.008333333333333333}^{3}\right)}^{0.3333333333333333} \]
      7. metadata-eval53.9%

        \[\leadsto re \cdot {\left(\left({im}^{\color{blue}{10}} \cdot {im}^{5}\right) \cdot {-0.008333333333333333}^{3}\right)}^{0.3333333333333333} \]
      8. pow-prod-up53.9%

        \[\leadsto re \cdot {\left(\color{blue}{{im}^{\left(10 + 5\right)}} \cdot {-0.008333333333333333}^{3}\right)}^{0.3333333333333333} \]
      9. metadata-eval53.9%

        \[\leadsto re \cdot {\left({im}^{\color{blue}{15}} \cdot {-0.008333333333333333}^{3}\right)}^{0.3333333333333333} \]
      10. metadata-eval53.9%

        \[\leadsto re \cdot {\left({im}^{15} \cdot \color{blue}{-5.787037037037037 \cdot 10^{-7}}\right)}^{0.3333333333333333} \]
    8. Applied egg-rr53.9%

      \[\leadsto re \cdot \color{blue}{{\left({im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}\right)}^{0.3333333333333333}} \]
    9. Step-by-step derivation
      1. unpow1/375.6%

        \[\leadsto re \cdot \color{blue}{\sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}} \]
    10. Simplified75.6%

      \[\leadsto re \cdot \color{blue}{\sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}} \]

    if -31000 < im < 920

    1. Initial program 33.8%

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

      \[\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. +-commutative97.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.1 \cdot 10^{+98}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq -31000:\\ \;\;\;\;re \cdot \sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}\\ \mathbf{elif}\;im \leq 920:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+61}:\\ \;\;\;\;re \cdot \sqrt[3]{{im}^{15} \cdot -5.787037037037037 \cdot 10^{-7}}\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \end{array} \]

Alternative 6: 89.4% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.3 \lor \neg \left(im \leq 3.4\right):\\
\;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -3.2999999999999998 or 3.39999999999999991 < im

    1. Initial program 99.3%

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

      \[\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. Taylor expanded in im around inf 81.0%

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

    if -3.2999999999999998 < im < 3.39999999999999991

    1. Initial program 33.0%

      \[\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(im \cdot \sin re\right)} \]
    3. Step-by-step derivation
      1. associate-*r*98.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.3 \lor \neg \left(im \leq 3.4\right):\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 7: 89.4% accurate, 1.5× speedup?

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

\\
\sin re \cdot \left({im}^{5} \cdot -0.008333333333333333 - im\right)
\end{array}
Derivation
  1. Initial program 64.3%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Taylor expanded in im around 0 90.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. Taylor expanded in im around inf 90.2%

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(-2 \cdot im + \color{blue}{-0.016666666666666666 \cdot {im}^{5}}\right) \]
  4. Taylor expanded in im around 0 90.2%

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

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

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

      \[\leadsto \left(-im\right) \cdot \sin re + \color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \sin re} \]
    4. *-commutative90.2%

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

      \[\leadsto \color{blue}{\sin re \cdot \left(\left(-im\right) + {im}^{5} \cdot -0.008333333333333333\right)} \]
  6. Simplified90.2%

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

    \[\leadsto \color{blue}{\sin re \cdot \left(-0.008333333333333333 \cdot {im}^{5} - im\right)} \]
  8. Final simplification90.2%

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

Alternative 8: 81.0% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -47000 \lor \neg \left(im \leq 7500\right):\\
\;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -47000 or 7500 < im

    1. Initial program 100.0%

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

      \[\leadsto \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. Taylor expanded in im around inf 82.9%

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

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

    if -47000 < im < 7500

    1. Initial program 33.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -47000 \lor \neg \left(im \leq 7500\right):\\ \;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \end{array} \]

Alternative 9: 57.0% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -9.5 \cdot 10^{+57} \lor \neg \left(im \leq 1900000000\right):\\
\;\;\;\;im \cdot \left(-re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -9.4999999999999997e57 or 1.9e9 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -9.4999999999999997e57 < im < 1.9e9

    1. Initial program 38.7%

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

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

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

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

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

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

Alternative 10: 32.8% accurate, 77.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 2.7% accurate, 308.0× speedup?

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

\\
-512
\end{array}
Derivation
  1. Initial program 64.3%

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

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

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

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

    \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
  5. Applied egg-rr2.9%

    \[\leadsto \color{blue}{-512} \]
  6. Final simplification2.9%

    \[\leadsto -512 \]

Alternative 12: 2.8% accurate, 308.0× speedup?

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

\\
-0.004629629629629629
\end{array}
Derivation
  1. Initial program 64.3%

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

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

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

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

    \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
  5. Applied egg-rr2.9%

    \[\leadsto \color{blue}{-0.004629629629629629} \]
  6. Final simplification2.9%

    \[\leadsto -0.004629629629629629 \]

Alternative 13: 2.8% accurate, 308.0× speedup?

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

\\
-5.080526342529086 \cdot 10^{-5}
\end{array}
Derivation
  1. Initial program 64.3%

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

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

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

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

    \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
  5. Applied egg-rr2.9%

    \[\leadsto \color{blue}{-5.080526342529086 \cdot 10^{-5}} \]
  6. Final simplification2.9%

    \[\leadsto -5.080526342529086 \cdot 10^{-5} \]

Alternative 14: 2.8% accurate, 308.0× speedup?

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
  5. Applied egg-rr3.0%

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

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

Alternative 15: 15.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 64.3%

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

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

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

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

    \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
  5. Applied egg-rr16.2%

    \[\leadsto \color{blue}{0} \]
  6. Final simplification16.2%

    \[\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 2023283 
(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))))