math.sin on complex, imaginary part

Percentage Accurate: 53.5% → 99.8%
Time: 11.8s
Alternatives: 21
Speedup: 2.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 21 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.5% 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.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -1 \lor \neg \left(t_0 \leq 0.04\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(\left({im}^{3} \cdot -0.16666666666666666 + {im}^{5} \cdot -0.008333333333333333\right) - im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 -1.0) (not (<= t_0 0.04)))
     (* (* 0.5 (cos re)) t_0)
     (*
      (cos re)
      (-
       (+
        (* (pow im 3.0) -0.16666666666666666)
        (* (pow im 5.0) -0.008333333333333333))
       im)))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -1.0) || !(t_0 <= 0.04)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * (((pow(im, 3.0) * -0.16666666666666666) + (pow(im, 5.0) * -0.008333333333333333)) - im);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-im) - exp(im)
    if ((t_0 <= (-1.0d0)) .or. (.not. (t_0 <= 0.04d0))) then
        tmp = (0.5d0 * cos(re)) * t_0
    else
        tmp = cos(re) * ((((im ** 3.0d0) * (-0.16666666666666666d0)) + ((im ** 5.0d0) * (-0.008333333333333333d0))) - im)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -1.0) || !(t_0 <= 0.04)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = Math.cos(re) * (((Math.pow(im, 3.0) * -0.16666666666666666) + (Math.pow(im, 5.0) * -0.008333333333333333)) - im);
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -1.0) or not (t_0 <= 0.04):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = math.cos(re) * (((math.pow(im, 3.0) * -0.16666666666666666) + (math.pow(im, 5.0) * -0.008333333333333333)) - im)
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= -1.0) || !(t_0 <= 0.04))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(cos(re) * Float64(Float64(Float64((im ^ 3.0) * -0.16666666666666666) + Float64((im ^ 5.0) * -0.008333333333333333)) - im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -1.0) || ~((t_0 <= 0.04)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = cos(re) * ((((im ^ 3.0) * -0.16666666666666666) + ((im ^ 5.0) * -0.008333333333333333)) - 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, -1.0], N[Not[LessEqual[t$95$0, 0.04]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 9.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -1 \lor \neg \left(e^{-im} - e^{im} \leq 0.04\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(\left({im}^{3} \cdot -0.16666666666666666 + {im}^{5} \cdot -0.008333333333333333\right) - im\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 -1 \lor \neg \left(t_0 \leq 2 \cdot 10^{-11}\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 -1.0) (not (<= t_0 2e-11)))
     (* (* 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 <= -1.0) || !(t_0 <= 2e-11)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-im) - exp(im)
    if ((t_0 <= (-1.0d0)) .or. (.not. (t_0 <= 2d-11))) then
        tmp = (0.5d0 * cos(re)) * t_0
    else
        tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -1.0) || !(t_0 <= 2e-11)) {
		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 <= -1.0) or not (t_0 <= 2e-11):
		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 <= -1.0) || !(t_0 <= 2e-11))
		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 <= -1.0) || ~((t_0 <= 2e-11)))
		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, -1.0], N[Not[LessEqual[t$95$0, 2e-11]], $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 -1 \lor \neg \left(t_0 \leq 2 \cdot 10^{-11}\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)) < -1 or 1.99999999999999988e-11 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 99.9%

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

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

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

    if -1 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1.99999999999999988e-11

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

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

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

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

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

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

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

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

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

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

      \[\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 -1 \lor \neg \left(e^{-im} - e^{im} \leq 2 \cdot 10^{-11}\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: 96.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ t_1 := 0.5 \cdot \cos re\\ \mathbf{if}\;t_0 \leq -1:\\ \;\;\;\;t_1 \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(im \cdot -2 + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* 0.5 (cos re))))
   (if (<= t_0 -1.0)
     (* t_1 t_0)
     (*
      t_1
      (+
       (* im -2.0)
       (+
        (* -0.3333333333333333 (pow im 3.0))
        (+
         (* -0.016666666666666666 (pow im 5.0))
         (* -0.0003968253968253968 (pow im 7.0)))))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double t_1 = 0.5 * cos(re);
	double tmp;
	if (t_0 <= -1.0) {
		tmp = t_1 * t_0;
	} else {
		tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * pow(im, 3.0)) + ((-0.016666666666666666 * pow(im, 5.0)) + (-0.0003968253968253968 * pow(im, 7.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) :: t_1
    real(8) :: tmp
    t_0 = exp(-im) - exp(im)
    t_1 = 0.5d0 * cos(re)
    if (t_0 <= (-1.0d0)) then
        tmp = t_1 * t_0
    else
        tmp = t_1 * ((im * (-2.0d0)) + (((-0.3333333333333333d0) * (im ** 3.0d0)) + (((-0.016666666666666666d0) * (im ** 5.0d0)) + ((-0.0003968253968253968d0) * (im ** 7.0d0)))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double t_1 = 0.5 * Math.cos(re);
	double tmp;
	if (t_0 <= -1.0) {
		tmp = t_1 * t_0;
	} else {
		tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * Math.pow(im, 3.0)) + ((-0.016666666666666666 * Math.pow(im, 5.0)) + (-0.0003968253968253968 * Math.pow(im, 7.0)))));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	t_1 = 0.5 * math.cos(re)
	tmp = 0
	if t_0 <= -1.0:
		tmp = t_1 * t_0
	else:
		tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * math.pow(im, 3.0)) + ((-0.016666666666666666 * math.pow(im, 5.0)) + (-0.0003968253968253968 * math.pow(im, 7.0)))))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	t_1 = Float64(0.5 * cos(re))
	tmp = 0.0
	if (t_0 <= -1.0)
		tmp = Float64(t_1 * t_0);
	else
		tmp = Float64(t_1 * Float64(Float64(im * -2.0) + Float64(Float64(-0.3333333333333333 * (im ^ 3.0)) + Float64(Float64(-0.016666666666666666 * (im ^ 5.0)) + Float64(-0.0003968253968253968 * (im ^ 7.0))))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	t_1 = 0.5 * cos(re);
	tmp = 0.0;
	if (t_0 <= -1.0)
		tmp = t_1 * t_0;
	else
		tmp = t_1 * ((im * -2.0) + ((-0.3333333333333333 * (im ^ 3.0)) + ((-0.016666666666666666 * (im ^ 5.0)) + (-0.0003968253968253968 * (im ^ 7.0)))));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1.0], N[(t$95$1 * t$95$0), $MachinePrecision], N[(t$95$1 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.016666666666666666 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision] + N[(-0.0003968253968253968 * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := 0.5 \cdot \cos re\\
\mathbf{if}\;t_0 \leq -1:\\
\;\;\;\;t_1 \cdot t_0\\

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


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

    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. neg-sub0100.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 -1 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 41.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -1:\\ \;\;\;\;\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.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)\\ \end{array} \]

Alternative 4: 96.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -1:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 + {im}^{7} \cdot -0.0001984126984126984\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (<= t_0 -1.0)
     (* (* 0.5 (cos re)) t_0)
     (*
      (cos re)
      (+
       (+
        (* (pow im 5.0) -0.008333333333333333)
        (* (pow im 7.0) -0.0001984126984126984))
       (- (* (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 <= -1.0) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * (((pow(im, 5.0) * -0.008333333333333333) + (pow(im, 7.0) * -0.0001984126984126984)) + ((pow(im, 3.0) * -0.16666666666666666) - im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-im) - exp(im)
    if (t_0 <= (-1.0d0)) then
        tmp = (0.5d0 * cos(re)) * t_0
    else
        tmp = cos(re) * ((((im ** 5.0d0) * (-0.008333333333333333d0)) + ((im ** 7.0d0) * (-0.0001984126984126984d0))) + (((im ** 3.0d0) * (-0.16666666666666666d0)) - im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if (t_0 <= -1.0) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = Math.cos(re) * (((Math.pow(im, 5.0) * -0.008333333333333333) + (Math.pow(im, 7.0) * -0.0001984126984126984)) + ((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 <= -1.0:
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = math.cos(re) * (((math.pow(im, 5.0) * -0.008333333333333333) + (math.pow(im, 7.0) * -0.0001984126984126984)) + ((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 <= -1.0)
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(cos(re) * Float64(Float64(Float64((im ^ 5.0) * -0.008333333333333333) + Float64((im ^ 7.0) * -0.0001984126984126984)) + 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 <= -1.0)
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = cos(re) * ((((im ^ 5.0) * -0.008333333333333333) + ((im ^ 7.0) * -0.0001984126984126984)) + (((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[LessEqual[t$95$0, -1.0], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision] + N[(N[Power[im, 7.0], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    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. neg-sub0100.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 -1 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 41.3%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + \left(-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + \left(-0.008333333333333333 \cdot \left({im}^{5} \cdot \cos re\right) + -0.0001984126984126984 \cdot \left({im}^{7} \cdot \cos re\right)\right)\right)} \]
    6. Step-by-step derivation
      1. associate-+r+98.9%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)\right) + \left(-0.008333333333333333 \cdot \left({im}^{5} \cdot \cos re\right) + -0.0001984126984126984 \cdot \left({im}^{7} \cdot \cos re\right)\right)} \]
      2. +-commutative98.9%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + -1 \cdot \left(im \cdot \cos re\right)\right)} + \left(-0.008333333333333333 \cdot \left({im}^{5} \cdot \cos re\right) + -0.0001984126984126984 \cdot \left({im}^{7} \cdot \cos re\right)\right) \]
      3. associate-*r*98.9%

        \[\leadsto \left(\color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} + -1 \cdot \left(im \cdot \cos re\right)\right) + \left(-0.008333333333333333 \cdot \left({im}^{5} \cdot \cos re\right) + -0.0001984126984126984 \cdot \left({im}^{7} \cdot \cos re\right)\right) \]
      4. neg-mul-198.9%

        \[\leadsto \left(\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re + \color{blue}{\left(-im \cdot \cos re\right)}\right) + \left(-0.008333333333333333 \cdot \left({im}^{5} \cdot \cos re\right) + -0.0001984126984126984 \cdot \left({im}^{7} \cdot \cos re\right)\right) \]
      5. distribute-lft-neg-in98.9%

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

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

        \[\leadsto \cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} + \left(-im\right)\right) + \left(\color{blue}{\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \cos re} + -0.0001984126984126984 \cdot \left({im}^{7} \cdot \cos re\right)\right) \]
      8. associate-*r*98.9%

        \[\leadsto \cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} + \left(-im\right)\right) + \left(\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \cos re + \color{blue}{\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \cos re}\right) \]
      9. distribute-rgt-out98.9%

        \[\leadsto \cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} + \left(-im\right)\right) + \color{blue}{\cos re \cdot \left(-0.008333333333333333 \cdot {im}^{5} + -0.0001984126984126984 \cdot {im}^{7}\right)} \]
      10. distribute-lft-out98.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -1:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 + {im}^{7} \cdot -0.0001984126984126984\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)\\ \end{array} \]

Alternative 5: 95.1% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
t_1 := e^{-im} - e^{im}\\
t_2 := 0.5 \cdot t_1\\
\mathbf{if}\;im \leq -5.7:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 3.6 \cdot 10^{+14}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;im \leq 1.05 \cdot 10^{+25}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(t_1 \cdot -0.25\right)\\

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -5.70000000000000018 or 1.09999999999999998e44 < 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. neg-sub0100.0%

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

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

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

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left({im}^{7} \cdot \cos re\right)} \]
    6. Step-by-step derivation
      1. *-commutative98.3%

        \[\leadsto \color{blue}{\left({im}^{7} \cdot \cos re\right) \cdot -0.0001984126984126984} \]
      2. associate-*l*98.3%

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

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

    if -5.70000000000000018 < im < 0.0290000000000000015

    1. Initial program 9.4%

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

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

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

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

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

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

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

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

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

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

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

    if 0.0290000000000000015 < im < 3.6e14 or 1.05e25 < im < 1.09999999999999998e44

    1. Initial program 99.9%

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

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

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

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

    if 3.6e14 < im < 1.05e25

    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. neg-sub0100.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({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.7:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{elif}\;im \leq 0.029:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 3.6 \cdot 10^{+14}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 1.05 \cdot 10^{+25}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(\left(e^{-im} - e^{im}\right) \cdot -0.25\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \end{array} \]

Alternative 6: 95.3% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -5.7:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -5.70000000000000018 or 1.09999999999999998e44 < 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. neg-sub0100.0%

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

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

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

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left({im}^{7} \cdot \cos re\right)} \]
    6. Step-by-step derivation
      1. *-commutative98.3%

        \[\leadsto \color{blue}{\left({im}^{7} \cdot \cos re\right) \cdot -0.0001984126984126984} \]
      2. associate-*l*98.3%

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

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

    if -5.70000000000000018 < im < 0.0420000000000000026

    1. Initial program 9.4%

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

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

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

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

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

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

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

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

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

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

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

    if 0.0420000000000000026 < im < 1.09999999999999998e44

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.7:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{elif}\;im \leq 0.042:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \end{array} \]

Alternative 7: 87.1% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{if}\;im \leq -0.0102:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 2 \cdot 10^{+103}:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -0.010200000000000001 or 0.00104999999999999994 < im < 2e103

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

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

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

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

    if -0.010200000000000001 < im < 0.00104999999999999994

    1. Initial program 9.4%

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

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

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

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

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

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

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

    if 2e103 < im < 1.9999999999999998e165

    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. neg-sub0100.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({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

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

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

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

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

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

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

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

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

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

    if 1.9999999999999998e165 < 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. neg-sub0100.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({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot -2\right) \cdot im} + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      3. metadata-eval96.2%

        \[\leadsto \color{blue}{-1} \cdot im + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      4. neg-mul-196.2%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      5. associate-*r*96.2%

        \[\leadsto \left(-im\right) + \color{blue}{\left(0.5 \cdot -0.3333333333333333\right) \cdot {im}^{3}} \]
      6. metadata-eval96.2%

        \[\leadsto \left(-im\right) + \color{blue}{-0.16666666666666666} \cdot {im}^{3} \]
      7. *-commutative96.2%

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

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

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666 - im} \]
      10. *-commutative96.2%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} - im \]
    10. Simplified96.2%

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

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

Alternative 8: 93.4% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \mathbf{if}\;im \leq -3.3:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.00059:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+58}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 5.0) (* (cos re) -0.008333333333333333))))
   (if (<= im -3.3)
     t_0
     (if (<= im 0.00059)
       (* (cos re) (- im))
       (if (<= im 1.6e+58) (* 0.5 (- (exp (- im)) (exp im))) t_0)))))
