math.sin on complex, imaginary part

Percentage Accurate: 55.1% → 99.2%
Time: 10.8s
Alternatives: 17
Speedup: 2.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 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: 55.1% 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.2% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

    if -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1.00000000000000004e-10

    1. Initial program 6.6%

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

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

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

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

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

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

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

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

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

Alternative 2: 95.6% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.25 \cdot 10^{+101} \lor \neg \left(im \leq -1.65\right) \land \left(im \leq 0.055 \lor \neg \left(im \leq 5.6 \cdot 10^{+102}\right)\right):\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -1.24999999999999997e101 or -1.6499999999999999 < im < 0.0550000000000000003 or 5.60000000000000037e102 < im

    1. Initial program 43.9%

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

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

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

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

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

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

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

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

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

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

    if -1.24999999999999997e101 < im < -1.6499999999999999 or 0.0550000000000000003 < im < 5.60000000000000037e102

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.25 \cdot 10^{+101} \lor \neg \left(im \leq -1.65\right) \land \left(im \leq 0.055 \lor \neg \left(im \leq 5.6 \cdot 10^{+102}\right)\right):\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \end{array} \]

Alternative 3: 95.3% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.6 \cdot 10^{+102} \lor \neg \left(im \leq -1.65\right) \land \left(im \leq 6600 \lor \neg \left(im \leq 3.3 \cdot 10^{+102}\right)\right):\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -5.60000000000000037e102 or -1.6499999999999999 < im < 6600 or 3.29999999999999999e102 < im

    1. Initial program 44.1%

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

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

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

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

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

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

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

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

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

    if -5.60000000000000037e102 < im < -1.6499999999999999 or 6600 < im < 3.29999999999999999e102

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.6 \cdot 10^{+102} \lor \neg \left(im \leq -1.65\right) \land \left(im \leq 6600 \lor \neg \left(im \leq 3.3 \cdot 10^{+102}\right)\right):\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \]

Alternative 4: 89.9% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.5 \cdot 10^{+150}:\\
\;\;\;\;\frac{387420489 - im \cdot im}{\frac{im}{\cos re}}\\

\mathbf{elif}\;im \leq -1.65 \lor \neg \left(im \leq 6600\right):\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{19683 \cdot 19683 - im \cdot im}{19683 + im}} \]
      2. associate-*r/97.1%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(19683 \cdot 19683 - im \cdot im\right)}{19683 + im}} \]
      3. metadata-eval97.1%

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{387420489} - im \cdot im\right)}{19683 + im} \]
      4. +-commutative97.1%

        \[\leadsto \frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} \]
    9. Applied egg-rr97.1%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{im + 19683}} \]
    10. Step-by-step derivation
      1. *-commutative97.1%

        \[\leadsto \frac{\color{blue}{\left(387420489 - im \cdot im\right) \cdot \cos re}}{im + 19683} \]
      2. associate-/l*97.1%

        \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{im + 19683}{\cos re}}} \]
      3. +-commutative97.1%

        \[\leadsto \frac{387420489 - im \cdot im}{\frac{\color{blue}{19683 + im}}{\cos re}} \]
    11. Simplified97.1%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{19683 + im}{\cos re}}} \]
    12. Taylor expanded in im around inf 97.1%

      \[\leadsto \frac{387420489 - im \cdot im}{\color{blue}{\frac{im}{\cos re}}} \]

    if -5.50000000000000017e150 < im < -1.6499999999999999 or 6600 < im

    1. Initial program 100.0%

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

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

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

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

    if -1.6499999999999999 < im < 6600

    1. Initial program 8.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.5 \cdot 10^{+150}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{\frac{im}{\cos re}}\\ \mathbf{elif}\;im \leq -1.65 \lor \neg \left(im \leq 6600\right):\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 5: 83.8% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ t_1 := \frac{387420489 - im \cdot im}{\frac{im}{\cos re}}\\ \mathbf{if}\;im \leq -7.5 \cdot 10^{+163}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -580:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 550:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 2.6 \cdot 10^{+150}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (*
          (+ (* -0.5 (* re re)) 1.0)
          (- (* (pow im 3.0) -0.16666666666666666) im)))
        (t_1 (/ (- 387420489.0 (* im im)) (/ im (cos re)))))
   (if (<= im -7.5e+163)
     t_1
     (if (<= im -580.0)
       t_0
       (if (<= im 550.0) (* im (- (cos re))) (if (<= im 2.6e+150) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = ((-0.5 * (re * re)) + 1.0) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	double t_1 = (387420489.0 - (im * im)) / (im / cos(re));
	double tmp;
	if (im <= -7.5e+163) {
		tmp = t_1;
	} else if (im <= -580.0) {
		tmp = t_0;
	} else if (im <= 550.0) {
		tmp = im * -cos(re);
	} else if (im <= 2.6e+150) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (((-0.5d0) * (re * re)) + 1.0d0) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    t_1 = (387420489.0d0 - (im * im)) / (im / cos(re))
    if (im <= (-7.5d+163)) then
        tmp = t_1
    else if (im <= (-580.0d0)) then
        tmp = t_0
    else if (im <= 550.0d0) then
        tmp = im * -cos(re)
    else if (im <= 2.6d+150) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = ((-0.5 * (re * re)) + 1.0) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	double t_1 = (387420489.0 - (im * im)) / (im / Math.cos(re));
	double tmp;
	if (im <= -7.5e+163) {
		tmp = t_1;
	} else if (im <= -580.0) {
		tmp = t_0;
	} else if (im <= 550.0) {
		tmp = im * -Math.cos(re);
	} else if (im <= 2.6e+150) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = ((-0.5 * (re * re)) + 1.0) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	t_1 = (387420489.0 - (im * im)) / (im / math.cos(re))
	tmp = 0
	if im <= -7.5e+163:
		tmp = t_1
	elif im <= -580.0:
		tmp = t_0
	elif im <= 550.0:
		tmp = im * -math.cos(re)
	elif im <= 2.6e+150:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(Float64(-0.5 * Float64(re * re)) + 1.0) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im))
	t_1 = Float64(Float64(387420489.0 - Float64(im * im)) / Float64(im / cos(re)))
	tmp = 0.0
	if (im <= -7.5e+163)
		tmp = t_1;
	elseif (im <= -580.0)
		tmp = t_0;
	elseif (im <= 550.0)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 2.6e+150)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = ((-0.5 * (re * re)) + 1.0) * (((im ^ 3.0) * -0.16666666666666666) - im);
	t_1 = (387420489.0 - (im * im)) / (im / cos(re));
	tmp = 0.0;
	if (im <= -7.5e+163)
		tmp = t_1;
	elseif (im <= -580.0)
		tmp = t_0;
	elseif (im <= 550.0)
		tmp = im * -cos(re);
	elseif (im <= 2.6e+150)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(387420489.0 - N[(im * im), $MachinePrecision]), $MachinePrecision] / N[(im / N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.5e+163], t$95$1, If[LessEqual[im, -580.0], t$95$0, If[LessEqual[im, 550.0], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 2.6e+150], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\
t_1 := \frac{387420489 - im \cdot im}{\frac{im}{\cos re}}\\
\mathbf{if}\;im \leq -7.5 \cdot 10^{+163}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 2.6 \cdot 10^{+150}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -7.50000000000000001e163 or 2.60000000000000006e150 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{19683 \cdot 19683 - im \cdot im}{19683 + im}} \]
      2. associate-*r/98.4%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(19683 \cdot 19683 - im \cdot im\right)}{19683 + im}} \]
      3. metadata-eval98.4%

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{387420489} - im \cdot im\right)}{19683 + im} \]
      4. +-commutative98.4%

        \[\leadsto \frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} \]
    9. Applied egg-rr98.4%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{im + 19683}} \]
    10. Step-by-step derivation
      1. *-commutative98.4%

        \[\leadsto \frac{\color{blue}{\left(387420489 - im \cdot im\right) \cdot \cos re}}{im + 19683} \]
      2. associate-/l*98.4%

        \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{im + 19683}{\cos re}}} \]
      3. +-commutative98.4%

        \[\leadsto \frac{387420489 - im \cdot im}{\frac{\color{blue}{19683 + im}}{\cos re}} \]
    11. Simplified98.4%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{19683 + im}{\cos re}}} \]
    12. Taylor expanded in im around inf 98.4%

      \[\leadsto \frac{387420489 - im \cdot im}{\color{blue}{\frac{im}{\cos re}}} \]

    if -7.50000000000000001e163 < im < -580 or 550 < im < 2.60000000000000006e150

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -580 < im < 550

    1. Initial program 7.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.5 \cdot 10^{+163}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{\frac{im}{\cos re}}\\ \mathbf{elif}\;im \leq -580:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 550:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 2.6 \cdot 10^{+150}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{\frac{im}{\cos re}}\\ \end{array} \]

