math.sin on complex, imaginary part

Percentage Accurate: 53.9% → 99.3%
Time: 9.1s
Alternatives: 16
Speedup: 2.9×

Specification

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

\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - 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 16 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: 53.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.3% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

    1. Initial program 7.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg7.3%

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

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

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

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

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -2 \cdot 10^{+110} \lor \neg \left(e^{-im} - e^{im} \leq 2 \cdot 10^{-10}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \end{array} \]

Alternative 2: 94.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ t_1 := \cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{if}\;im \leq -4.1 \cdot 10^{+93}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.00155:\\ \;\;\;\;0.5 \cdot t_0\\ \mathbf{elif}\;im \leq 260:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.42 \cdot 10^{+102}:\\ \;\;\;\;t_0 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im)))
        (t_1 (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))))
   (if (<= im -4.1e+93)
     t_1
     (if (<= im -0.00155)
       (* 0.5 t_0)
       (if (<= im 260.0)
         (* (cos re) (- im))
         (if (<= im 1.42e+102) (* t_0 (+ 0.5 (* re (* re -0.25)))) t_1))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double t_1 = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	double tmp;
	if (im <= -4.1e+93) {
		tmp = t_1;
	} else if (im <= -0.00155) {
		tmp = 0.5 * t_0;
	} else if (im <= 260.0) {
		tmp = cos(re) * -im;
	} else if (im <= 1.42e+102) {
		tmp = t_0 * (0.5 + (re * (re * -0.25)));
	} 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)
    t_1 = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    if (im <= (-4.1d+93)) then
        tmp = t_1
    else if (im <= (-0.00155d0)) then
        tmp = 0.5d0 * t_0
    else if (im <= 260.0d0) then
        tmp = cos(re) * -im
    else if (im <= 1.42d+102) then
        tmp = t_0 * (0.5d0 + (re * (re * (-0.25d0))))
    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);
	double t_1 = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	double tmp;
	if (im <= -4.1e+93) {
		tmp = t_1;
	} else if (im <= -0.00155) {
		tmp = 0.5 * t_0;
	} else if (im <= 260.0) {
		tmp = Math.cos(re) * -im;
	} else if (im <= 1.42e+102) {
		tmp = t_0 * (0.5 + (re * (re * -0.25)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	t_1 = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	tmp = 0
	if im <= -4.1e+93:
		tmp = t_1
	elif im <= -0.00155:
		tmp = 0.5 * t_0
	elif im <= 260.0:
		tmp = math.cos(re) * -im
	elif im <= 1.42e+102:
		tmp = t_0 * (0.5 + (re * (re * -0.25)))
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	t_1 = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im))
	tmp = 0.0
	if (im <= -4.1e+93)
		tmp = t_1;
	elseif (im <= -0.00155)
		tmp = Float64(0.5 * t_0);
	elseif (im <= 260.0)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 1.42e+102)
		tmp = Float64(t_0 * Float64(0.5 + Float64(re * Float64(re * -0.25))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	t_1 = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	tmp = 0.0;
	if (im <= -4.1e+93)
		tmp = t_1;
	elseif (im <= -0.00155)
		tmp = 0.5 * t_0;
	elseif (im <= 260.0)
		tmp = cos(re) * -im;
	elseif (im <= 1.42e+102)
		tmp = t_0 * (0.5 + (re * (re * -0.25)));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.1e+93], t$95$1, If[LessEqual[im, -0.00155], N[(0.5 * t$95$0), $MachinePrecision], If[LessEqual[im, 260.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1.42e+102], N[(t$95$0 * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -0.00155:\\
\;\;\;\;0.5 \cdot t_0\\

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

\mathbf{elif}\;im \leq 1.42 \cdot 10^{+102}:\\
\;\;\;\;t_0 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -4.1000000000000001e93 or 1.4200000000000001e102 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

    if -4.1000000000000001e93 < im < -0.00154999999999999995

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

    if -0.00154999999999999995 < im < 260

    1. Initial program 8.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg8.0%

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

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

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

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

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

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

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

    if 260 < im < 1.4200000000000001e102

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

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

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out85.7%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow285.7%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*85.7%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified85.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.1 \cdot 10^{+93}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq -0.00155:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 260:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.42 \cdot 10^{+102}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 3: 94.8% accurate, 1.4× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4.1000000000000001e93 or 5.60000000000000037e102 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

    if -4.1000000000000001e93 < im < -0.0134999999999999998 or 0.0519999999999999976 < im < 5.60000000000000037e102

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

    if -0.0134999999999999998 < im < 0.0519999999999999976

    1. Initial program 7.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg7.3%

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

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

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

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

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.1 \cdot 10^{+93}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq -0.0135:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.052:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]

Alternative 4: 87.3% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -0.00135 \lor \neg \left(im \leq 0.0021\right):\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -0.00135) (not (<= im 0.0021)))
   (* 0.5 (- (exp (- im)) (exp im)))
   (* (cos re) (- im))))