double code(double re, double im) {
	double t_0 = pow(im, 5.0) * (cos(re) * -0.008333333333333333);
	double tmp;
	if (im <= -3.3) {
		tmp = t_0;
	} else if (im <= 0.00059) {
		tmp = cos(re) * -im;
	} else if (im <= 1.6e+58) {
		tmp = 0.5 * (exp(-im) - exp(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 = (im ** 5.0d0) * (cos(re) * (-0.008333333333333333d0))
    if (im <= (-3.3d0)) then
        tmp = t_0
    else if (im <= 0.00059d0) then
        tmp = cos(re) * -im
    else if (im <= 1.6d+58) then
        tmp = 0.5d0 * (exp(-im) - exp(im))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 5.0) * (Math.cos(re) * -0.008333333333333333);
	double tmp;
	if (im <= -3.3) {
		tmp = t_0;
	} else if (im <= 0.00059) {
		tmp = Math.cos(re) * -im;
	} else if (im <= 1.6e+58) {
		tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 5.0) * (math.cos(re) * -0.008333333333333333)
	tmp = 0
	if im <= -3.3:
		tmp = t_0
	elif im <= 0.00059:
		tmp = math.cos(re) * -im
	elif im <= 1.6e+58:
		tmp = 0.5 * (math.exp(-im) - math.exp(im))
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 5.0) * Float64(cos(re) * -0.008333333333333333))
	tmp = 0.0
	if (im <= -3.3)
		tmp = t_0;
	elseif (im <= 0.00059)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 1.6e+58)
		tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 5.0) * (cos(re) * -0.008333333333333333);
	tmp = 0.0;
	if (im <= -3.3)
		tmp = t_0;
	elseif (im <= 0.00059)
		tmp = cos(re) * -im;
	elseif (im <= 1.6e+58)
		tmp = 0.5 * (exp(-im) - exp(im));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 5.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3.3], t$95$0, If[LessEqual[im, 0.00059], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1.6e+58], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\