Alternative 6: 79.6% accurate, 2.6× speedup?

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

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

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

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

\mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.65000000000000012e154 or 3.30000000000000027e145 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{19683 \cdot 19683 - im \cdot im}{19683 + im}} \]
      2. associate-*r/96.9%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(19683 \cdot 19683 - im \cdot im\right)}{19683 + im}} \]
      3. metadata-eval96.9%

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{387420489} - im \cdot im\right)}{19683 + im} \]
      4. +-commutative96.9%

        \[\leadsto \frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} \]
    9. Applied egg-rr96.9%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{im + 19683}} \]
    10. Step-by-step derivation
      1. *-commutative96.9%

        \[\leadsto \frac{\color{blue}{\left(387420489 - im \cdot im\right) \cdot \cos re}}{im + 19683} \]
      2. associate-/l*96.9%

        \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{im + 19683}{\cos re}}} \]
      3. +-commutative96.9%

        \[\leadsto \frac{387420489 - im \cdot im}{\frac{\color{blue}{19683 + im}}{\cos re}} \]
    11. Simplified96.9%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{19683 + im}{\cos re}}} \]
    12. Taylor expanded in im around inf 96.9%

      \[\leadsto \frac{387420489 - im \cdot im}{\color{blue}{\frac{im}{\cos re}}} \]

    if -2.65000000000000012e154 < im < -8.8e7 or 700 < im < 3.30000000000000027e145

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
    10. Taylor expanded in re around inf 35.0%

      \[\leadsto \color{blue}{-0.5 \cdot \left({re}^{2} \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\right)} \]
    11. Step-by-step derivation
      1. unpow235.0%

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

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

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right)\right)} \]
    12. Simplified35.0%

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

    if -8.8e7 < im < 700

    1. Initial program 8.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.65 \cdot 10^{+154}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{\frac{im}{\cos re}}\\ \mathbf{elif}\;im \leq -88000000:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 700:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{\frac{im}{\cos re}}\\ \end{array} \]

Alternative 7: 79.5% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 387420489 - im \cdot im\\ t_1 := -0.5 \cdot \frac{t_0 \cdot \left(re \cdot re\right)}{im + 19683} + \frac{t_0}{im + 19683}\\ t_2 := \frac{t_0}{\frac{im}{\cos re}}\\ \mathbf{if}\;im \leq -1.32 \cdot 10^{+154}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq -650:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 86000000000:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- 387420489.0 (* im im)))
        (t_1
         (+
          (* -0.5 (/ (* t_0 (* re re)) (+ im 19683.0)))
          (/ t_0 (+ im 19683.0))))
        (t_2 (/ t_0 (/ im (cos re)))))
   (if (<= im -1.32e+154)
     t_2
     (if (<= im -650.0)
       t_1
       (if (<= im 86000000000.0)
         (* im (- (cos re)))
         (if (<= im 3.3e+145) t_1 t_2))))))