double code(double re, double im) {
	double tmp;
	if ((im <= -0.00135) || !(im <= 0.0021)) {
		tmp = 0.5 * (exp(-im) - exp(im));
	} else {
		tmp = cos(re) * -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.00135d0)) .or. (.not. (im <= 0.0021d0))) then
        tmp = 0.5d0 * (exp(-im) - exp(im))
    else
        tmp = cos(re) * -im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -0.00135) || !(im <= 0.0021)) {
		tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
	} else {
		tmp = Math.cos(re) * -im;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -0.00135) or not (im <= 0.0021):
		tmp = 0.5 * (math.exp(-im) - math.exp(im))
	else:
		tmp = math.cos(re) * -im
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -0.00135) || !(im <= 0.0021))
		tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)));
	else
		tmp = Float64(cos(re) * Float64(-im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -0.00135) || ~((im <= 0.0021)))
		tmp = 0.5 * (exp(-im) - exp(im));
	else
		tmp = cos(re) * -im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -0.00135], N[Not[LessEqual[im, 0.0021]], $MachinePrecision]], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.00135 \lor \neg \left(im \leq 0.0021\right):\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

    if -0.0013500000000000001 < im < 0.00209999999999999987

    1. Initial program 7.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg7.3%

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

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

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

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

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -0.00135 \lor \neg \left(im \leq 0.0021\right):\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \end{array} \]

Alternative 5: 77.0% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.7 \cdot 10^{+25}:\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\

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

\mathbf{else}:\\
\;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\right)\\


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]

    if -3.6999999999999999e25 < im < 2100

    1. Initial program 13.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg13.3%

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

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

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

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

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in93.6%

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

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

    if 2100 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

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

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out77.0%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow277.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*77.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified77.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.7 \cdot 10^{+25}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 2100:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\right)\\ \end{array} \]

Alternative 6: 77.0% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -3.8 \cdot 10^{+25}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 700:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;-0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -3.8e+25)
   (- (* (pow im 3.0) -0.16666666666666666) im)
   (if (<= im 700.0)
     (* (cos re) (- im))
     (* -0.3333333333333333 (* (pow im 3.0) (+ 0.5 (* -0.25 (* re re))))))))