\mathbf{if}\;im \leq -3.3:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 1.6 \cdot 10^{+58}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -3.2999999999999998 or 1.60000000000000008e58 < 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. neg-sub0100.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 92.5%

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

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

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

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

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

    if -3.2999999999999998 < im < 5.9000000000000003e-4

    1. Initial program 9.4%

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

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

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

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

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

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

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

    if 5.9000000000000003e-4 < im < 1.60000000000000008e58

    1. Initial program 99.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.3:\\ \;\;\;\;{im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \mathbf{elif}\;im \leq 0.00059:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+58}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{5} \cdot \left(\cos re \cdot -0.008333333333333333\right)\\ \end{array} \]

Alternative 9: 95.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{if}\;im \leq -4.2:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.00126:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 7.0) (* (cos re) -0.0001984126984126984))))
   (if (<= im -4.2)
     t_0
     (if (<= im 0.00126)
       (* (cos re) (- im))
       (if (<= im 1.1e+44) (* 0.5 (- (exp (- im)) (exp im))) t_0)))))
double code(double re, double im) {
	double t_0 = pow(im, 7.0) * (cos(re) * -0.0001984126984126984);
	double tmp;
	if (im <= -4.2) {
		tmp = t_0;
	} else if (im <= 0.00126) {
		tmp = cos(re) * -im;
	} else if (im <= 1.1e+44) {
		tmp = 0.5 * (exp(-im) - exp(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 = (im ** 7.0d0) * (cos(re) * (-0.0001984126984126984d0))
    if (im <= (-4.2d0)) then
        tmp = t_0
    else if (im <= 0.00126d0) then
        tmp = cos(re) * -im
    else if (im <= 1.1d+44) then
        tmp = 0.5d0 * (exp(-im) - exp(im))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 7.0) * (Math.cos(re) * -0.0001984126984126984);
	double tmp;
	if (im <= -4.2) {
		tmp = t_0;
	} else if (im <= 0.00126) {
		tmp = Math.cos(re) * -im;
	} else if (im <= 1.1e+44) {
		tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 7.0) * (math.cos(re) * -0.0001984126984126984)
	tmp = 0
	if im <= -4.2:
		tmp = t_0
	elif im <= 0.00126:
		tmp = math.cos(re) * -im
	elif im <= 1.1e+44:
		tmp = 0.5 * (math.exp(-im) - math.exp(im))
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 7.0) * Float64(cos(re) * -0.0001984126984126984))
	tmp = 0.0
	if (im <= -4.2)
		tmp = t_0;
	elseif (im <= 0.00126)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 1.1e+44)
		tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 7.0) * (cos(re) * -0.0001984126984126984);
	tmp = 0.0;
	if (im <= -4.2)
		tmp = t_0;
	elseif (im <= 0.00126)
		tmp = cos(re) * -im;
	elseif (im <= 1.1e+44)
		tmp = 0.5 * (exp(-im) - exp(im));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.2], t$95$0, If[LessEqual[im, 0.00126], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1.1e+44], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -4.2:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4.20000000000000018 or 1.09999999999999998e44 < 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. neg-sub0100.0%

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

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

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

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left({im}^{7} \cdot \cos re\right)} \]
    6. Step-by-step derivation
      1. *-commutative98.3%

        \[\leadsto \color{blue}{\left({im}^{7} \cdot \cos re\right) \cdot -0.0001984126984126984} \]
      2. associate-*l*98.3%

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

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

    if -4.20000000000000018 < im < 0.00126000000000000005

    1. Initial program 9.4%

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

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

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

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

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

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

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

    if 0.00126000000000000005 < im < 1.09999999999999998e44

    1. Initial program 99.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.2:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{elif}\;im \leq 0.00126:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \end{array} \]