double code(double re, double im) {
	double t_0 = 387420489.0 - (im * im);
	double t_1 = (-0.5 * ((t_0 * (re * re)) / (im + 19683.0))) + (t_0 / (im + 19683.0));
	double t_2 = t_0 / (im / cos(re));
	double tmp;
	if (im <= -1.32e+154) {
		tmp = t_2;
	} else if (im <= -650.0) {
		tmp = t_1;
	} else if (im <= 86000000000.0) {
		tmp = im * -cos(re);
	} else if (im <= 3.3e+145) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	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 = 387420489.0d0 - (im * im)
    t_1 = ((-0.5d0) * ((t_0 * (re * re)) / (im + 19683.0d0))) + (t_0 / (im + 19683.0d0))
    t_2 = t_0 / (im / cos(re))
    if (im <= (-1.32d+154)) then
        tmp = t_2
    else if (im <= (-650.0d0)) then
        tmp = t_1
    else if (im <= 86000000000.0d0) then
        tmp = im * -cos(re)
    else if (im <= 3.3d+145) then
        tmp = t_1
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 387420489.0 - (im * im);
	double t_1 = (-0.5 * ((t_0 * (re * re)) / (im + 19683.0))) + (t_0 / (im + 19683.0));
	double t_2 = t_0 / (im / Math.cos(re));
	double tmp;
	if (im <= -1.32e+154) {
		tmp = t_2;
	} else if (im <= -650.0) {
		tmp = t_1;
	} else if (im <= 86000000000.0) {
		tmp = im * -Math.cos(re);
	} else if (im <= 3.3e+145) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(re, im):
	t_0 = 387420489.0 - (im * im)
	t_1 = (-0.5 * ((t_0 * (re * re)) / (im + 19683.0))) + (t_0 / (im + 19683.0))
	t_2 = t_0 / (im / math.cos(re))
	tmp = 0
	if im <= -1.32e+154:
		tmp = t_2
	elif im <= -650.0:
		tmp = t_1
	elif im <= 86000000000.0:
		tmp = im * -math.cos(re)
	elif im <= 3.3e+145:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(re, im)
	t_0 = Float64(387420489.0 - Float64(im * im))
	t_1 = Float64(Float64(-0.5 * Float64(Float64(t_0 * Float64(re * re)) / Float64(im + 19683.0))) + Float64(t_0 / Float64(im + 19683.0)))
	t_2 = Float64(t_0 / Float64(im / cos(re)))
	tmp = 0.0
	if (im <= -1.32e+154)
		tmp = t_2;
	elseif (im <= -650.0)
		tmp = t_1;
	elseif (im <= 86000000000.0)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 3.3e+145)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 387420489.0 - (im * im);
	t_1 = (-0.5 * ((t_0 * (re * re)) / (im + 19683.0))) + (t_0 / (im + 19683.0));
	t_2 = t_0 / (im / cos(re));
	tmp = 0.0;
	if (im <= -1.32e+154)
		tmp = t_2;
	elseif (im <= -650.0)
		tmp = t_1;
	elseif (im <= 86000000000.0)
		tmp = im * -cos(re);
	elseif (im <= 3.3e+145)
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(387420489.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-0.5 * N[(N[(t$95$0 * N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(im + 19683.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 / N[(im + 19683.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 / N[(im / N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.32e+154], t$95$2, If[LessEqual[im, -650.0], t$95$1, If[LessEqual[im, 86000000000.0], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 3.3e+145], t$95$1, t$95$2]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 387420489 - im \cdot im\\
t_1 := -0.5 \cdot \frac{t_0 \cdot \left(re \cdot re\right)}{im + 19683} + \frac{t_0}{im + 19683}\\
t_2 := \frac{t_0}{\frac{im}{\cos re}}\\
\mathbf{if}\;im \leq -1.32 \cdot 10^{+154}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;im \leq -650:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.31999999999999998e154 or 3.30000000000000027e145 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{19683 \cdot 19683 - im \cdot im}{19683 + im}} \]
      2. associate-*r/97.0%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(19683 \cdot 19683 - im \cdot im\right)}{19683 + im}} \]
      3. metadata-eval97.0%

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{387420489} - im \cdot im\right)}{19683 + im} \]
      4. +-commutative97.0%

        \[\leadsto \frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} \]
    9. Applied egg-rr97.0%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{im + 19683}} \]
    10. Step-by-step derivation
      1. *-commutative97.0%

        \[\leadsto \frac{\color{blue}{\left(387420489 - im \cdot im\right) \cdot \cos re}}{im + 19683} \]
      2. associate-/l*97.0%

        \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{im + 19683}{\cos re}}} \]
      3. +-commutative97.0%

        \[\leadsto \frac{387420489 - im \cdot im}{\frac{\color{blue}{19683 + im}}{\cos re}} \]
    11. Simplified97.0%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{19683 + im}{\cos re}}} \]
    12. Taylor expanded in im around inf 97.0%

      \[\leadsto \frac{387420489 - im \cdot im}{\color{blue}{\frac{im}{\cos re}}} \]

    if -1.31999999999999998e154 < im < -650 or 8.6e10 < im < 3.30000000000000027e145

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{19683 \cdot 19683 - im \cdot im}{19683 + im}} \]
      2. associate-*r/3.8%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(19683 \cdot 19683 - im \cdot im\right)}{19683 + im}} \]
      3. metadata-eval3.8%

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{387420489} - im \cdot im\right)}{19683 + im} \]
      4. +-commutative3.8%

        \[\leadsto \frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} \]
    9. Applied egg-rr3.8%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{im + 19683}} \]
    10. Step-by-step derivation
      1. *-commutative3.8%

        \[\leadsto \frac{\color{blue}{\left(387420489 - im \cdot im\right) \cdot \cos re}}{im + 19683} \]
      2. associate-/l*3.8%

        \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{im + 19683}{\cos re}}} \]
      3. +-commutative3.8%

        \[\leadsto \frac{387420489 - im \cdot im}{\frac{\color{blue}{19683 + im}}{\cos re}} \]
    11. Simplified3.8%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{19683 + im}{\cos re}}} \]
    12. Taylor expanded in re around 0 31.0%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \frac{\left(387420489 - {im}^{2}\right) \cdot {re}^{2}}{19683 + im} + 387420489 \cdot \frac{1}{19683 + im}\right) - \frac{{im}^{2}}{19683 + im}} \]
    13. Step-by-step derivation
      1. associate--l+31.0%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{\left(387420489 - {im}^{2}\right) \cdot {re}^{2}}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right)} \]
      2. unpow231.0%

        \[\leadsto -0.5 \cdot \frac{\left(387420489 - {im}^{2}\right) \cdot \color{blue}{\left(re \cdot re\right)}}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      3. *-commutative31.0%

        \[\leadsto -0.5 \cdot \frac{\color{blue}{\left(re \cdot re\right) \cdot \left(387420489 - {im}^{2}\right)}}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      4. unpow231.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - \color{blue}{im \cdot im}\right)}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      5. +-commutative31.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      6. associate-*r/31.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \left(\color{blue}{\frac{387420489 \cdot 1}{19683 + im}} - \frac{{im}^{2}}{19683 + im}\right) \]
      7. metadata-eval31.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \left(\frac{\color{blue}{387420489}}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      8. unpow231.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \left(\frac{387420489}{19683 + im} - \frac{\color{blue}{im \cdot im}}{19683 + im}\right) \]
      9. div-sub31.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \color{blue}{\frac{387420489 - im \cdot im}{19683 + im}} \]
      10. +-commutative31.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \frac{387420489 - im \cdot im}{\color{blue}{im + 19683}} \]
    14. Simplified31.0%

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

    if -650 < im < 8.6e10

    1. Initial program 8.7%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.32 \cdot 10^{+154}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{\frac{im}{\cos re}}\\ \mathbf{elif}\;im \leq -650:\\ \;\;\;\;-0.5 \cdot \frac{\left(387420489 - im \cdot im\right) \cdot \left(re \cdot re\right)}{im + 19683} + \frac{387420489 - im \cdot im}{im + 19683}\\ \mathbf{elif}\;im \leq 86000000000:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\ \;\;\;\;-0.5 \cdot \frac{\left(387420489 - im \cdot im\right) \cdot \left(re \cdot re\right)}{im + 19683} + \frac{387420489 - im \cdot im}{im + 19683}\\ \mathbf{else}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{\frac{im}{\cos re}}\\ \end{array} \]

Alternative 8: 76.1% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\ t_1 := 387420489 - im \cdot im\\ \mathbf{if}\;im \leq -1.3 \cdot 10^{+42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 16500000000000:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;-0.5 \cdot \frac{t_1 \cdot \left(re \cdot re\right)}{im + 19683} + \frac{t_1}{im + 19683}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im))
        (t_1 (- 387420489.0 (* im im))))
   (if (<= im -1.3e+42)
     t_0
     (if (<= im 16500000000000.0)
       (* im (- (cos re)))
       (if (<= im 5.6e+102)
         (+
          (* -0.5 (/ (* t_1 (* re re)) (+ im 19683.0)))
          (/ t_1 (+ im 19683.0)))
         t_0)))))