double code(double re, double im) {
	double tmp;
	if (im <= -3.8e+25) {
		tmp = (pow(im, 3.0) * -0.16666666666666666) - im;
	} else if (im <= 700.0) {
		tmp = cos(re) * -im;
	} else {
		tmp = -0.3333333333333333 * (pow(im, 3.0) * (0.5 + (-0.25 * (re * 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.8d+25)) then
        tmp = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
    else if (im <= 700.0d0) then
        tmp = cos(re) * -im
    else
        tmp = (-0.3333333333333333d0) * ((im ** 3.0d0) * (0.5d0 + ((-0.25d0) * (re * re))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -3.8e+25) {
		tmp = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
	} else if (im <= 700.0) {
		tmp = Math.cos(re) * -im;
	} else {
		tmp = -0.3333333333333333 * (Math.pow(im, 3.0) * (0.5 + (-0.25 * (re * re))));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -3.8e+25:
		tmp = (math.pow(im, 3.0) * -0.16666666666666666) - im
	elif im <= 700.0:
		tmp = math.cos(re) * -im
	else:
		tmp = -0.3333333333333333 * (math.pow(im, 3.0) * (0.5 + (-0.25 * (re * re))))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -3.8e+25)
		tmp = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im);
	elseif (im <= 700.0)
		tmp = Float64(cos(re) * Float64(-im));
	else
		tmp = Float64(-0.3333333333333333 * Float64((im ^ 3.0) * Float64(0.5 + Float64(-0.25 * Float64(re * re)))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -3.8e+25)
		tmp = ((im ^ 3.0) * -0.16666666666666666) - im;
	elseif (im <= 700.0)
		tmp = cos(re) * -im;
	else
		tmp = -0.3333333333333333 * ((im ^ 3.0) * (0.5 + (-0.25 * (re * re))));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -3.8e+25], N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 700.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(-0.3333333333333333 * N[(N[Power[im, 3.0], $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.8 \cdot 10^{+25}:\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\

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

\mathbf{else}:\\
\;\;\;\;-0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\right)\\


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]

    if -3.8e25 < im < 700

    1. Initial program 13.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg13.3%

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

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

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

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

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in93.6%

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

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

    if 700 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

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

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out77.0%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow277.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*77.0%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified77.0%

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

      \[\leadsto \color{blue}{\left(-2 \cdot im + -0.3333333333333333 \cdot {im}^{3}\right)} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in im around inf 57.0%

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

        \[\leadsto -0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right)\right) \]
      2. unpow257.0%

        \[\leadsto -0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right)\right) \]
    10. Simplified57.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.8 \cdot 10^{+25}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 700:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;-0.3333333333333333 \cdot \left({im}^{3} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\right)\\ \end{array} \]

Alternative 7: 76.9% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{if}\;im \leq -3.1 \cdot 10^{+25}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 1.42 \cdot 10^{+102}:\\
\;\;\;\;im \cdot \left(0.001388888888888889 \cdot {re}^{6}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -3.0999999999999998e25 or 1.4200000000000001e102 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]

    if -3.0999999999999998e25 < im < 2.25e18

    1. Initial program 14.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg14.5%

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

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

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

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

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in92.4%

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

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

    if 2.25e18 < im < 1.4200000000000001e102

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

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

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in3.7%

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 2.2%

      \[\leadsto \color{blue}{0.001388888888888889 \cdot \left({re}^{6} \cdot im\right) + \left(-0.041666666666666664 \cdot \left({re}^{4} \cdot im\right) + \left(-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)\right)\right)} \]
    8. Taylor expanded in re around inf 27.3%

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

        \[\leadsto \color{blue}{\left(0.001388888888888889 \cdot {re}^{6}\right) \cdot im} \]
    10. Simplified27.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.1 \cdot 10^{+25}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 2.25 \cdot 10^{+18}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.42 \cdot 10^{+102}:\\ \;\;\;\;im \cdot \left(0.001388888888888889 \cdot {re}^{6}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 8: 59.9% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.6 \cdot 10^{+18} \lor \neg \left(im \leq 600\right):\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -2.6e18 or 600 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

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

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in5.6%

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 3.8%

      \[\leadsto \color{blue}{0.001388888888888889 \cdot \left({re}^{6} \cdot im\right) + \left(-0.041666666666666664 \cdot \left({re}^{4} \cdot im\right) + \left(-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)\right)\right)} \]
    8. Taylor expanded in re around 0 22.5%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(re \cdot \left(re \cdot im\right)\right)} - im \]
    10. Simplified22.5%

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

    if -2.6e18 < im < 600

    1. Initial program 12.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg12.0%

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

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

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

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative95.0%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in95.0%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified95.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.6 \cdot 10^{+18} \lor \neg \left(im \leq 600\right):\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \end{array} \]

Alternative 9: 60.1% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -2.8 \cdot 10^{+18}:\\ \;\;\;\;im \cdot \left(0.001388888888888889 \cdot {re}^{6}\right)\\ \mathbf{elif}\;im \leq 2050000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -2.8e+18)
   (* im (* 0.001388888888888889 (pow re 6.0)))
   (if (<= im 2050000.0) (* (cos re) (- im)) (- (* 0.5 (* re (* im re))) im))))