Alternative 10: 95.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{if}\;im \leq -6.8:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.00125:\\ \;\;\;\;\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 7.0) (* (cos re) -0.0001984126984126984))))
   (if (<= im -6.8)
     t_0
     (if (<= im 0.00125)
       (* (cos re) (- (* (pow im 5.0) -0.008333333333333333) im))
       (if (<= im 1.1e+44) (* 0.5 (- (exp (- im)) (exp im))) t_0)))))
double code(double re, double im) {
	double t_0 = pow(im, 7.0) * (cos(re) * -0.0001984126984126984);
	double tmp;
	if (im <= -6.8) {
		tmp = t_0;
	} else if (im <= 0.00125) {
		tmp = cos(re) * ((pow(im, 5.0) * -0.008333333333333333) - im);
	} else if (im <= 1.1e+44) {
		tmp = 0.5 * (exp(-im) - exp(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 = (im ** 7.0d0) * (cos(re) * (-0.0001984126984126984d0))
    if (im <= (-6.8d0)) then
        tmp = t_0
    else if (im <= 0.00125d0) then
        tmp = cos(re) * (((im ** 5.0d0) * (-0.008333333333333333d0)) - im)
    else if (im <= 1.1d+44) then
        tmp = 0.5d0 * (exp(-im) - exp(im))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 7.0) * (Math.cos(re) * -0.0001984126984126984);
	double tmp;
	if (im <= -6.8) {
		tmp = t_0;
	} else if (im <= 0.00125) {
		tmp = Math.cos(re) * ((Math.pow(im, 5.0) * -0.008333333333333333) - im);
	} else if (im <= 1.1e+44) {
		tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 7.0) * (math.cos(re) * -0.0001984126984126984)
	tmp = 0
	if im <= -6.8:
		tmp = t_0
	elif im <= 0.00125:
		tmp = math.cos(re) * ((math.pow(im, 5.0) * -0.008333333333333333) - im)
	elif im <= 1.1e+44:
		tmp = 0.5 * (math.exp(-im) - math.exp(im))
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 7.0) * Float64(cos(re) * -0.0001984126984126984))
	tmp = 0.0
	if (im <= -6.8)
		tmp = t_0;
	elseif (im <= 0.00125)
		tmp = Float64(cos(re) * Float64(Float64((im ^ 5.0) * -0.008333333333333333) - im));
	elseif (im <= 1.1e+44)
		tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 7.0) * (cos(re) * -0.0001984126984126984);
	tmp = 0.0;
	if (im <= -6.8)
		tmp = t_0;
	elseif (im <= 0.00125)
		tmp = cos(re) * (((im ^ 5.0) * -0.008333333333333333) - im);
	elseif (im <= 1.1e+44)
		tmp = 0.5 * (exp(-im) - exp(im));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.8], t$95$0, If[LessEqual[im, 0.00125], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.1e+44], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -6.8:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 0.00125:\\