double code(double re, double im) {
	double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double t_1 = 387420489.0 - (im * im);
	double tmp;
	if (im <= -1.3e+42) {
		tmp = t_0;
	} else if (im <= 16500000000000.0) {
		tmp = im * -cos(re);
	} else if (im <= 5.6e+102) {
		tmp = (-0.5 * ((t_1 * (re * re)) / (im + 19683.0))) + (t_1 / (im + 19683.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) :: t_1
    real(8) :: tmp
    t_0 = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
    t_1 = 387420489.0d0 - (im * im)
    if (im <= (-1.3d+42)) then
        tmp = t_0
    else if (im <= 16500000000000.0d0) then
        tmp = im * -cos(re)
    else if (im <= 5.6d+102) then
        tmp = ((-0.5d0) * ((t_1 * (re * re)) / (im + 19683.0d0))) + (t_1 / (im + 19683.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 t_1 = 387420489.0 - (im * im);
	double tmp;
	if (im <= -1.3e+42) {
		tmp = t_0;
	} else if (im <= 16500000000000.0) {
		tmp = im * -Math.cos(re);
	} else if (im <= 5.6e+102) {
		tmp = (-0.5 * ((t_1 * (re * re)) / (im + 19683.0))) + (t_1 / (im + 19683.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im
	t_1 = 387420489.0 - (im * im)
	tmp = 0
	if im <= -1.3e+42:
		tmp = t_0
	elif im <= 16500000000000.0:
		tmp = im * -math.cos(re)
	elif im <= 5.6e+102:
		tmp = (-0.5 * ((t_1 * (re * re)) / (im + 19683.0))) + (t_1 / (im + 19683.0))
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	t_1 = Float64(387420489.0 - Float64(im * im))
	tmp = 0.0
	if (im <= -1.3e+42)
		tmp = t_0;
	elseif (im <= 16500000000000.0)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 5.6e+102)
		tmp = Float64(Float64(-0.5 * Float64(Float64(t_1 * Float64(re * re)) / Float64(im + 19683.0))) + Float64(t_1 / Float64(im + 19683.0)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = ((im ^ 3.0) * -0.16666666666666666) - im;
	t_1 = 387420489.0 - (im * im);
	tmp = 0.0;
	if (im <= -1.3e+42)
		tmp = t_0;
	elseif (im <= 16500000000000.0)
		tmp = im * -cos(re);
	elseif (im <= 5.6e+102)
		tmp = (-0.5 * ((t_1 * (re * re)) / (im + 19683.0))) + (t_1 / (im + 19683.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]}, Block[{t$95$1 = N[(387420489.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.3e+42], t$95$0, If[LessEqual[im, 16500000000000.0], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 5.6e+102], N[(N[(-0.5 * N[(N[(t$95$1 * N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(im + 19683.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 / N[(im + 19683.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
t_1 := 387420489 - im \cdot im\\
\mathbf{if}\;im \leq -1.3 \cdot 10^{+42}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 5.6 \cdot 10^{+102}:\\
\;\;\;\;-0.5 \cdot \frac{t_1 \cdot \left(re \cdot re\right)}{im + 19683} + \frac{t_1}{im + 19683}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -1.29999999999999995e42 < im < 1.65e13

    1. Initial program 12.7%

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

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

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

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

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

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

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

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

    if 1.65e13 < im < 5.60000000000000037e102

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{19683 \cdot 19683 - im \cdot im}{19683 + im}} \]
      2. associate-*r/3.6%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(19683 \cdot 19683 - im \cdot im\right)}{19683 + im}} \]
      3. metadata-eval3.6%

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{387420489} - im \cdot im\right)}{19683 + im} \]
      4. +-commutative3.6%

        \[\leadsto \frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} \]
    9. Applied egg-rr3.6%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{im + 19683}} \]
    10. Step-by-step derivation
      1. *-commutative3.6%

        \[\leadsto \frac{\color{blue}{\left(387420489 - im \cdot im\right) \cdot \cos re}}{im + 19683} \]
      2. associate-/l*3.6%

        \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{im + 19683}{\cos re}}} \]
      3. +-commutative3.6%

        \[\leadsto \frac{387420489 - im \cdot im}{\frac{\color{blue}{19683 + im}}{\cos re}} \]
    11. Simplified3.6%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{19683 + im}{\cos re}}} \]
    12. Taylor expanded in re around 0 32.4%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \frac{\left(387420489 - {im}^{2}\right) \cdot {re}^{2}}{19683 + im} + 387420489 \cdot \frac{1}{19683 + im}\right) - \frac{{im}^{2}}{19683 + im}} \]
    13. Step-by-step derivation
      1. associate--l+32.4%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{\left(387420489 - {im}^{2}\right) \cdot {re}^{2}}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right)} \]
      2. unpow232.4%

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

        \[\leadsto -0.5 \cdot \frac{\color{blue}{\left(re \cdot re\right) \cdot \left(387420489 - {im}^{2}\right)}}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      4. unpow232.4%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - \color{blue}{im \cdot im}\right)}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      5. +-commutative32.4%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      6. associate-*r/32.4%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \left(\color{blue}{\frac{387420489 \cdot 1}{19683 + im}} - \frac{{im}^{2}}{19683 + im}\right) \]
      7. metadata-eval32.4%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \left(\frac{\color{blue}{387420489}}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      8. unpow232.4%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \left(\frac{387420489}{19683 + im} - \frac{\color{blue}{im \cdot im}}{19683 + im}\right) \]
      9. div-sub32.4%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \color{blue}{\frac{387420489 - im \cdot im}{19683 + im}} \]
      10. +-commutative32.4%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \frac{387420489 - im \cdot im}{\color{blue}{im + 19683}} \]
    14. Simplified32.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.3 \cdot 10^{+42}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 16500000000000:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;-0.5 \cdot \frac{\left(387420489 - im \cdot im\right) \cdot \left(re \cdot re\right)}{im + 19683} + \frac{387420489 - im \cdot im}{im + 19683}\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 9: 72.1% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 387420489 - im \cdot im\\ t_1 := \frac{t_0}{im + 19683}\\ \mathbf{if}\;im \leq -7.5 \cdot 10^{+163}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -88000000:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq 17000000000:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\ \;\;\;\;-0.5 \cdot \frac{t_0 \cdot \left(re \cdot re\right)}{im + 19683} + t_1\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- 387420489.0 (* im im))) (t_1 (/ t_0 (+ im 19683.0))))
   (if (<= im -7.5e+163)
     t_1
     (if (<= im -88000000.0)
       (- (* im (* 0.5 (* re re))) im)
       (if (<= im 17000000000.0)
         (* im (- (cos re)))
         (if (<= im 3.3e+145)
           (+ (* -0.5 (/ (* t_0 (* re re)) (+ im 19683.0))) t_1)
           t_1))))))