double code(double re, double im) {
	double tmp;
	if (im <= -2.8e+18) {
		tmp = im * (0.001388888888888889 * pow(re, 6.0));
	} else if (im <= 2050000.0) {
		tmp = cos(re) * -im;
	} else {
		tmp = (0.5 * (re * (im * re))) - im;
	}
	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+18)) then
        tmp = im * (0.001388888888888889d0 * (re ** 6.0d0))
    else if (im <= 2050000.0d0) then
        tmp = cos(re) * -im
    else
        tmp = (0.5d0 * (re * (im * re))) - im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -2.8e+18) {
		tmp = im * (0.001388888888888889 * Math.pow(re, 6.0));
	} else if (im <= 2050000.0) {
		tmp = Math.cos(re) * -im;
	} else {
		tmp = (0.5 * (re * (im * re))) - im;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -2.8e+18:
		tmp = im * (0.001388888888888889 * math.pow(re, 6.0))
	elif im <= 2050000.0:
		tmp = math.cos(re) * -im
	else:
		tmp = (0.5 * (re * (im * re))) - im
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -2.8e+18)
		tmp = Float64(im * Float64(0.001388888888888889 * (re ^ 6.0)));
	elseif (im <= 2050000.0)
		tmp = Float64(cos(re) * Float64(-im));
	else
		tmp = Float64(Float64(0.5 * Float64(re * Float64(im * re))) - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -2.8e+18)
		tmp = im * (0.001388888888888889 * (re ^ 6.0));
	elseif (im <= 2050000.0)
		tmp = cos(re) * -im;
	else
		tmp = (0.5 * (re * (im * re))) - im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -2.8e+18], N[(im * N[(0.001388888888888889 * N[Power[re, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2050000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(N[(0.5 * N[(re * N[(im * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.8 \cdot 10^{+18}:\\
\;\;\;\;im \cdot \left(0.001388888888888889 \cdot {re}^{6}\right)\\

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

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

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

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in6.1%

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 5.0%

      \[\leadsto \color{blue}{0.001388888888888889 \cdot \left({re}^{6} \cdot im\right) + \left(-0.041666666666666664 \cdot \left({re}^{4} \cdot im\right) + \left(-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)\right)\right)} \]
    8. Taylor expanded in re around inf 21.6%

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

        \[\leadsto \color{blue}{\left(0.001388888888888889 \cdot {re}^{6}\right) \cdot im} \]
    10. Simplified21.6%

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

    if -2.8e18 < im < 2.05e6

    1. Initial program 12.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg12.0%

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

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

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

        \[\leadsto \color{blue}{-\cos re \cdot im} \]
      2. *-commutative95.0%

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in95.0%

        \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    6. Simplified95.0%

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

    if 2.05e6 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg100.0%

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

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

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

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

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in5.1%

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 2.6%

      \[\leadsto \color{blue}{0.001388888888888889 \cdot \left({re}^{6} \cdot im\right) + \left(-0.041666666666666664 \cdot \left({re}^{4} \cdot im\right) + \left(-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)\right)\right)} \]
    8. Taylor expanded in re around 0 25.7%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(re \cdot \left(re \cdot im\right)\right)} - im \]
    10. Simplified25.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.8 \cdot 10^{+18}:\\ \;\;\;\;im \cdot \left(0.001388888888888889 \cdot {re}^{6}\right)\\ \mathbf{elif}\;im \leq 2050000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \end{array} \]

Alternative 10: 31.6% accurate, 27.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 1.1 \cdot 10^{+158}:\\ \;\;\;\;-im\\ \mathbf{elif}\;re \leq 1.85 \cdot 10^{+176}:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{else}:\\ \;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 1.1e+158)
   (- im)
   (if (<= re 1.85e+176) (* (* re re) 0.75) (+ 13.5 (* (* re re) -6.75)))))
double code(double re, double im) {
	double tmp;
	if (re <= 1.1e+158) {
		tmp = -im;
	} else if (re <= 1.85e+176) {
		tmp = (re * re) * 0.75;
	} else {
		tmp = 13.5 + ((re * re) * -6.75);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 1.1d+158) then
        tmp = -im
    else if (re <= 1.85d+176) then
        tmp = (re * re) * 0.75d0
    else
        tmp = 13.5d0 + ((re * re) * (-6.75d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 1.1e+158) {
		tmp = -im;
	} else if (re <= 1.85e+176) {
		tmp = (re * re) * 0.75;
	} else {
		tmp = 13.5 + ((re * re) * -6.75);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 1.1e+158:
		tmp = -im
	elif re <= 1.85e+176:
		tmp = (re * re) * 0.75
	else:
		tmp = 13.5 + ((re * re) * -6.75)
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 1.1e+158)
		tmp = Float64(-im);
	elseif (re <= 1.85e+176)
		tmp = Float64(Float64(re * re) * 0.75);
	else
		tmp = Float64(13.5 + Float64(Float64(re * re) * -6.75));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 1.1e+158)
		tmp = -im;
	elseif (re <= 1.85e+176)
		tmp = (re * re) * 0.75;
	else
		tmp = 13.5 + ((re * re) * -6.75);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 1.1e+158], (-im), If[LessEqual[re, 1.85e+176], N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision], N[(13.5 + N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.1 \cdot 10^{+158}:\\
\;\;\;\;-im\\

\mathbf{elif}\;re \leq 1.85 \cdot 10^{+176}:\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.75\\

\mathbf{else}:\\
\;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if re < 1.1000000000000001e158

    1. Initial program 53.4%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg53.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 32.2%

      \[\leadsto \color{blue}{-1 \cdot im} \]
    8. Step-by-step derivation
      1. neg-mul-132.2%

        \[\leadsto \color{blue}{-im} \]
    9. Simplified32.2%

      \[\leadsto \color{blue}{-im} \]

    if 1.1000000000000001e158 < re < 1.8499999999999999e176

    1. Initial program 58.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg58.3%

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

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

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.1%

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

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out33.4%

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

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*33.4%

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

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

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 51.0%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. unpow251.0%

        \[\leadsto 0.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
    10. Simplified51.0%

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

    if 1.8499999999999999e176 < re

    1. Initial program 44.7%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg44.7%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Applied egg-rr2.6%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{27} \]
    5. Taylor expanded in re around 0 24.6%

      \[\leadsto \color{blue}{13.5 + -6.75 \cdot {re}^{2}} \]
    6. Step-by-step derivation
      1. *-commutative24.6%

        \[\leadsto 13.5 + \color{blue}{{re}^{2} \cdot -6.75} \]
      2. unpow224.6%

        \[\leadsto 13.5 + \color{blue}{\left(re \cdot re\right)} \cdot -6.75 \]
    7. Simplified24.6%

      \[\leadsto \color{blue}{13.5 + \left(re \cdot re\right) \cdot -6.75} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification32.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.1 \cdot 10^{+158}:\\ \;\;\;\;-im\\ \mathbf{elif}\;re \leq 1.85 \cdot 10^{+176}:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{else}:\\ \;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\ \end{array} \]

Alternative 11: 35.7% accurate, 27.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 1.8 \cdot 10^{+172}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 1.8e+172)
   (- (* 0.5 (* re (* im re))) im)
   (+ 13.5 (* (* re re) -6.75))))
double code(double re, double im) {
	double tmp;
	if (re <= 1.8e+172) {
		tmp = (0.5 * (re * (im * re))) - im;
	} else {
		tmp = 13.5 + ((re * re) * -6.75);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 1.8d+172) then
        tmp = (0.5d0 * (re * (im * re))) - im
    else
        tmp = 13.5d0 + ((re * re) * (-6.75d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 1.8e+172) {
		tmp = (0.5 * (re * (im * re))) - im;
	} else {
		tmp = 13.5 + ((re * re) * -6.75);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 1.8e+172:
		tmp = (0.5 * (re * (im * re))) - im
	else:
		tmp = 13.5 + ((re * re) * -6.75)
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 1.8e+172)
		tmp = Float64(Float64(0.5 * Float64(re * Float64(im * re))) - im);
	else
		tmp = Float64(13.5 + Float64(Float64(re * re) * -6.75));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 1.8e+172)
		tmp = (0.5 * (re * (im * re))) - im;
	else
		tmp = 13.5 + ((re * re) * -6.75);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 1.8e+172], N[(N[(0.5 * N[(re * N[(im * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(13.5 + N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.8 \cdot 10^{+172}:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\

\mathbf{else}:\\
\;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\


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

    1. Initial program 53.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg53.3%

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

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

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

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

        \[\leadsto -\color{blue}{im \cdot \cos re} \]
      3. distribute-lft-neg-in53.1%

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

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

      \[\leadsto \color{blue}{0.001388888888888889 \cdot \left({re}^{6} \cdot im\right) + \left(-0.041666666666666664 \cdot \left({re}^{4} \cdot im\right) + \left(-1 \cdot im + 0.5 \cdot \left({re}^{2} \cdot im\right)\right)\right)} \]
    8. Taylor expanded in re around 0 37.8%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(re \cdot \left(re \cdot im\right)\right)} - im \]
    10. Simplified37.8%

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

    if 1.79999999999999987e172 < re

    1. Initial program 47.8%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg47.8%

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

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

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{27} \]
    5. Taylor expanded in re around 0 23.2%

      \[\leadsto \color{blue}{13.5 + -6.75 \cdot {re}^{2}} \]
    6. Step-by-step derivation
      1. *-commutative23.2%

        \[\leadsto 13.5 + \color{blue}{{re}^{2} \cdot -6.75} \]
      2. unpow223.2%

        \[\leadsto 13.5 + \color{blue}{\left(re \cdot re\right)} \cdot -6.75 \]
    7. Simplified23.2%

      \[\leadsto \color{blue}{13.5 + \left(re \cdot re\right) \cdot -6.75} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification36.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.8 \cdot 10^{+172}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\ \end{array} \]

Alternative 12: 31.8% accurate, 43.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 8.1 \cdot 10^{+157}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 8.1e+157) (- im) (* (* re re) 0.75)))
double code(double re, double im) {
	double tmp;
	if (re <= 8.1e+157) {
		tmp = -im;
	} else {
		tmp = (re * re) * 0.75;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 8.1d+157) then
        tmp = -im
    else
        tmp = (re * re) * 0.75d0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 8.1e+157) {
		tmp = -im;
	} else {
		tmp = (re * re) * 0.75;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 8.1e+157:
		tmp = -im
	else:
		tmp = (re * re) * 0.75
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 8.1e+157)
		tmp = Float64(-im);
	else
		tmp = Float64(Float64(re * re) * 0.75);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 8.1e+157)
		tmp = -im;
	else
		tmp = (re * re) * 0.75;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 8.1e+157], (-im), N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 8.1 \cdot 10^{+157}:\\
\;\;\;\;-im\\

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


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

    1. Initial program 53.4%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg53.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 32.2%

      \[\leadsto \color{blue}{-1 \cdot im} \]
    8. Step-by-step derivation
      1. neg-mul-132.2%

        \[\leadsto \color{blue}{-im} \]
    9. Simplified32.2%

      \[\leadsto \color{blue}{-im} \]

    if 8.10000000000000009e157 < re

    1. Initial program 48.2%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. sub0-neg48.2%

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

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

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(e^{-im} - e^{im}\right) \cdot {re}^{2}\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

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

        \[\leadsto \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} + 0.5 \cdot \left(e^{-im} - e^{im}\right) \]
      3. distribute-rgt-out21.8%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow221.8%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \]
      7. associate-*l*21.8%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified21.8%

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

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
    8. Taylor expanded in re around inf 27.0%

      \[\leadsto \color{blue}{0.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. unpow227.0%

        \[\leadsto 0.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
    10. Simplified27.0%

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

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

Alternative 13: 29.8% accurate, 154.5× speedup?

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

\\
-im
\end{array}
Derivation
  1. Initial program 52.9%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. sub0-neg52.9%

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

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

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

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

      \[\leadsto -\color{blue}{im \cdot \cos re} \]
    3. distribute-lft-neg-in53.4%

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

    \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
  7. Taylor expanded in re around 0 30.4%

    \[\leadsto \color{blue}{-1 \cdot im} \]
  8. Step-by-step derivation
    1. neg-mul-130.4%

      \[\leadsto \color{blue}{-im} \]
  9. Simplified30.4%

    \[\leadsto \color{blue}{-im} \]
  10. Final simplification30.4%

    \[\leadsto -im \]

Alternative 14: 2.9% accurate, 309.0× speedup?

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

\\
-3
\end{array}
Derivation
  1. Initial program 52.9%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. sub0-neg52.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-3} \]
  8. Final simplification2.9%

    \[\leadsto -3 \]

Alternative 15: 2.9% accurate, 309.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 52.9%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. sub0-neg52.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 3.5% accurate, 309.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 52.9%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. sub0-neg52.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0} \]
  8. Final simplification3.6%

    \[\leadsto 0 \]

Developer target: 99.8% accurate, 0.8× speedup?

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

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


\end{array}
\end{array}

Reproduce

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

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

  (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))