\;\;\;\;\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333 - im\right)\\

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -6.79999999999999982 or 1.09999999999999998e44 < 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. neg-sub0100.0%

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

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

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

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left({im}^{7} \cdot \cos re\right)} \]
    6. Step-by-step derivation
      1. *-commutative98.3%

        \[\leadsto \color{blue}{\left({im}^{7} \cdot \cos re\right) \cdot -0.0001984126984126984} \]
      2. associate-*l*98.3%

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

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

    if -6.79999999999999982 < im < 0.00125000000000000003

    1. Initial program 9.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.00125000000000000003 < im < 1.09999999999999998e44

    1. Initial program 99.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.8:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{elif}\;im \leq 0.00125:\\ \;\;\;\;\cos re \cdot \left({im}^{5} \cdot -0.008333333333333333 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \end{array} \]

Alternative 11: 95.5% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -5.7:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -5.70000000000000018 or 1.09999999999999998e44 < 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. neg-sub0100.0%

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

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

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

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left({im}^{7} \cdot \cos re\right)} \]
    6. Step-by-step derivation
      1. *-commutative98.3%

        \[\leadsto \color{blue}{\left({im}^{7} \cdot \cos re\right) \cdot -0.0001984126984126984} \]
      2. associate-*l*98.3%

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

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

    if -5.70000000000000018 < im < 0.060999999999999999

    1. Initial program 9.4%

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

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

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

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

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

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

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

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

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

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

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

    if 0.060999999999999999 < im < 1.09999999999999998e44

    1. Initial program 99.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.7:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{elif}\;im \leq 0.061:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \end{array} \]