double code(double re, double im) {
	double t_0 = 387420489.0 - (im * im);
	double t_1 = t_0 / (im + 19683.0);
	double tmp;
	if (im <= -7.5e+163) {
		tmp = t_1;
	} else if (im <= -88000000.0) {
		tmp = (im * (0.5 * (re * re))) - im;
	} else if (im <= 17000000000.0) {
		tmp = im * -cos(re);
	} else if (im <= 3.3e+145) {
		tmp = (-0.5 * ((t_0 * (re * re)) / (im + 19683.0))) + t_1;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 387420489.0d0 - (im * im)
    t_1 = t_0 / (im + 19683.0d0)
    if (im <= (-7.5d+163)) then
        tmp = t_1
    else if (im <= (-88000000.0d0)) then
        tmp = (im * (0.5d0 * (re * re))) - im
    else if (im <= 17000000000.0d0) then
        tmp = im * -cos(re)
    else if (im <= 3.3d+145) then
        tmp = ((-0.5d0) * ((t_0 * (re * re)) / (im + 19683.0d0))) + t_1
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 387420489.0 - (im * im);
	double t_1 = t_0 / (im + 19683.0);
	double tmp;
	if (im <= -7.5e+163) {
		tmp = t_1;
	} else if (im <= -88000000.0) {
		tmp = (im * (0.5 * (re * re))) - im;
	} else if (im <= 17000000000.0) {
		tmp = im * -Math.cos(re);
	} else if (im <= 3.3e+145) {
		tmp = (-0.5 * ((t_0 * (re * re)) / (im + 19683.0))) + t_1;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = 387420489.0 - (im * im)
	t_1 = t_0 / (im + 19683.0)
	tmp = 0
	if im <= -7.5e+163:
		tmp = t_1
	elif im <= -88000000.0:
		tmp = (im * (0.5 * (re * re))) - im
	elif im <= 17000000000.0:
		tmp = im * -math.cos(re)
	elif im <= 3.3e+145:
		tmp = (-0.5 * ((t_0 * (re * re)) / (im + 19683.0))) + t_1
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(387420489.0 - Float64(im * im))
	t_1 = Float64(t_0 / Float64(im + 19683.0))
	tmp = 0.0
	if (im <= -7.5e+163)
		tmp = t_1;
	elseif (im <= -88000000.0)
		tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im);
	elseif (im <= 17000000000.0)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 3.3e+145)
		tmp = Float64(Float64(-0.5 * Float64(Float64(t_0 * Float64(re * re)) / Float64(im + 19683.0))) + t_1);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 387420489.0 - (im * im);
	t_1 = t_0 / (im + 19683.0);
	tmp = 0.0;
	if (im <= -7.5e+163)
		tmp = t_1;
	elseif (im <= -88000000.0)
		tmp = (im * (0.5 * (re * re))) - im;
	elseif (im <= 17000000000.0)
		tmp = im * -cos(re);
	elseif (im <= 3.3e+145)
		tmp = (-0.5 * ((t_0 * (re * re)) / (im + 19683.0))) + t_1;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(387420489.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(im + 19683.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.5e+163], t$95$1, If[LessEqual[im, -88000000.0], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 17000000000.0], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 3.3e+145], N[(N[(-0.5 * N[(N[(t$95$0 * N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(im + 19683.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 387420489 - im \cdot im\\
t_1 := \frac{t_0}{im + 19683}\\
\mathbf{if}\;im \leq -7.5 \cdot 10^{+163}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\
\;\;\;\;-0.5 \cdot \frac{t_0 \cdot \left(re \cdot re\right)}{im + 19683} + t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -7.50000000000000001e163 or 3.30000000000000027e145 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{19683 \cdot 19683 - im \cdot im}{19683 + im}} \]
      2. associate-*r/96.8%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(19683 \cdot 19683 - im \cdot im\right)}{19683 + im}} \]
      3. metadata-eval96.8%

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{387420489} - im \cdot im\right)}{19683 + im} \]
      4. +-commutative96.8%

        \[\leadsto \frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} \]
    9. Applied egg-rr96.8%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{im + 19683}} \]
    10. Step-by-step derivation
      1. *-commutative96.8%

        \[\leadsto \frac{\color{blue}{\left(387420489 - im \cdot im\right) \cdot \cos re}}{im + 19683} \]
      2. associate-/l*96.8%

        \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{im + 19683}{\cos re}}} \]
      3. +-commutative96.8%

        \[\leadsto \frac{387420489 - im \cdot im}{\frac{\color{blue}{19683 + im}}{\cos re}} \]
    11. Simplified96.8%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{19683 + im}{\cos re}}} \]
    12. Taylor expanded in re around 0 85.2%

      \[\leadsto \color{blue}{\frac{387420489 - {im}^{2}}{19683 + im}} \]
    13. Step-by-step derivation
      1. unpow285.2%

        \[\leadsto \frac{387420489 - \color{blue}{im \cdot im}}{19683 + im} \]
      2. +-commutative85.2%

        \[\leadsto \frac{387420489 - im \cdot im}{\color{blue}{im + 19683}} \]
    14. Simplified85.2%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{im + 19683}} \]

    if -7.50000000000000001e163 < im < -8.8e7

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.8e7 < im < 1.7e10

    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. sub0-neg9.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 97.0%

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

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

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

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

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

    if 1.7e10 < im < 3.30000000000000027e145

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{19683 \cdot 19683 - im \cdot im}{19683 + im}} \]
      2. associate-*r/3.7%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(19683 \cdot 19683 - im \cdot im\right)}{19683 + im}} \]
      3. metadata-eval3.7%

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{387420489} - im \cdot im\right)}{19683 + im} \]
      4. +-commutative3.7%

        \[\leadsto \frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} \]
    9. Applied egg-rr3.7%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{im + 19683}} \]
    10. Step-by-step derivation
      1. *-commutative3.7%

        \[\leadsto \frac{\color{blue}{\left(387420489 - im \cdot im\right) \cdot \cos re}}{im + 19683} \]
      2. associate-/l*3.7%

        \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{im + 19683}{\cos re}}} \]
      3. +-commutative3.7%

        \[\leadsto \frac{387420489 - im \cdot im}{\frac{\color{blue}{19683 + im}}{\cos re}} \]
    11. Simplified3.7%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{19683 + im}{\cos re}}} \]
    12. Taylor expanded in re around 0 34.0%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \frac{\left(387420489 - {im}^{2}\right) \cdot {re}^{2}}{19683 + im} + 387420489 \cdot \frac{1}{19683 + im}\right) - \frac{{im}^{2}}{19683 + im}} \]
    13. Step-by-step derivation
      1. associate--l+34.0%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{\left(387420489 - {im}^{2}\right) \cdot {re}^{2}}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right)} \]
      2. unpow234.0%

        \[\leadsto -0.5 \cdot \frac{\left(387420489 - {im}^{2}\right) \cdot \color{blue}{\left(re \cdot re\right)}}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      3. *-commutative34.0%

        \[\leadsto -0.5 \cdot \frac{\color{blue}{\left(re \cdot re\right) \cdot \left(387420489 - {im}^{2}\right)}}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      4. unpow234.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - \color{blue}{im \cdot im}\right)}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      5. +-commutative34.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      6. associate-*r/34.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \left(\color{blue}{\frac{387420489 \cdot 1}{19683 + im}} - \frac{{im}^{2}}{19683 + im}\right) \]
      7. metadata-eval34.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \left(\frac{\color{blue}{387420489}}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      8. unpow234.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \left(\frac{387420489}{19683 + im} - \frac{\color{blue}{im \cdot im}}{19683 + im}\right) \]
      9. div-sub34.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \color{blue}{\frac{387420489 - im \cdot im}{19683 + im}} \]
      10. +-commutative34.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \frac{387420489 - im \cdot im}{\color{blue}{im + 19683}} \]
    14. Simplified34.0%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \frac{387420489 - im \cdot im}{im + 19683}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification77.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.5 \cdot 10^{+163}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{im + 19683}\\ \mathbf{elif}\;im \leq -88000000:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq 17000000000:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\ \;\;\;\;-0.5 \cdot \frac{\left(387420489 - im \cdot im\right) \cdot \left(re \cdot re\right)}{im + 19683} + \frac{387420489 - im \cdot im}{im + 19683}\\ \mathbf{else}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{im + 19683}\\ \end{array} \]

