math.sin on complex, imaginary part

Percentage Accurate: 53.6% → 99.7%
Time: 11.4s
Alternatives: 16
Speedup: 2.8×

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

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

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

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


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

    1. Initial program 6.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified6.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.7%

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

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

Alternative 2: 99.6% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 6.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified6.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.7%

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

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

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

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

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

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

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

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

Alternative 3: 87.2% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := {im}^{3} \cdot -0.16666666666666666 - im\\ t_2 := t_1 \cdot \left(\left(re \cdot re\right) \cdot -0.5 + 1\right)\\ \mathbf{if}\;im \leq -3 \cdot 10^{+205}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq -0.00132:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.00044:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.05 \cdot 10^{+189}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 10^{+219}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
        (t_1 (- (* (pow im 3.0) -0.16666666666666666) im))
        (t_2 (* t_1 (+ (* (* re re) -0.5) 1.0))))
   (if (<= im -3e+205)
     t_2
     (if (<= im -0.00132)
       t_0
       (if (<= im 0.00044)
         (* im (- (cos re)))
         (if (<= im 1.05e+189) t_0 (if (<= im 1e+219) t_2 t_1)))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double t_1 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double t_2 = t_1 * (((re * re) * -0.5) + 1.0);
	double tmp;
	if (im <= -3e+205) {
		tmp = t_2;
	} else if (im <= -0.00132) {
		tmp = t_0;
	} else if (im <= 0.00044) {
		tmp = im * -cos(re);
	} else if (im <= 1.05e+189) {
		tmp = t_0;
	} else if (im <= 1e+219) {
		tmp = t_2;
	} 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) :: t_2
    real(8) :: tmp
    t_0 = 0.5d0 * (exp(-im) - exp(im))
    t_1 = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
    t_2 = t_1 * (((re * re) * (-0.5d0)) + 1.0d0)
    if (im <= (-3d+205)) then
        tmp = t_2
    else if (im <= (-0.00132d0)) then
        tmp = t_0
    else if (im <= 0.00044d0) then
        tmp = im * -cos(re)
    else if (im <= 1.05d+189) then
        tmp = t_0
    else if (im <= 1d+219) then
        tmp = t_2
    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.pow(im, 3.0) * -0.16666666666666666) - im;
	double t_2 = t_1 * (((re * re) * -0.5) + 1.0);
	double tmp;
	if (im <= -3e+205) {
		tmp = t_2;
	} else if (im <= -0.00132) {
		tmp = t_0;
	} else if (im <= 0.00044) {
		tmp = im * -Math.cos(re);
	} else if (im <= 1.05e+189) {
		tmp = t_0;
	} else if (im <= 1e+219) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * (math.exp(-im) - math.exp(im))
	t_1 = (math.pow(im, 3.0) * -0.16666666666666666) - im
	t_2 = t_1 * (((re * re) * -0.5) + 1.0)
	tmp = 0
	if im <= -3e+205:
		tmp = t_2
	elif im <= -0.00132:
		tmp = t_0
	elif im <= 0.00044:
		tmp = im * -math.cos(re)
	elif im <= 1.05e+189:
		tmp = t_0
	elif im <= 1e+219:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	t_1 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	t_2 = Float64(t_1 * Float64(Float64(Float64(re * re) * -0.5) + 1.0))
	tmp = 0.0
	if (im <= -3e+205)
		tmp = t_2;
	elseif (im <= -0.00132)
		tmp = t_0;
	elseif (im <= 0.00044)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 1.05e+189)
		tmp = t_0;
	elseif (im <= 1e+219)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * (exp(-im) - exp(im));
	t_1 = ((im ^ 3.0) * -0.16666666666666666) - im;
	t_2 = t_1 * (((re * re) * -0.5) + 1.0);
	tmp = 0.0;
	if (im <= -3e+205)
		tmp = t_2;
	elseif (im <= -0.00132)
		tmp = t_0;
	elseif (im <= 0.00044)
		tmp = im * -cos(re);
	elseif (im <= 1.05e+189)
		tmp = t_0;
	elseif (im <= 1e+219)
		tmp = t_2;
	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[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3e+205], t$95$2, If[LessEqual[im, -0.00132], t$95$0, If[LessEqual[im, 0.00044], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.05e+189], t$95$0, If[LessEqual[im, 1e+219], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;im \leq 1.05 \cdot 10^{+189}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 10^{+219}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -2.9999999999999999e205 or 1.04999999999999996e189 < im < 9.99999999999999965e218

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.9999999999999999e205 < im < -0.00132 or 4.40000000000000016e-4 < im < 1.04999999999999996e189

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

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

    if -0.00132 < im < 4.40000000000000016e-4

    1. Initial program 6.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified6.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.4%

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

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

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

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

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

    if 9.99999999999999965e218 < 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 100.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-neg100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Step-by-step derivation
      1. *-commutative95.0%

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} - im \]
    9. Simplified95.0%

      \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666 - im} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification92.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3 \cdot 10^{+205}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(\left(re \cdot re\right) \cdot -0.5 + 1\right)\\ \mathbf{elif}\;im \leq -0.00132:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.00044:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.05 \cdot 10^{+189}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 10^{+219}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(\left(re \cdot re\right) \cdot -0.5 + 1\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 4: 96.4% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := {im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \mathbf{if}\;im \leq -6.5 \cdot 10^{+97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.00132:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.029:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+61}:\\ \;\;\;\;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 (* (pow im 5.0) (* (cos re) -0.008333333333333333))))
   (if (<= im -6.5e+97)
     t_1
     (if (<= im -0.00132)
       t_0
       (if (<= im 0.029) (* im (- (cos re))) (if (<= im 5e+61) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double t_1 = pow(im, 5.0) * (cos(re) * -0.008333333333333333);
	double tmp;
	if (im <= -6.5e+97) {
		tmp = t_1;
	} else if (im <= -0.00132) {
		tmp = t_0;
	} else if (im <= 0.029) {
		tmp = im * -cos(re);
	} else if (im <= 5e+61) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * (exp(-im) - exp(im))
    t_1 = (im ** 5.0d0) * (cos(re) * (-0.008333333333333333d0))
    if (im <= (-6.5d+97)) then
        tmp = t_1
    else if (im <= (-0.00132d0)) then
        tmp = t_0
    else if (im <= 0.029d0) then
        tmp = im * -cos(re)
    else if (im <= 5d+61) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
	double t_1 = Math.pow(im, 5.0) * (Math.cos(re) * -0.008333333333333333);
	double tmp;
	if (im <= -6.5e+97) {
		tmp = t_1;
	} else if (im <= -0.00132) {
		tmp = t_0;
	} else if (im <= 0.029) {
		tmp = im * -Math.cos(re);
	} else if (im <= 5e+61) {
		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.pow(im, 5.0) * (math.cos(re) * -0.008333333333333333)
	tmp = 0
	if im <= -6.5e+97:
		tmp = t_1
	elif im <= -0.00132:
		tmp = t_0
	elif im <= 0.029:
		tmp = im * -math.cos(re)
	elif im <= 5e+61:
		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((im ^ 5.0) * Float64(cos(re) * -0.008333333333333333))
	tmp = 0.0
	if (im <= -6.5e+97)
		tmp = t_1;
	elseif (im <= -0.00132)
		tmp = t_0;
	elseif (im <= 0.029)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 5e+61)
		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 = (im ^ 5.0) * (cos(re) * -0.008333333333333333);
	tmp = 0.0;
	if (im <= -6.5e+97)
		tmp = t_1;
	elseif (im <= -0.00132)
		tmp = t_0;
	elseif (im <= 0.029)
		tmp = im * -cos(re);
	elseif (im <= 5e+61)
		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[Power[im, 5.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.5e+97], t$95$1, If[LessEqual[im, -0.00132], t$95$0, If[LessEqual[im, 0.029], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 5e+61], 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 := {im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\
\mathbf{if}\;im \leq -6.5 \cdot 10^{+97}:\\
\;\;\;\;t_1\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -6.4999999999999999e97 or 5.00000000000000018e61 < 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 100.0%

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

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

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

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

        \[\leadsto \color{blue}{{im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)} \]
    7. Simplified100.0%

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

    if -6.4999999999999999e97 < im < -0.00132 or 0.0290000000000000015 < im < 5.00000000000000018e61

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

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

    if -0.00132 < im < 0.0290000000000000015

    1. Initial program 6.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified6.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.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.5 \cdot 10^{+97}:\\ \;\;\;\;{im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \mathbf{elif}\;im \leq -0.00132:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.029:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+61}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \end{array} \]

Alternative 5: 96.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := {im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \mathbf{if}\;im \leq -6.5 \cdot 10^{+97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.068:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.052:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 4.5 \cdot 10^{+61}:\\ \;\;\;\;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 (* (pow im 5.0) (* (cos re) -0.008333333333333333))))
   (if (<= im -6.5e+97)
     t_1
     (if (<= im -0.068)
       t_0
       (if (<= im 0.052)
         (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
         (if (<= im 4.5e+61) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double t_1 = pow(im, 5.0) * (cos(re) * -0.008333333333333333);
	double tmp;
	if (im <= -6.5e+97) {
		tmp = t_1;
	} else if (im <= -0.068) {
		tmp = t_0;
	} else if (im <= 0.052) {
		tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 4.5e+61) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * (exp(-im) - exp(im))
    t_1 = (im ** 5.0d0) * (cos(re) * (-0.008333333333333333d0))
    if (im <= (-6.5d+97)) then
        tmp = t_1
    else if (im <= (-0.068d0)) then
        tmp = t_0
    else if (im <= 0.052d0) then
        tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    else if (im <= 4.5d+61) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
	double t_1 = Math.pow(im, 5.0) * (Math.cos(re) * -0.008333333333333333);
	double tmp;
	if (im <= -6.5e+97) {
		tmp = t_1;
	} else if (im <= -0.068) {
		tmp = t_0;
	} else if (im <= 0.052) {
		tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 4.5e+61) {
		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.pow(im, 5.0) * (math.cos(re) * -0.008333333333333333)
	tmp = 0
	if im <= -6.5e+97:
		tmp = t_1
	elif im <= -0.068:
		tmp = t_0
	elif im <= 0.052:
		tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	elif im <= 4.5e+61:
		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((im ^ 5.0) * Float64(cos(re) * -0.008333333333333333))
	tmp = 0.0
	if (im <= -6.5e+97)
		tmp = t_1;
	elseif (im <= -0.068)
		tmp = t_0;
	elseif (im <= 0.052)
		tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	elseif (im <= 4.5e+61)
		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 = (im ^ 5.0) * (cos(re) * -0.008333333333333333);
	tmp = 0.0;
	if (im <= -6.5e+97)
		tmp = t_1;
	elseif (im <= -0.068)
		tmp = t_0;
	elseif (im <= 0.052)
		tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	elseif (im <= 4.5e+61)
		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[Power[im, 5.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.5e+97], t$95$1, If[LessEqual[im, -0.068], t$95$0, If[LessEqual[im, 0.052], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.5e+61], 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 := {im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\
\mathbf{if}\;im \leq -6.5 \cdot 10^{+97}:\\
\;\;\;\;t_1\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -6.4999999999999999e97 or 4.5e61 < 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 100.0%

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

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

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

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

        \[\leadsto \color{blue}{{im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)} \]
    7. Simplified100.0%

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

    if -6.4999999999999999e97 < im < -0.068000000000000005 or 0.0519999999999999976 < im < 4.5e61

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

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

    if -0.068000000000000005 < im < 0.0519999999999999976

    1. Initial program 6.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified6.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.7%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.5 \cdot 10^{+97}:\\ \;\;\;\;{im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \mathbf{elif}\;im \leq -0.068:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.052:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 4.5 \cdot 10^{+61}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \end{array} \]

Alternative 6: 75.7% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{if}\;im \leq -5 \cdot 10^{+214}:\\ \;\;\;\;t_0 \cdot \left(\left(re \cdot re\right) \cdot -0.5 + 1\right)\\ \mathbf{elif}\;im \leq -2.65 \cdot 10^{+44} \lor \neg \left(im \leq 8.5 \cdot 10^{+48}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im)))
   (if (<= im -5e+214)
     (* t_0 (+ (* (* re re) -0.5) 1.0))
     (if (or (<= im -2.65e+44) (not (<= im 8.5e+48)))
       t_0
       (* im (- (cos re)))))))
double code(double re, double im) {
	double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double tmp;
	if (im <= -5e+214) {
		tmp = t_0 * (((re * re) * -0.5) + 1.0);
	} else if ((im <= -2.65e+44) || !(im <= 8.5e+48)) {
		tmp = t_0;
	} else {
		tmp = im * -cos(re);
	}
	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 <= (-5d+214)) then
        tmp = t_0 * (((re * re) * (-0.5d0)) + 1.0d0)
    else if ((im <= (-2.65d+44)) .or. (.not. (im <= 8.5d+48))) then
        tmp = t_0
    else
        tmp = im * -cos(re)
    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 <= -5e+214) {
		tmp = t_0 * (((re * re) * -0.5) + 1.0);
	} else if ((im <= -2.65e+44) || !(im <= 8.5e+48)) {
		tmp = t_0;
	} else {
		tmp = im * -Math.cos(re);
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im
	tmp = 0
	if im <= -5e+214:
		tmp = t_0 * (((re * re) * -0.5) + 1.0)
	elif (im <= -2.65e+44) or not (im <= 8.5e+48):
		tmp = t_0
	else:
		tmp = im * -math.cos(re)
	return tmp
function code(re, im)
	t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	tmp = 0.0
	if (im <= -5e+214)
		tmp = Float64(t_0 * Float64(Float64(Float64(re * re) * -0.5) + 1.0));
	elseif ((im <= -2.65e+44) || !(im <= 8.5e+48))
		tmp = t_0;
	else
		tmp = Float64(im * Float64(-cos(re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = ((im ^ 3.0) * -0.16666666666666666) - im;
	tmp = 0.0;
	if (im <= -5e+214)
		tmp = t_0 * (((re * re) * -0.5) + 1.0);
	elseif ((im <= -2.65e+44) || ~((im <= 8.5e+48)))
		tmp = t_0;
	else
		tmp = im * -cos(re);
	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, -5e+214], N[(t$95$0 * N[(N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, -2.65e+44], N[Not[LessEqual[im, 8.5e+48]], $MachinePrecision]], t$95$0, N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -2.65 \cdot 10^{+44} \lor \neg \left(im \leq 8.5 \cdot 10^{+48}\right):\\
\;\;\;\;t_0\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.99999999999999953e214 < im < -2.65e44 or 8.5000000000000001e48 < 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 74.4%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Step-by-step derivation
      1. *-commutative60.4%

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} - im \]
    9. Simplified60.4%

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

    if -2.65e44 < im < 8.5000000000000001e48

    1. Initial program 15.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified15.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 90.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5 \cdot 10^{+214}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(\left(re \cdot re\right) \cdot -0.5 + 1\right)\\ \mathbf{elif}\;im \leq -2.65 \cdot 10^{+44} \lor \neg \left(im \leq 8.5 \cdot 10^{+48}\right):\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 7: 57.8% accurate, 2.8× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -7.59999999999999987e167

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.59999999999999987e167 < im < -4.1e18

    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-out55.6%

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

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

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

        \[\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*55.6%

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

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

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow226.9%

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

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

    if -4.1e18 < im < 680

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

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

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

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

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

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

    if 680 < 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-out71.6%

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

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

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

        \[\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*71.6%

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

      \[\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 re around inf 16.2%

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

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

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

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

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(-0.25 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
    10. Applied egg-rr19.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.6 \cdot 10^{+167}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq -4.1 \cdot 10^{+18}:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{elif}\;im \leq 680:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \]

Alternative 8: 75.8% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.32 \cdot 10^{+47} \lor \neg \left(im \leq 9 \cdot 10^{+46}\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -1.31999999999999992e47 or 9.00000000000000019e46 < 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 78.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Step-by-step derivation
      1. *-commutative59.8%

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} - im \]
    9. Simplified59.8%

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

    if -1.31999999999999992e47 < im < 9.00000000000000019e46

    1. Initial program 15.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified15.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 90.2%

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

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

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

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

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

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

Alternative 9: 34.6% accurate, 27.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(re \cdot re\right) \cdot -6.75\\ \mathbf{if}\;im \leq -5.6 \cdot 10^{+172}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -4.1 \cdot 10^{+18}:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{elif}\;im \leq 500:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* re re) -6.75)))
   (if (<= im -5.6e+172)
     t_0
     (if (<= im -4.1e+18) (* (* re re) 0.75) (if (<= im 500.0) (- im) t_0)))))
double code(double re, double im) {
	double t_0 = (re * re) * -6.75;
	double tmp;
	if (im <= -5.6e+172) {
		tmp = t_0;
	} else if (im <= -4.1e+18) {
		tmp = (re * re) * 0.75;
	} else if (im <= 500.0) {
		tmp = -im;
	} 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 = (re * re) * (-6.75d0)
    if (im <= (-5.6d+172)) then
        tmp = t_0
    else if (im <= (-4.1d+18)) then
        tmp = (re * re) * 0.75d0
    else if (im <= 500.0d0) then
        tmp = -im
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (re * re) * -6.75;
	double tmp;
	if (im <= -5.6e+172) {
		tmp = t_0;
	} else if (im <= -4.1e+18) {
		tmp = (re * re) * 0.75;
	} else if (im <= 500.0) {
		tmp = -im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (re * re) * -6.75
	tmp = 0
	if im <= -5.6e+172:
		tmp = t_0
	elif im <= -4.1e+18:
		tmp = (re * re) * 0.75
	elif im <= 500.0:
		tmp = -im
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64(re * re) * -6.75)
	tmp = 0.0
	if (im <= -5.6e+172)
		tmp = t_0;
	elseif (im <= -4.1e+18)
		tmp = Float64(Float64(re * re) * 0.75);
	elseif (im <= 500.0)
		tmp = Float64(-im);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (re * re) * -6.75;
	tmp = 0.0;
	if (im <= -5.6e+172)
		tmp = t_0;
	elseif (im <= -4.1e+18)
		tmp = (re * re) * 0.75;
	elseif (im <= 500.0)
		tmp = -im;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]}, If[LessEqual[im, -5.6e+172], t$95$0, If[LessEqual[im, -4.1e+18], N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision], If[LessEqual[im, 500.0], (-im), t$95$0]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 500:\\
\;\;\;\;-im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -5.5999999999999999e172 or 500 < 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-out74.8%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow274.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*74.8%

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

      \[\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 re around inf 23.3%

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

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

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

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

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(-0.25 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
    10. Applied egg-rr21.1%

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

    if -5.5999999999999999e172 < im < -4.1e18

    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-out56.8%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow256.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*56.8%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified56.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-rr25.6%

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow226.2%

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

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

    if -4.1e18 < im < 500

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-im} \]
    9. Simplified54.0%

      \[\leadsto \color{blue}{-im} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification36.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.6 \cdot 10^{+172}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \mathbf{elif}\;im \leq -4.1 \cdot 10^{+18}:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{elif}\;im \leq 500:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \]

Alternative 10: 35.5% accurate, 27.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -1.45 \cdot 10^{+173}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\ \mathbf{elif}\;im \leq -4.6 \cdot 10^{+18}:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{elif}\;im \leq 580:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -1.45e+173)
   (* (* re re) (* im 0.5))
   (if (<= im -4.6e+18)
     (* (* re re) 0.75)
     (if (<= im 580.0) (- im) (* (* re re) -6.75)))))
double code(double re, double im) {
	double tmp;
	if (im <= -1.45e+173) {
		tmp = (re * re) * (im * 0.5);
	} else if (im <= -4.6e+18) {
		tmp = (re * re) * 0.75;
	} else if (im <= 580.0) {
		tmp = -im;
	} else {
		tmp = (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 (im <= (-1.45d+173)) then
        tmp = (re * re) * (im * 0.5d0)
    else if (im <= (-4.6d+18)) then
        tmp = (re * re) * 0.75d0
    else if (im <= 580.0d0) then
        tmp = -im
    else
        tmp = (re * re) * (-6.75d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -1.45e+173) {
		tmp = (re * re) * (im * 0.5);
	} else if (im <= -4.6e+18) {
		tmp = (re * re) * 0.75;
	} else if (im <= 580.0) {
		tmp = -im;
	} else {
		tmp = (re * re) * -6.75;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -1.45e+173:
		tmp = (re * re) * (im * 0.5)
	elif im <= -4.6e+18:
		tmp = (re * re) * 0.75
	elif im <= 580.0:
		tmp = -im
	else:
		tmp = (re * re) * -6.75
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -1.45e+173)
		tmp = Float64(Float64(re * re) * Float64(im * 0.5));
	elseif (im <= -4.6e+18)
		tmp = Float64(Float64(re * re) * 0.75);
	elseif (im <= 580.0)
		tmp = Float64(-im);
	else
		tmp = Float64(Float64(re * re) * -6.75);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -1.45e+173)
		tmp = (re * re) * (im * 0.5);
	elseif (im <= -4.6e+18)
		tmp = (re * re) * 0.75;
	elseif (im <= 580.0)
		tmp = -im;
	else
		tmp = (re * re) * -6.75;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -1.45e+173], N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -4.6e+18], N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision], If[LessEqual[im, 580.0], (-im), N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 580:\\
\;\;\;\;-im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -1.45000000000000003e173

    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-out82.8%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow282.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*82.8%

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

      \[\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 re around inf 41.4%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot \left(im \cdot 0.5\right)} \]
      3. unpow241.9%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot \left(im \cdot 0.5\right) \]
    12. Simplified41.9%

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

    if -1.45000000000000003e173 < im < -4.6e18

    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-out56.8%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow256.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*56.8%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
    6. Simplified56.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-rr25.6%

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow226.2%

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

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

    if -4.6e18 < im < 580

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-im} \]
    9. Simplified54.0%

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

    if 580 < 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-out71.6%

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

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

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

        \[\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*71.6%

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

      \[\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 re around inf 16.2%

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

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

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

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

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(-0.25 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
    10. Applied egg-rr19.2%

      \[\leadsto \left(re \cdot re\right) \cdot \left(-0.25 \cdot \color{blue}{27}\right) \]
  3. Recombined 4 regimes into one program.
  4. Final simplification38.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.45 \cdot 10^{+173}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\ \mathbf{elif}\;im \leq -4.6 \cdot 10^{+18}:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{elif}\;im \leq 580:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \]

Alternative 11: 35.9% accurate, 27.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -2.3 \cdot 10^{+171}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq -4.1 \cdot 10^{+18}:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{elif}\;im \leq 520:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -2.3e+171)
   (- (* 0.5 (* re (* im re))) im)
   (if (<= im -4.1e+18)
     (* (* re re) 0.75)
     (if (<= im 520.0) (- im) (* (* re re) -6.75)))))
double code(double re, double im) {
	double tmp;
	if (im <= -2.3e+171) {
		tmp = (0.5 * (re * (im * re))) - im;
	} else if (im <= -4.1e+18) {
		tmp = (re * re) * 0.75;
	} else if (im <= 520.0) {
		tmp = -im;
	} else {
		tmp = (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 (im <= (-2.3d+171)) then
        tmp = (0.5d0 * (re * (im * re))) - im
    else if (im <= (-4.1d+18)) then
        tmp = (re * re) * 0.75d0
    else if (im <= 520.0d0) then
        tmp = -im
    else
        tmp = (re * re) * (-6.75d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -2.3e+171) {
		tmp = (0.5 * (re * (im * re))) - im;
	} else if (im <= -4.1e+18) {
		tmp = (re * re) * 0.75;
	} else if (im <= 520.0) {
		tmp = -im;
	} else {
		tmp = (re * re) * -6.75;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -2.3e+171:
		tmp = (0.5 * (re * (im * re))) - im
	elif im <= -4.1e+18:
		tmp = (re * re) * 0.75
	elif im <= 520.0:
		tmp = -im
	else:
		tmp = (re * re) * -6.75
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -2.3e+171)
		tmp = Float64(Float64(0.5 * Float64(re * Float64(im * re))) - im);
	elseif (im <= -4.1e+18)
		tmp = Float64(Float64(re * re) * 0.75);
	elseif (im <= 520.0)
		tmp = Float64(-im);
	else
		tmp = Float64(Float64(re * re) * -6.75);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -2.3e+171)
		tmp = (0.5 * (re * (im * re))) - im;
	elseif (im <= -4.1e+18)
		tmp = (re * re) * 0.75;
	elseif (im <= 520.0)
		tmp = -im;
	else
		tmp = (re * re) * -6.75;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -2.3e+171], N[(N[(0.5 * N[(re * N[(im * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, -4.1e+18], N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision], If[LessEqual[im, 520.0], (-im), N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 520:\\
\;\;\;\;-im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -2.30000000000000017e171

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.30000000000000017e171 < im < -4.1e18

    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-out55.6%

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

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

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

        \[\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*55.6%

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

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

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow226.9%

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

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

    if -4.1e18 < im < 520

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-im} \]
    9. Simplified54.0%

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

    if 520 < 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-out71.6%

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

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

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

        \[\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*71.6%

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

      \[\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 re around inf 16.2%

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

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

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

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

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(-0.25 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
    10. Applied egg-rr19.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.3 \cdot 10^{+171}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq -4.1 \cdot 10^{+18}:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{elif}\;im \leq 520:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \]

Alternative 12: 34.2% accurate, 33.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -5.2 \cdot 10^{+160} \lor \neg \left(re \leq 1.15 \cdot 10^{+176}\right):\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.75\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -5.2000000000000001e160 or 1.14999999999999998e176 < re

    1. Initial program 63.3%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified63.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.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-out23.7%

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

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

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
      6. unpow223.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*23.7%

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

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

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow227.7%

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

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

    if -5.2000000000000001e160 < re < 1.14999999999999998e176

    1. Initial program 56.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -5.2 \cdot 10^{+160} \lor \neg \left(re \leq 1.15 \cdot 10^{+176}\right):\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot -2\right)\\ \end{array} \]

Alternative 13: 30.3% accurate, 61.8× speedup?

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

\\
0.5 \cdot \left(im \cdot -2\right)
\end{array}
Derivation
  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 46.3%

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

    \[\leadsto 0.5 \cdot \color{blue}{\left(-2 \cdot im\right)} \]
  6. Final simplification27.2%

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

Alternative 14: 30.3% 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 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 im around 0 47.3%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-im} \]
  10. Final simplification26.9%

    \[\leadsto -im \]

Alternative 15: 2.9% accurate, 309.0× speedup?

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

\\
-1.5
\end{array}
Derivation
  1. Initial program 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 2.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. *-commutative2.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*2.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-out41.0%

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

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

      \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
    6. unpow241.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*41.0%

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

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

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

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

    \[\leadsto -1.5 \]

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 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 2.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. *-commutative2.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*2.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-out41.0%

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

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

      \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{{re}^{2} \cdot -0.25}\right) \]
    6. unpow241.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*41.0%

      \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + \color{blue}{re \cdot \left(re \cdot -0.25\right)}\right) \]
  6. Simplified41.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 re around inf 13.7%

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

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

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

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

    \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(-0.25 \cdot \left(e^{-im} - e^{im}\right)\right)} \]
  10. Step-by-step derivation
    1. expm1-log1p-u6.6%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot \left(e^{-im} - e^{im}\right)\right)\right)\right)} \]
    2. expm1-udef6.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot \left(e^{-im} - e^{im}\right)\right)\right)} - 1} \]
    3. associate-*l*7.2%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{re \cdot \left(re \cdot \left(-0.25 \cdot \left(e^{-im} - e^{im}\right)\right)\right)}\right)} - 1 \]
    4. add-sqr-sqrt1.3%

      \[\leadsto e^{\mathsf{log1p}\left(re \cdot \left(re \cdot \left(-0.25 \cdot \left(e^{\color{blue}{\sqrt{-im} \cdot \sqrt{-im}}} - e^{im}\right)\right)\right)\right)} - 1 \]
    5. sqrt-unprod2.5%

      \[\leadsto e^{\mathsf{log1p}\left(re \cdot \left(re \cdot \left(-0.25 \cdot \left(e^{\color{blue}{\sqrt{\left(-im\right) \cdot \left(-im\right)}}} - e^{im}\right)\right)\right)\right)} - 1 \]
    6. sqr-neg2.5%

      \[\leadsto e^{\mathsf{log1p}\left(re \cdot \left(re \cdot \left(-0.25 \cdot \left(e^{\sqrt{\color{blue}{im \cdot im}}} - e^{im}\right)\right)\right)\right)} - 1 \]
    7. sqrt-unprod1.2%

      \[\leadsto e^{\mathsf{log1p}\left(re \cdot \left(re \cdot \left(-0.25 \cdot \left(e^{\color{blue}{\sqrt{im} \cdot \sqrt{im}}} - e^{im}\right)\right)\right)\right)} - 1 \]
    8. add-sqr-sqrt2.9%

      \[\leadsto e^{\mathsf{log1p}\left(re \cdot \left(re \cdot \left(-0.25 \cdot \left(e^{\color{blue}{im}} - e^{im}\right)\right)\right)\right)} - 1 \]
  11. Applied egg-rr2.9%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re \cdot \left(re \cdot \left(-0.25 \cdot \left(e^{im} - e^{im}\right)\right)\right)\right)} - 1} \]
  12. Step-by-step derivation
    1. expm1-def2.9%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot \left(re \cdot \left(-0.25 \cdot \left(e^{im} - e^{im}\right)\right)\right)\right)\right)} \]
    2. expm1-log1p2.9%

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

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

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

      \[\leadsto {re}^{2} \cdot \left(-0.25 \cdot \color{blue}{0}\right) \]
    6. metadata-eval2.6%

      \[\leadsto {re}^{2} \cdot \color{blue}{0} \]
    7. mul0-rgt3.4%

      \[\leadsto \color{blue}{0} \]
  13. Simplified3.4%

    \[\leadsto \color{blue}{0} \]
  14. Final simplification3.4%

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