Alternative 12: 76.4% accurate, 2.5× speedup?

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

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

\mathbf{elif}\;im \leq 8.6 \cdot 10^{-8}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\

\mathbf{elif}\;im \leq 8.5 \cdot 10^{+165}:\\
\;\;\;\;\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(im \cdot -2 + -0.3333333333333333 \cdot {im}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -9.4999999999999997e56 or 8.5000000000000001e165 < 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. neg-sub0100.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({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot -2\right) \cdot im} + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      3. metadata-eval78.7%

        \[\leadsto \color{blue}{-1} \cdot im + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      4. neg-mul-178.7%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      5. associate-*r*78.7%

        \[\leadsto \left(-im\right) + \color{blue}{\left(0.5 \cdot -0.3333333333333333\right) \cdot {im}^{3}} \]
      6. metadata-eval78.7%

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

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

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

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666 - im} \]
      10. *-commutative78.7%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} - im \]
    10. Simplified78.7%

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

    if -9.4999999999999997e56 < im < 8.6000000000000002e-8

    1. Initial program 12.8%

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

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

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

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

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

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

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

    if 8.6000000000000002e-8 < im < 8.5000000000000001e165

    1. Initial program 98.3%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -9.5 \cdot 10^{+56}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 8.6 \cdot 10^{-8}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 8.5 \cdot 10^{+165}:\\ \;\;\;\;\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(im \cdot -2 + -0.3333333333333333 \cdot {im}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 13: 76.5% accurate, 2.6× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.20000000000000002e57 or 9.99999999999999899e164 < 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. neg-sub0100.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({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot -2\right) \cdot im} + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      3. metadata-eval78.7%

        \[\leadsto \color{blue}{-1} \cdot im + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      4. neg-mul-178.7%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      5. associate-*r*78.7%

        \[\leadsto \left(-im\right) + \color{blue}{\left(0.5 \cdot -0.3333333333333333\right) \cdot {im}^{3}} \]
      6. metadata-eval78.7%

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

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

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

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666 - im} \]
      10. *-commutative78.7%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} - im \]
    10. Simplified78.7%

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

    if -1.20000000000000002e57 < im < 4.2e10

    1. Initial program 19.2%

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

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

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

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

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

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

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

    if 4.2e10 < im < 9.99999999999999899e164

    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. neg-sub0100.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({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

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

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

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

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

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

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

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

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

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

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

Alternative 14: 76.1% accurate, 2.7× speedup?

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

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

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

\mathbf{elif}\;im \leq 3.25 \cdot 10^{+103}:\\
\;\;\;\;{im}^{3} \cdot \left(\left(re \cdot re\right) \cdot 0.08333333333333333\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -7.19999999999999996e56 or 3.25000000000000001e103 < 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. neg-sub0100.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({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot -2\right) \cdot im} + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      3. metadata-eval75.2%

        \[\leadsto \color{blue}{-1} \cdot im + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      4. neg-mul-175.2%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      5. associate-*r*75.2%

        \[\leadsto \left(-im\right) + \color{blue}{\left(0.5 \cdot -0.3333333333333333\right) \cdot {im}^{3}} \]
      6. metadata-eval75.2%

        \[\leadsto \left(-im\right) + \color{blue}{-0.16666666666666666} \cdot {im}^{3} \]
      7. *-commutative75.2%

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

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

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666 - im} \]
      10. *-commutative75.2%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} - im \]
    10. Simplified75.2%

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

    if -7.19999999999999996e56 < im < 3.1e10

    1. Initial program 19.2%

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

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

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

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

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

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

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

    if 3.1e10 < im < 3.25000000000000001e103

    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. neg-sub0100.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({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.08333333333333333 \cdot \left({im}^{3} \cdot {re}^{2}\right)} \]
    12. Step-by-step derivation
      1. *-commutative31.3%

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

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

        \[\leadsto {im}^{3} \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.08333333333333333\right) \]
    13. Simplified31.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.2 \cdot 10^{+56}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 31000000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 3.25 \cdot 10^{+103}:\\ \;\;\;\;{im}^{3} \cdot \left(\left(re \cdot re\right) \cdot 0.08333333333333333\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 15: 75.5% accurate, 2.8× speedup?

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

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

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

\mathbf{elif}\;im \leq 4.2 \cdot 10^{+70}:\\
\;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot re\right)\right) - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -9.4999999999999997e56 or 4.20000000000000015e70 < 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. neg-sub0100.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({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot -2\right) \cdot im} + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      3. metadata-eval72.4%

        \[\leadsto \color{blue}{-1} \cdot im + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      4. neg-mul-172.4%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right) \]
      5. associate-*r*72.4%

        \[\leadsto \left(-im\right) + \color{blue}{\left(0.5 \cdot -0.3333333333333333\right) \cdot {im}^{3}} \]
      6. metadata-eval72.4%

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

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

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

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666 - im} \]
      10. *-commutative72.4%

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

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

    if -9.4999999999999997e56 < im < 3.5e10

    1. Initial program 19.2%

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

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

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

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

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

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

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

    if 3.5e10 < im < 4.20000000000000015e70

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -9.5 \cdot 10^{+56}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 35000000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+70}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 16: 59.8% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(im \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{if}\;im \leq -1.25 \cdot 10^{+50}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 100000000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 2.4 \cdot 10^{+182} \lor \neg \left(im \leq 5.5 \cdot 10^{+272}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot -6.75\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (* 0.5 (* im (* re re))) im)))
   (if (<= im -1.25e+50)
     t_0
     (if (<= im 100000000000.0)
       (* (cos re) (- im))
       (if (or (<= im 2.4e+182) (not (<= im 5.5e+272)))
         t_0
         (* re (* re -6.75)))))))