Alternative 10: 50.8% accurate, 9.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 387420489 - im \cdot im\\ t_1 := \frac{t_0}{im + 19683}\\ \mathbf{if}\;im \leq -7.5 \cdot 10^{+163}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -88000000:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq 17000000000:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\ \;\;\;\;-0.5 \cdot \frac{t_0 \cdot \left(re \cdot re\right)}{im + 19683} + t_1\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- 387420489.0 (* im im))) (t_1 (/ t_0 (+ im 19683.0))))
   (if (<= im -7.5e+163)
     t_1
     (if (<= im -88000000.0)
       (- (* im (* 0.5 (* re re))) im)
       (if (<= im 17000000000.0)
         (- im)
         (if (<= im 3.3e+145)
           (+ (* -0.5 (/ (* t_0 (* re re)) (+ im 19683.0))) t_1)
           t_1))))))
double code(double re, double im) {
	double t_0 = 387420489.0 - (im * im);
	double t_1 = t_0 / (im + 19683.0);
	double tmp;
	if (im <= -7.5e+163) {
		tmp = t_1;
	} else if (im <= -88000000.0) {
		tmp = (im * (0.5 * (re * re))) - im;
	} else if (im <= 17000000000.0) {
		tmp = -im;
	} else if (im <= 3.3e+145) {
		tmp = (-0.5 * ((t_0 * (re * re)) / (im + 19683.0))) + t_1;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 387420489.0d0 - (im * im)
    t_1 = t_0 / (im + 19683.0d0)
    if (im <= (-7.5d+163)) then
        tmp = t_1
    else if (im <= (-88000000.0d0)) then
        tmp = (im * (0.5d0 * (re * re))) - im
    else if (im <= 17000000000.0d0) then
        tmp = -im
    else if (im <= 3.3d+145) then
        tmp = ((-0.5d0) * ((t_0 * (re * re)) / (im + 19683.0d0))) + t_1
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 387420489.0 - (im * im);
	double t_1 = t_0 / (im + 19683.0);
	double tmp;
	if (im <= -7.5e+163) {
		tmp = t_1;
	} else if (im <= -88000000.0) {
		tmp = (im * (0.5 * (re * re))) - im;
	} else if (im <= 17000000000.0) {
		tmp = -im;
	} else if (im <= 3.3e+145) {
		tmp = (-0.5 * ((t_0 * (re * re)) / (im + 19683.0))) + t_1;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = 387420489.0 - (im * im)
	t_1 = t_0 / (im + 19683.0)
	tmp = 0
	if im <= -7.5e+163:
		tmp = t_1
	elif im <= -88000000.0:
		tmp = (im * (0.5 * (re * re))) - im
	elif im <= 17000000000.0:
		tmp = -im
	elif im <= 3.3e+145:
		tmp = (-0.5 * ((t_0 * (re * re)) / (im + 19683.0))) + t_1
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(387420489.0 - Float64(im * im))
	t_1 = Float64(t_0 / Float64(im + 19683.0))
	tmp = 0.0
	if (im <= -7.5e+163)
		tmp = t_1;
	elseif (im <= -88000000.0)
		tmp = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im);
	elseif (im <= 17000000000.0)
		tmp = Float64(-im);
	elseif (im <= 3.3e+145)
		tmp = Float64(Float64(-0.5 * Float64(Float64(t_0 * Float64(re * re)) / Float64(im + 19683.0))) + t_1);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 387420489.0 - (im * im);
	t_1 = t_0 / (im + 19683.0);
	tmp = 0.0;
	if (im <= -7.5e+163)
		tmp = t_1;
	elseif (im <= -88000000.0)
		tmp = (im * (0.5 * (re * re))) - im;
	elseif (im <= 17000000000.0)
		tmp = -im;
	elseif (im <= 3.3e+145)
		tmp = (-0.5 * ((t_0 * (re * re)) / (im + 19683.0))) + t_1;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(387420489.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(im + 19683.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.5e+163], t$95$1, If[LessEqual[im, -88000000.0], N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 17000000000.0], (-im), If[LessEqual[im, 3.3e+145], N[(N[(-0.5 * N[(N[(t$95$0 * N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(im + 19683.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 387420489 - im \cdot im\\
t_1 := \frac{t_0}{im + 19683}\\
\mathbf{if}\;im \leq -7.5 \cdot 10^{+163}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\
\;\;\;\;-0.5 \cdot \frac{t_0 \cdot \left(re \cdot re\right)}{im + 19683} + t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -7.50000000000000001e163 or 3.30000000000000027e145 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{19683 \cdot 19683 - im \cdot im}{19683 + im}} \]
      2. associate-*r/96.8%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(19683 \cdot 19683 - im \cdot im\right)}{19683 + im}} \]
      3. metadata-eval96.8%

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{387420489} - im \cdot im\right)}{19683 + im} \]
      4. +-commutative96.8%

        \[\leadsto \frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} \]
    9. Applied egg-rr96.8%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{im + 19683}} \]
    10. Step-by-step derivation
      1. *-commutative96.8%

        \[\leadsto \frac{\color{blue}{\left(387420489 - im \cdot im\right) \cdot \cos re}}{im + 19683} \]
      2. associate-/l*96.8%

        \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{im + 19683}{\cos re}}} \]
      3. +-commutative96.8%

        \[\leadsto \frac{387420489 - im \cdot im}{\frac{\color{blue}{19683 + im}}{\cos re}} \]
    11. Simplified96.8%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{19683 + im}{\cos re}}} \]
    12. Taylor expanded in re around 0 85.2%

      \[\leadsto \color{blue}{\frac{387420489 - {im}^{2}}{19683 + im}} \]
    13. Step-by-step derivation
      1. unpow285.2%

        \[\leadsto \frac{387420489 - \color{blue}{im \cdot im}}{19683 + im} \]
      2. +-commutative85.2%

        \[\leadsto \frac{387420489 - im \cdot im}{\color{blue}{im + 19683}} \]
    14. Simplified85.2%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{im + 19683}} \]

    if -7.50000000000000001e163 < im < -8.8e7

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.8e7 < im < 1.7e10

    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. sub0-neg9.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 97.0%

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

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

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

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

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

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

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

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

    if 1.7e10 < im < 3.30000000000000027e145

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{19683 \cdot 19683 - im \cdot im}{19683 + im}} \]
      2. associate-*r/3.7%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(19683 \cdot 19683 - im \cdot im\right)}{19683 + im}} \]
      3. metadata-eval3.7%

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{387420489} - im \cdot im\right)}{19683 + im} \]
      4. +-commutative3.7%

        \[\leadsto \frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} \]
    9. Applied egg-rr3.7%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{im + 19683}} \]
    10. Step-by-step derivation
      1. *-commutative3.7%

        \[\leadsto \frac{\color{blue}{\left(387420489 - im \cdot im\right) \cdot \cos re}}{im + 19683} \]
      2. associate-/l*3.7%

        \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{im + 19683}{\cos re}}} \]
      3. +-commutative3.7%

        \[\leadsto \frac{387420489 - im \cdot im}{\frac{\color{blue}{19683 + im}}{\cos re}} \]
    11. Simplified3.7%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{19683 + im}{\cos re}}} \]
    12. Taylor expanded in re around 0 34.0%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \frac{\left(387420489 - {im}^{2}\right) \cdot {re}^{2}}{19683 + im} + 387420489 \cdot \frac{1}{19683 + im}\right) - \frac{{im}^{2}}{19683 + im}} \]
    13. Step-by-step derivation
      1. associate--l+34.0%

        \[\leadsto \color{blue}{-0.5 \cdot \frac{\left(387420489 - {im}^{2}\right) \cdot {re}^{2}}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right)} \]
      2. unpow234.0%

        \[\leadsto -0.5 \cdot \frac{\left(387420489 - {im}^{2}\right) \cdot \color{blue}{\left(re \cdot re\right)}}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      3. *-commutative34.0%

        \[\leadsto -0.5 \cdot \frac{\color{blue}{\left(re \cdot re\right) \cdot \left(387420489 - {im}^{2}\right)}}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      4. unpow234.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - \color{blue}{im \cdot im}\right)}{19683 + im} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      5. +-commutative34.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} + \left(387420489 \cdot \frac{1}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      6. associate-*r/34.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \left(\color{blue}{\frac{387420489 \cdot 1}{19683 + im}} - \frac{{im}^{2}}{19683 + im}\right) \]
      7. metadata-eval34.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \left(\frac{\color{blue}{387420489}}{19683 + im} - \frac{{im}^{2}}{19683 + im}\right) \]
      8. unpow234.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \left(\frac{387420489}{19683 + im} - \frac{\color{blue}{im \cdot im}}{19683 + im}\right) \]
      9. div-sub34.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \color{blue}{\frac{387420489 - im \cdot im}{19683 + im}} \]
      10. +-commutative34.0%

        \[\leadsto -0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \frac{387420489 - im \cdot im}{\color{blue}{im + 19683}} \]
    14. Simplified34.0%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{\left(re \cdot re\right) \cdot \left(387420489 - im \cdot im\right)}{im + 19683} + \frac{387420489 - im \cdot im}{im + 19683}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification54.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.5 \cdot 10^{+163}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{im + 19683}\\ \mathbf{elif}\;im \leq -88000000:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq 17000000000:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\ \;\;\;\;-0.5 \cdot \frac{\left(387420489 - im \cdot im\right) \cdot \left(re \cdot re\right)}{im + 19683} + \frac{387420489 - im \cdot im}{im + 19683}\\ \mathbf{else}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{im + 19683}\\ \end{array} \]