double code(double re, double im) {
	double t_0 = (0.5 * (im * (re * re))) - im;
	double tmp;
	if (im <= -1.25e+50) {
		tmp = t_0;
	} else if (im <= 100000000000.0) {
		tmp = cos(re) * -im;
	} else if ((im <= 2.4e+182) || !(im <= 5.5e+272)) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = (0.5d0 * (im * (re * re))) - im
    if (im <= (-1.25d+50)) then
        tmp = t_0
    else if (im <= 100000000000.0d0) then
        tmp = cos(re) * -im
    else if ((im <= 2.4d+182) .or. (.not. (im <= 5.5d+272))) then
        tmp = t_0
    else
        tmp = re * (re * (-6.75d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (0.5 * (im * (re * re))) - im;
	double tmp;
	if (im <= -1.25e+50) {
		tmp = t_0;
	} else if (im <= 100000000000.0) {
		tmp = Math.cos(re) * -im;
	} else if ((im <= 2.4e+182) || !(im <= 5.5e+272)) {
		tmp = t_0;
	} else {
		tmp = re * (re * -6.75);
	}
	return tmp;
}
def code(re, im):
	t_0 = (0.5 * (im * (re * re))) - im
	tmp = 0
	if im <= -1.25e+50:
		tmp = t_0
	elif im <= 100000000000.0:
		tmp = math.cos(re) * -im
	elif (im <= 2.4e+182) or not (im <= 5.5e+272):
		tmp = t_0
	else:
		tmp = re * (re * -6.75)
	return tmp
function code(re, im)
	t_0 = Float64(Float64(0.5 * Float64(im * Float64(re * re))) - im)
	tmp = 0.0
	if (im <= -1.25e+50)
		tmp = t_0;
	elseif (im <= 100000000000.0)
		tmp = Float64(cos(re) * Float64(-im));
	elseif ((im <= 2.4e+182) || !(im <= 5.5e+272))
		tmp = t_0;
	else
		tmp = Float64(re * Float64(re * -6.75));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (0.5 * (im * (re * re))) - im;
	tmp = 0.0;
	if (im <= -1.25e+50)
		tmp = t_0;
	elseif (im <= 100000000000.0)
		tmp = cos(re) * -im;
	elseif ((im <= 2.4e+182) || ~((im <= 5.5e+272)))
		tmp = t_0;
	else
		tmp = re * (re * -6.75);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[(im * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]}, If[LessEqual[im, -1.25e+50], t$95$0, If[LessEqual[im, 100000000000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[Or[LessEqual[im, 2.4e+182], N[Not[LessEqual[im, 5.5e+272]], $MachinePrecision]], t$95$0, N[(re * N[(re * -6.75), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 2.4 \cdot 10^{+182} \lor \neg \left(im \leq 5.5 \cdot 10^{+272}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.25e50 or 1e11 < im < 2.4000000000000001e182 or 5.4999999999999998e272 < 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. neg-sub0100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.25e50 < im < 1e11

    1. Initial program 17.4%

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

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

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

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

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

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

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

    if 2.4000000000000001e182 < im < 5.4999999999999998e272

    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. neg-sub0100.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({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot -6.75} \]
      2. unpow231.0%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot -6.75 \]
      3. associate-*l*31.0%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -6.75\right)} \]
    10. Simplified31.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.25 \cdot 10^{+50}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq 100000000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 2.4 \cdot 10^{+182} \lor \neg \left(im \leq 5.5 \cdot 10^{+272}\right):\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot -6.75\right)\\ \end{array} \]

Alternative 17: 35.6% accurate, 34.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 18: 31.0% accurate, 43.8× speedup?

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

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

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


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

    1. Initial program 55.4%

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

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

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

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

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

    if 4.99999999999999977e170 < re

    1. Initial program 64.9%

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

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

      \[\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({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot -6.75} \]
      2. unpow245.4%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot -6.75 \]
      3. associate-*l*45.4%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -6.75\right)} \]
    10. Simplified45.4%

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

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

Alternative 19: 29.2% 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 56.5%

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

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

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

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

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

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

Alternative 20: 29.1% 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 56.5%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -im \]

Alternative 21: 2.9% accurate, 309.0× speedup?

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

\\
13.5
\end{array}
Derivation
  1. Initial program 56.5%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 13.5 \]

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