Alternative 11: 50.2% accurate, 17.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{387420489 - im \cdot im}{im + 19683}\\ t_1 := im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{if}\;im \leq -7.5 \cdot 10^{+163}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -2150000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 8 \cdot 10^{-51}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (/ (- 387420489.0 (* im im)) (+ im 19683.0)))
        (t_1 (- (* im (* 0.5 (* re re))) im)))
   (if (<= im -7.5e+163)
     t_0
     (if (<= im -2150000000.0)
       t_1
       (if (<= im 8e-51) (- im) (if (<= im 3.3e+145) t_1 t_0))))))
double code(double re, double im) {
	double t_0 = (387420489.0 - (im * im)) / (im + 19683.0);
	double t_1 = (im * (0.5 * (re * re))) - im;
	double tmp;
	if (im <= -7.5e+163) {
		tmp = t_0;
	} else if (im <= -2150000000.0) {
		tmp = t_1;
	} else if (im <= 8e-51) {
		tmp = -im;
	} else if (im <= 3.3e+145) {
		tmp = t_1;
	} 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) :: tmp
    t_0 = (387420489.0d0 - (im * im)) / (im + 19683.0d0)
    t_1 = (im * (0.5d0 * (re * re))) - im
    if (im <= (-7.5d+163)) then
        tmp = t_0
    else if (im <= (-2150000000.0d0)) then
        tmp = t_1
    else if (im <= 8d-51) then
        tmp = -im
    else if (im <= 3.3d+145) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (387420489.0 - (im * im)) / (im + 19683.0);
	double t_1 = (im * (0.5 * (re * re))) - im;
	double tmp;
	if (im <= -7.5e+163) {
		tmp = t_0;
	} else if (im <= -2150000000.0) {
		tmp = t_1;
	} else if (im <= 8e-51) {
		tmp = -im;
	} else if (im <= 3.3e+145) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (387420489.0 - (im * im)) / (im + 19683.0)
	t_1 = (im * (0.5 * (re * re))) - im
	tmp = 0
	if im <= -7.5e+163:
		tmp = t_0
	elif im <= -2150000000.0:
		tmp = t_1
	elif im <= 8e-51:
		tmp = -im
	elif im <= 3.3e+145:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64(387420489.0 - Float64(im * im)) / Float64(im + 19683.0))
	t_1 = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im)
	tmp = 0.0
	if (im <= -7.5e+163)
		tmp = t_0;
	elseif (im <= -2150000000.0)
		tmp = t_1;
	elseif (im <= 8e-51)
		tmp = Float64(-im);
	elseif (im <= 3.3e+145)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (387420489.0 - (im * im)) / (im + 19683.0);
	t_1 = (im * (0.5 * (re * re))) - im;
	tmp = 0.0;
	if (im <= -7.5e+163)
		tmp = t_0;
	elseif (im <= -2150000000.0)
		tmp = t_1;
	elseif (im <= 8e-51)
		tmp = -im;
	elseif (im <= 3.3e+145)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(387420489.0 - N[(im * im), $MachinePrecision]), $MachinePrecision] / N[(im + 19683.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]}, If[LessEqual[im, -7.5e+163], t$95$0, If[LessEqual[im, -2150000000.0], t$95$1, If[LessEqual[im, 8e-51], (-im), If[LessEqual[im, 3.3e+145], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{387420489 - im \cdot im}{im + 19683}\\
t_1 := im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\
\mathbf{if}\;im \leq -7.5 \cdot 10^{+163}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -2150000000:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq 8 \cdot 10^{-51}:\\
\;\;\;\;-im\\

\mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -7.50000000000000001e163 or 3.30000000000000027e145 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{19683 \cdot 19683 - im \cdot im}{19683 + im}} \]
      2. associate-*r/96.8%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(19683 \cdot 19683 - im \cdot im\right)}{19683 + im}} \]
      3. metadata-eval96.8%

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{387420489} - im \cdot im\right)}{19683 + im} \]
      4. +-commutative96.8%

        \[\leadsto \frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{\color{blue}{im + 19683}} \]
    9. Applied egg-rr96.8%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(387420489 - im \cdot im\right)}{im + 19683}} \]
    10. Step-by-step derivation
      1. *-commutative96.8%

        \[\leadsto \frac{\color{blue}{\left(387420489 - im \cdot im\right) \cdot \cos re}}{im + 19683} \]
      2. associate-/l*96.8%

        \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{im + 19683}{\cos re}}} \]
      3. +-commutative96.8%

        \[\leadsto \frac{387420489 - im \cdot im}{\frac{\color{blue}{19683 + im}}{\cos re}} \]
    11. Simplified96.8%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{\frac{19683 + im}{\cos re}}} \]
    12. Taylor expanded in re around 0 85.2%

      \[\leadsto \color{blue}{\frac{387420489 - {im}^{2}}{19683 + im}} \]
    13. Step-by-step derivation
      1. unpow285.2%

        \[\leadsto \frac{387420489 - \color{blue}{im \cdot im}}{19683 + im} \]
      2. +-commutative85.2%

        \[\leadsto \frac{387420489 - im \cdot im}{\color{blue}{im + 19683}} \]
    14. Simplified85.2%

      \[\leadsto \color{blue}{\frac{387420489 - im \cdot im}{im + 19683}} \]

    if -7.50000000000000001e163 < im < -2.15e9 or 8.0000000000000001e-51 < im < 3.30000000000000027e145

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.15e9 < im < 8.0000000000000001e-51

    1. Initial program 7.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.5 \cdot 10^{+163}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{im + 19683}\\ \mathbf{elif}\;im \leq -2150000000:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq 8 \cdot 10^{-51}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+145}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;\frac{387420489 - im \cdot im}{im + 19683}\\ \end{array} \]

Alternative 12: 34.5% accurate, 20.3× speedup?

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

\\
\begin{array}{l}
t_0 := \left(re \cdot re\right) \cdot -6.75\\
\mathbf{if}\;im \leq -88000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 2 \cdot 10^{-10}:\\
\;\;\;\;-im\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -8.8e7 or 5.5000000000000001e113 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.8e7 < im < 2.00000000000000007e-10

    1. Initial program 7.7%

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000007e-10 < im < 5.5000000000000001e113

    1. Initial program 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -88000000:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \mathbf{elif}\;im \leq 2 \cdot 10^{-10}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 5.5 \cdot 10^{+113}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \]

Alternative 13: 34.7% accurate, 20.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 + re \cdot \left(re \cdot -0.25\right)\\ \mathbf{if}\;im \leq -420000000:\\ \;\;\;\;t_0 \cdot 27\\ \mathbf{elif}\;im \leq 2 \cdot 10^{-10}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 3 \cdot 10^{+113}:\\ \;\;\;\;t_0 \cdot -3\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (+ 0.5 (* re (* re -0.25)))))
   (if (<= im -420000000.0)
     (* t_0 27.0)
     (if (<= im 2e-10)
       (- im)
       (if (<= im 3e+113) (* t_0 -3.0) (* (* re re) -6.75))))))
double code(double re, double im) {
	double t_0 = 0.5 + (re * (re * -0.25));
	double tmp;
	if (im <= -420000000.0) {
		tmp = t_0 * 27.0;
	} else if (im <= 2e-10) {
		tmp = -im;
	} else if (im <= 3e+113) {
		tmp = t_0 * -3.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 + (re * (re * (-0.25d0)))
    if (im <= (-420000000.0d0)) then
        tmp = t_0 * 27.0d0
    else if (im <= 2d-10) then
        tmp = -im
    else if (im <= 3d+113) then
        tmp = t_0 * (-3.0d0)
    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 + (re * (re * -0.25));
	double tmp;
	if (im <= -420000000.0) {
		tmp = t_0 * 27.0;
	} else if (im <= 2e-10) {
		tmp = -im;
	} else if (im <= 3e+113) {
		tmp = t_0 * -3.0;
	} else {
		tmp = (re * re) * -6.75;
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 + (re * (re * -0.25))
	tmp = 0
	if im <= -420000000.0:
		tmp = t_0 * 27.0
	elif im <= 2e-10:
		tmp = -im
	elif im <= 3e+113:
		tmp = t_0 * -3.0
	else:
		tmp = (re * re) * -6.75
	return tmp
function code(re, im)
	t_0 = Float64(0.5 + Float64(re * Float64(re * -0.25)))
	tmp = 0.0
	if (im <= -420000000.0)
		tmp = Float64(t_0 * 27.0);
	elseif (im <= 2e-10)
		tmp = Float64(-im);
	elseif (im <= 3e+113)
		tmp = Float64(t_0 * -3.0);
	else
		tmp = Float64(Float64(re * re) * -6.75);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 + (re * (re * -0.25));
	tmp = 0.0;
	if (im <= -420000000.0)
		tmp = t_0 * 27.0;
	elseif (im <= 2e-10)
		tmp = -im;
	elseif (im <= 3e+113)
		tmp = t_0 * -3.0;
	else
		tmp = (re * re) * -6.75;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -420000000.0], N[(t$95$0 * 27.0), $MachinePrecision], If[LessEqual[im, 2e-10], (-im), If[LessEqual[im, 3e+113], N[(t$95$0 * -3.0), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 + re \cdot \left(re \cdot -0.25\right)\\
\mathbf{if}\;im \leq -420000000:\\
\;\;\;\;t_0 \cdot 27\\

\mathbf{elif}\;im \leq 2 \cdot 10^{-10}:\\
\;\;\;\;-im\\

\mathbf{elif}\;im \leq 3 \cdot 10^{+113}:\\
\;\;\;\;t_0 \cdot -3\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.2e8 < im < 2.00000000000000007e-10

    1. Initial program 7.7%

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000007e-10 < im < 3e113

    1. Initial program 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3e113 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -420000000:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\\ \mathbf{elif}\;im \leq 2 \cdot 10^{-10}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 3 \cdot 10^{+113}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \]

Alternative 14: 38.3% accurate, 23.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -88000000 \lor \neg \left(im \leq 8 \cdot 10^{-51}\right):\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\

\mathbf{else}:\\
\;\;\;\;-im\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -8.8e7 or 8.0000000000000001e-51 < im

    1. Initial program 96.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.8e7 < im < 8.0000000000000001e-51

    1. Initial program 7.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -88000000 \lor \neg \left(im \leq 8 \cdot 10^{-51}\right):\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]

Alternative 15: 31.9% accurate, 43.8× speedup?

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

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

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


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

    1. Initial program 53.8%

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

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

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

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

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

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

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

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

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

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

    if 2.0499999999999999e155 < re

    1. Initial program 49.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 29.4% 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 53.3%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -im \]

Alternative 17: 2.8% 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 53.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{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 2023217 
(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))))