math.sin on complex, imaginary part

Percentage Accurate: 54.0% → 99.8%
Time: 13.3s
Alternatives: 21
Speedup: 2.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 21 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 54.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

    if -0.20000000000000001 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1.99999999999999991e-6

    1. Initial program 7.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\cos re \cdot \frac{68719476736 - \left(im \cdot im\right) \cdot \left(im \cdot im\right)}{im \cdot im + 262144}}{im + -512}\\ t_1 := \frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ t_2 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -1.15 \cdot 10^{+77}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -0.00195:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq 235000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (/
          (*
           (cos re)
           (/
            (- 68719476736.0 (* (* im im) (* im im)))
            (+ (* im im) 262144.0)))
          (+ im -512.0)))
        (t_1 (/ (* (cos re) (- (* im im))) (+ im -512.0)))
        (t_2 (* 0.5 (- (exp (- im)) (exp im)))))
   (if (<= im -1.35e+154)
     t_1
     (if (<= im -1.15e+77)
       t_0
       (if (<= im -0.00195)
         t_2
         (if (<= im 235000000000.0)
           (- (* im (cos re)))
           (if (<= im 1.15e+77) t_2 (if (<= im 1.4e+154) t_0 t_1))))))))
double code(double re, double im) {
	double t_0 = (cos(re) * ((68719476736.0 - ((im * im) * (im * im))) / ((im * im) + 262144.0))) / (im + -512.0);
	double t_1 = (cos(re) * -(im * im)) / (im + -512.0);
	double t_2 = 0.5 * (exp(-im) - exp(im));
	double tmp;
	if (im <= -1.35e+154) {
		tmp = t_1;
	} else if (im <= -1.15e+77) {
		tmp = t_0;
	} else if (im <= -0.00195) {
		tmp = t_2;
	} else if (im <= 235000000000.0) {
		tmp = -(im * cos(re));
	} else if (im <= 1.15e+77) {
		tmp = t_2;
	} else if (im <= 1.4e+154) {
		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) :: t_2
    real(8) :: tmp
    t_0 = (cos(re) * ((68719476736.0d0 - ((im * im) * (im * im))) / ((im * im) + 262144.0d0))) / (im + (-512.0d0))
    t_1 = (cos(re) * -(im * im)) / (im + (-512.0d0))
    t_2 = 0.5d0 * (exp(-im) - exp(im))
    if (im <= (-1.35d+154)) then
        tmp = t_1
    else if (im <= (-1.15d+77)) then
        tmp = t_0
    else if (im <= (-0.00195d0)) then
        tmp = t_2
    else if (im <= 235000000000.0d0) then
        tmp = -(im * cos(re))
    else if (im <= 1.15d+77) then
        tmp = t_2
    else if (im <= 1.4d+154) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (Math.cos(re) * ((68719476736.0 - ((im * im) * (im * im))) / ((im * im) + 262144.0))) / (im + -512.0);
	double t_1 = (Math.cos(re) * -(im * im)) / (im + -512.0);
	double t_2 = 0.5 * (Math.exp(-im) - Math.exp(im));
	double tmp;
	if (im <= -1.35e+154) {
		tmp = t_1;
	} else if (im <= -1.15e+77) {
		tmp = t_0;
	} else if (im <= -0.00195) {
		tmp = t_2;
	} else if (im <= 235000000000.0) {
		tmp = -(im * Math.cos(re));
	} else if (im <= 1.15e+77) {
		tmp = t_2;
	} else if (im <= 1.4e+154) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.cos(re) * ((68719476736.0 - ((im * im) * (im * im))) / ((im * im) + 262144.0))) / (im + -512.0)
	t_1 = (math.cos(re) * -(im * im)) / (im + -512.0)
	t_2 = 0.5 * (math.exp(-im) - math.exp(im))
	tmp = 0
	if im <= -1.35e+154:
		tmp = t_1
	elif im <= -1.15e+77:
		tmp = t_0
	elif im <= -0.00195:
		tmp = t_2
	elif im <= 235000000000.0:
		tmp = -(im * math.cos(re))
	elif im <= 1.15e+77:
		tmp = t_2
	elif im <= 1.4e+154:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(cos(re) * Float64(Float64(68719476736.0 - Float64(Float64(im * im) * Float64(im * im))) / Float64(Float64(im * im) + 262144.0))) / Float64(im + -512.0))
	t_1 = Float64(Float64(cos(re) * Float64(-Float64(im * im))) / Float64(im + -512.0))
	t_2 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	tmp = 0.0
	if (im <= -1.35e+154)
		tmp = t_1;
	elseif (im <= -1.15e+77)
		tmp = t_0;
	elseif (im <= -0.00195)
		tmp = t_2;
	elseif (im <= 235000000000.0)
		tmp = Float64(-Float64(im * cos(re)));
	elseif (im <= 1.15e+77)
		tmp = t_2;
	elseif (im <= 1.4e+154)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (cos(re) * ((68719476736.0 - ((im * im) * (im * im))) / ((im * im) + 262144.0))) / (im + -512.0);
	t_1 = (cos(re) * -(im * im)) / (im + -512.0);
	t_2 = 0.5 * (exp(-im) - exp(im));
	tmp = 0.0;
	if (im <= -1.35e+154)
		tmp = t_1;
	elseif (im <= -1.15e+77)
		tmp = t_0;
	elseif (im <= -0.00195)
		tmp = t_2;
	elseif (im <= 235000000000.0)
		tmp = -(im * cos(re));
	elseif (im <= 1.15e+77)
		tmp = t_2;
	elseif (im <= 1.4e+154)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Cos[re], $MachinePrecision] * N[(N[(68719476736.0 - N[(N[(im * im), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(im * im), $MachinePrecision] + 262144.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * (-N[(im * im), $MachinePrecision])), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.35e+154], t$95$1, If[LessEqual[im, -1.15e+77], t$95$0, If[LessEqual[im, -0.00195], t$95$2, If[LessEqual[im, 235000000000.0], (-N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), If[LessEqual[im, 1.15e+77], t$95$2, If[LessEqual[im, 1.4e+154], t$95$0, t$95$1]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\cos re \cdot \frac{68719476736 - \left(im \cdot im\right) \cdot \left(im \cdot im\right)}{im \cdot im + 262144}}{im + -512}\\
t_1 := \frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\
t_2 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -1.15 \cdot 10^{+77}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -0.00195:\\
\;\;\;\;t_2\\

\mathbf{elif}\;im \leq 235000000000:\\
\;\;\;\;-im \cdot \cos re\\

\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -1.35000000000000003e154 or 1.4e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative7.6%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval100.0%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative100.0%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in im around inf 100.0%

      \[\leadsto \frac{\color{blue}{\left(-1 \cdot {im}^{2}\right)} \cdot \cos re}{im + -512} \]
    11. Step-by-step derivation
      1. unpow2100.0%

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

        \[\leadsto \frac{\color{blue}{\left(-im \cdot im\right)} \cdot \cos re}{im + -512} \]
    12. Simplified100.0%

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

    if -1.35000000000000003e154 < im < -1.14999999999999997e77 or 1.14999999999999997e77 < im < 1.4e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative4.2%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/4.2%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval4.2%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative4.2%

        \[\leadsto \frac{\left(262144 - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -512}} \]
    9. Applied egg-rr4.2%

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Step-by-step derivation
      1. sub-neg4.2%

        \[\leadsto \frac{\color{blue}{\left(262144 + \left(-im \cdot im\right)\right)} \cdot \cos re}{im + -512} \]
      2. flip-+100.0%

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

        \[\leadsto \frac{\frac{\color{blue}{68719476736} - \left(-im \cdot im\right) \cdot \left(-im \cdot im\right)}{262144 - \left(-im \cdot im\right)} \cdot \cos re}{im + -512} \]
    11. Applied egg-rr100.0%

      \[\leadsto \frac{\color{blue}{\frac{68719476736 - \left(-im \cdot im\right) \cdot \left(-im \cdot im\right)}{262144 - \left(-im \cdot im\right)}} \cdot \cos re}{im + -512} \]

    if -1.14999999999999997e77 < im < -0.0019499999999999999 or 2.35e11 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

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

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

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

    if -0.0019499999999999999 < im < 2.35e11

    1. Initial program 9.3%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \mathbf{elif}\;im \leq -1.15 \cdot 10^{+77}:\\ \;\;\;\;\frac{\cos re \cdot \frac{68719476736 - \left(im \cdot im\right) \cdot \left(im \cdot im\right)}{im \cdot im + 262144}}{im + -512}\\ \mathbf{elif}\;im \leq -0.00195:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 235000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \frac{68719476736 - \left(im \cdot im\right) \cdot \left(im \cdot im\right)}{im \cdot im + 262144}}{im + -512}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \end{array} \]

Alternative 3: 94.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -1 \cdot 10^{+113} \lor \neg \left(im \leq -0.07 \lor \neg \left(im \leq 235000000000\right) \land im \leq 2.25 \cdot 10^{+101}\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 -1e+113)
         (not
          (or (<= im -0.07)
              (and (not (<= im 235000000000.0)) (<= im 2.25e+101)))))
   (* (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 <= -1e+113) || !((im <= -0.07) || (!(im <= 235000000000.0) && (im <= 2.25e+101)))) {
		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 <= (-1d+113)) .or. (.not. (im <= (-0.07d0)) .or. (.not. (im <= 235000000000.0d0)) .and. (im <= 2.25d+101))) 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 <= -1e+113) || !((im <= -0.07) || (!(im <= 235000000000.0) && (im <= 2.25e+101)))) {
		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 <= -1e+113) or not ((im <= -0.07) or (not (im <= 235000000000.0) and (im <= 2.25e+101))):
		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 <= -1e+113) || !((im <= -0.07) || (!(im <= 235000000000.0) && (im <= 2.25e+101))))
		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 <= -1e+113) || ~(((im <= -0.07) || (~((im <= 235000000000.0)) && (im <= 2.25e+101)))))
		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, -1e+113], N[Not[Or[LessEqual[im, -0.07], And[N[Not[LessEqual[im, 235000000000.0]], $MachinePrecision], LessEqual[im, 2.25e+101]]]], $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 -1 \cdot 10^{+113} \lor \neg \left(im \leq -0.07 \lor \neg \left(im \leq 235000000000\right) \land im \leq 2.25 \cdot 10^{+101}\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 < -1e113 or -0.070000000000000007 < im < 2.35e11 or 2.2500000000000001e101 < im

    1. Initial program 42.7%

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \left(\color{blue}{{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 -1e113 < im < -0.070000000000000007 or 2.35e11 < im < 2.2500000000000001e101

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1 \cdot 10^{+113} \lor \neg \left(im \leq -0.07 \lor \neg \left(im \leq 235000000000\right) \land im \leq 2.25 \cdot 10^{+101}\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: 94.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ t_1 := \cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{if}\;im \leq -5.7 \cdot 10^{+102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -1000:\\ \;\;\;\;t_0 \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 235000000000 \lor \neg \left(im \leq 2.25 \cdot 10^{+101}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im)))
        (t_1 (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))))
   (if (<= im -5.7e+102)
     t_1
     (if (<= im -1000.0)
       (* t_0 (+ 0.5 (* -0.25 (* re re))))
       (if (or (<= im 235000000000.0) (not (<= im 2.25e+101)))
         t_1
         (* 0.5 t_0))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double t_1 = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	double tmp;
	if (im <= -5.7e+102) {
		tmp = t_1;
	} else if (im <= -1000.0) {
		tmp = t_0 * (0.5 + (-0.25 * (re * re)));
	} else if ((im <= 235000000000.0) || !(im <= 2.25e+101)) {
		tmp = t_1;
	} else {
		tmp = 0.5 * 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 = exp(-im) - exp(im)
    t_1 = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    if (im <= (-5.7d+102)) then
        tmp = t_1
    else if (im <= (-1000.0d0)) then
        tmp = t_0 * (0.5d0 + ((-0.25d0) * (re * re)))
    else if ((im <= 235000000000.0d0) .or. (.not. (im <= 2.25d+101))) then
        tmp = t_1
    else
        tmp = 0.5d0 * t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double t_1 = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	double tmp;
	if (im <= -5.7e+102) {
		tmp = t_1;
	} else if (im <= -1000.0) {
		tmp = t_0 * (0.5 + (-0.25 * (re * re)));
	} else if ((im <= 235000000000.0) || !(im <= 2.25e+101)) {
		tmp = t_1;
	} else {
		tmp = 0.5 * t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	t_1 = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	tmp = 0
	if im <= -5.7e+102:
		tmp = t_1
	elif im <= -1000.0:
		tmp = t_0 * (0.5 + (-0.25 * (re * re)))
	elif (im <= 235000000000.0) or not (im <= 2.25e+101):
		tmp = t_1
	else:
		tmp = 0.5 * t_0
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	t_1 = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im))
	tmp = 0.0
	if (im <= -5.7e+102)
		tmp = t_1;
	elseif (im <= -1000.0)
		tmp = Float64(t_0 * Float64(0.5 + Float64(-0.25 * Float64(re * re))));
	elseif ((im <= 235000000000.0) || !(im <= 2.25e+101))
		tmp = t_1;
	else
		tmp = Float64(0.5 * t_0);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	t_1 = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	tmp = 0.0;
	if (im <= -5.7e+102)
		tmp = t_1;
	elseif (im <= -1000.0)
		tmp = t_0 * (0.5 + (-0.25 * (re * re)));
	elseif ((im <= 235000000000.0) || ~((im <= 2.25e+101)))
		tmp = t_1;
	else
		tmp = 0.5 * t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.7e+102], t$95$1, If[LessEqual[im, -1000.0], N[(t$95$0 * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, 235000000000.0], N[Not[LessEqual[im, 2.25e+101]], $MachinePrecision]], t$95$1, N[(0.5 * t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 235000000000 \lor \neg \left(im \leq 2.25 \cdot 10^{+101}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -5.6999999999999999e102 or -1e3 < im < 2.35e11 or 2.2500000000000001e101 < im

    1. Initial program 43.5%

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

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

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

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

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

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

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

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

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

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

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

    if -5.6999999999999999e102 < im < -1e3

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 2.35e11 < im < 2.2500000000000001e101

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.7 \cdot 10^{+102}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq -1000:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 235000000000 \lor \neg \left(im \leq 2.25 \cdot 10^{+101}\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 5: 89.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\cos re \cdot \frac{68719476736 - \left(im \cdot im\right) \cdot \left(im \cdot im\right)}{im \cdot im + 262144}}{im + -512}\\ t_1 := \frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -8 \cdot 10^{+76}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -1000:\\ \;\;\;\;\left(re \cdot \left(re \cdot -0.5\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 750000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot \left(re \cdot -6.75\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (/
          (*
           (cos re)
           (/
            (- 68719476736.0 (* (* im im) (* im im)))
            (+ (* im im) 262144.0)))
          (+ im -512.0)))
        (t_1 (/ (* (cos re) (- (* im im))) (+ im -512.0))))
   (if (<= im -1.35e+154)
     t_1
     (if (<= im -8e+76)
       t_0
       (if (<= im -1000.0)
         (*
          (+ (* re (* re -0.5)) 1.0)
          (- (* (pow im 3.0) -0.16666666666666666) im))
         (if (<= im 750000000000.0)
           (- (* im (cos re)))
           (if (<= im 1.15e+77)
             (log1p (expm1 (* re (* re -6.75))))
             (if (<= im 1.4e+154) t_0 t_1))))))))
double code(double re, double im) {
	double t_0 = (cos(re) * ((68719476736.0 - ((im * im) * (im * im))) / ((im * im) + 262144.0))) / (im + -512.0);
	double t_1 = (cos(re) * -(im * im)) / (im + -512.0);
	double tmp;
	if (im <= -1.35e+154) {
		tmp = t_1;
	} else if (im <= -8e+76) {
		tmp = t_0;
	} else if (im <= -1000.0) {
		tmp = ((re * (re * -0.5)) + 1.0) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 750000000000.0) {
		tmp = -(im * cos(re));
	} else if (im <= 1.15e+77) {
		tmp = log1p(expm1((re * (re * -6.75))));
	} else if (im <= 1.4e+154) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = (Math.cos(re) * ((68719476736.0 - ((im * im) * (im * im))) / ((im * im) + 262144.0))) / (im + -512.0);
	double t_1 = (Math.cos(re) * -(im * im)) / (im + -512.0);
	double tmp;
	if (im <= -1.35e+154) {
		tmp = t_1;
	} else if (im <= -8e+76) {
		tmp = t_0;
	} else if (im <= -1000.0) {
		tmp = ((re * (re * -0.5)) + 1.0) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 750000000000.0) {
		tmp = -(im * Math.cos(re));
	} else if (im <= 1.15e+77) {
		tmp = Math.log1p(Math.expm1((re * (re * -6.75))));
	} else if (im <= 1.4e+154) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.cos(re) * ((68719476736.0 - ((im * im) * (im * im))) / ((im * im) + 262144.0))) / (im + -512.0)
	t_1 = (math.cos(re) * -(im * im)) / (im + -512.0)
	tmp = 0
	if im <= -1.35e+154:
		tmp = t_1
	elif im <= -8e+76:
		tmp = t_0
	elif im <= -1000.0:
		tmp = ((re * (re * -0.5)) + 1.0) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	elif im <= 750000000000.0:
		tmp = -(im * math.cos(re))
	elif im <= 1.15e+77:
		tmp = math.log1p(math.expm1((re * (re * -6.75))))
	elif im <= 1.4e+154:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(cos(re) * Float64(Float64(68719476736.0 - Float64(Float64(im * im) * Float64(im * im))) / Float64(Float64(im * im) + 262144.0))) / Float64(im + -512.0))
	t_1 = Float64(Float64(cos(re) * Float64(-Float64(im * im))) / Float64(im + -512.0))
	tmp = 0.0
	if (im <= -1.35e+154)
		tmp = t_1;
	elseif (im <= -8e+76)
		tmp = t_0;
	elseif (im <= -1000.0)
		tmp = Float64(Float64(Float64(re * Float64(re * -0.5)) + 1.0) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	elseif (im <= 750000000000.0)
		tmp = Float64(-Float64(im * cos(re)));
	elseif (im <= 1.15e+77)
		tmp = log1p(expm1(Float64(re * Float64(re * -6.75))));
	elseif (im <= 1.4e+154)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Cos[re], $MachinePrecision] * N[(N[(68719476736.0 - N[(N[(im * im), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(im * im), $MachinePrecision] + 262144.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * (-N[(im * im), $MachinePrecision])), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.35e+154], t$95$1, If[LessEqual[im, -8e+76], t$95$0, If[LessEqual[im, -1000.0], N[(N[(N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 750000000000.0], (-N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), If[LessEqual[im, 1.15e+77], N[Log[1 + N[(Exp[N[(re * N[(re * -6.75), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 1.4e+154], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\cos re \cdot \frac{68719476736 - \left(im \cdot im\right) \cdot \left(im \cdot im\right)}{im \cdot im + 262144}}{im + -512}\\
t_1 := \frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\
\mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -8 \cdot 10^{+76}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -1000:\\
\;\;\;\;\left(re \cdot \left(re \cdot -0.5\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\

\mathbf{elif}\;im \leq 750000000000:\\
\;\;\;\;-im \cdot \cos re\\

\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot \left(re \cdot -6.75\right)\right)\right)\\

\mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < -1.35000000000000003e154 or 1.4e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative7.6%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval100.0%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative100.0%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in im around inf 100.0%

      \[\leadsto \frac{\color{blue}{\left(-1 \cdot {im}^{2}\right)} \cdot \cos re}{im + -512} \]
    11. Step-by-step derivation
      1. unpow2100.0%

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

        \[\leadsto \frac{\color{blue}{\left(-im \cdot im\right)} \cdot \cos re}{im + -512} \]
    12. Simplified100.0%

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

    if -1.35000000000000003e154 < im < -8.0000000000000004e76 or 1.14999999999999997e77 < im < 1.4e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative4.2%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/4.2%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval4.2%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative4.2%

        \[\leadsto \frac{\left(262144 - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -512}} \]
    9. Applied egg-rr4.2%

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Step-by-step derivation
      1. sub-neg4.2%

        \[\leadsto \frac{\color{blue}{\left(262144 + \left(-im \cdot im\right)\right)} \cdot \cos re}{im + -512} \]
      2. flip-+97.4%

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

        \[\leadsto \frac{\frac{\color{blue}{68719476736} - \left(-im \cdot im\right) \cdot \left(-im \cdot im\right)}{262144 - \left(-im \cdot im\right)} \cdot \cos re}{im + -512} \]
    11. Applied egg-rr97.4%

      \[\leadsto \frac{\color{blue}{\frac{68719476736 - \left(-im \cdot im\right) \cdot \left(-im \cdot im\right)}{262144 - \left(-im \cdot im\right)}} \cdot \cos re}{im + -512} \]

    if -8.0000000000000004e76 < im < -1e3

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\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+38.4%

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

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

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

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

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

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

    if -1e3 < im < 7.5e11

    1. Initial program 10.7%

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

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

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

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

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

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

    if 7.5e11 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -6.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
      2. *-commutative20.9%

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

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

      \[\leadsto \color{blue}{re \cdot \left(re \cdot -6.75\right)} \]
    11. Step-by-step derivation
      1. log1p-expm1-u43.6%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot \left(re \cdot -6.75\right)\right)\right)} \]
    12. Applied egg-rr43.6%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot \left(re \cdot -6.75\right)\right)\right)} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification90.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \mathbf{elif}\;im \leq -8 \cdot 10^{+76}:\\ \;\;\;\;\frac{\cos re \cdot \frac{68719476736 - \left(im \cdot im\right) \cdot \left(im \cdot im\right)}{im \cdot im + 262144}}{im + -512}\\ \mathbf{elif}\;im \leq -1000:\\ \;\;\;\;\left(re \cdot \left(re \cdot -0.5\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 750000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot \left(re \cdot -6.75\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \frac{68719476736 - \left(im \cdot im\right) \cdot \left(im \cdot im\right)}{im \cdot im + 262144}}{im + -512}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \end{array} \]

Alternative 6: 89.4% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\cos re \cdot \frac{68719476736 - \left(im \cdot im\right) \cdot \left(im \cdot im\right)}{im \cdot im + 262144}}{im + -512}\\ t_1 := \frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -8 \cdot 10^{+76}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -1000:\\ \;\;\;\;\left(re \cdot \left(re \cdot -0.5\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 750000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (/
          (*
           (cos re)
           (/
            (- 68719476736.0 (* (* im im) (* im im)))
            (+ (* im im) 262144.0)))
          (+ im -512.0)))
        (t_1 (/ (* (cos re) (- (* im im))) (+ im -512.0))))
   (if (<= im -1.35e+154)
     t_1
     (if (<= im -8e+76)
       t_0
       (if (<= im -1000.0)
         (*
          (+ (* re (* re -0.5)) 1.0)
          (- (* (pow im 3.0) -0.16666666666666666) im))
         (if (<= im 750000000000.0)
           (- (* im (cos re)))
           (if (<= im 1.15e+77)
             (-
              (* (* re re) (* im (+ 0.5 (* (* re re) -0.041666666666666664))))
              im)
             (if (<= im 1.4e+154) t_0 t_1))))))))
double code(double re, double im) {
	double t_0 = (cos(re) * ((68719476736.0 - ((im * im) * (im * im))) / ((im * im) + 262144.0))) / (im + -512.0);
	double t_1 = (cos(re) * -(im * im)) / (im + -512.0);
	double tmp;
	if (im <= -1.35e+154) {
		tmp = t_1;
	} else if (im <= -8e+76) {
		tmp = t_0;
	} else if (im <= -1000.0) {
		tmp = ((re * (re * -0.5)) + 1.0) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 750000000000.0) {
		tmp = -(im * cos(re));
	} else if (im <= 1.15e+77) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 1.4e+154) {
		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 = (cos(re) * ((68719476736.0d0 - ((im * im) * (im * im))) / ((im * im) + 262144.0d0))) / (im + (-512.0d0))
    t_1 = (cos(re) * -(im * im)) / (im + (-512.0d0))
    if (im <= (-1.35d+154)) then
        tmp = t_1
    else if (im <= (-8d+76)) then
        tmp = t_0
    else if (im <= (-1000.0d0)) then
        tmp = ((re * (re * (-0.5d0))) + 1.0d0) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    else if (im <= 750000000000.0d0) then
        tmp = -(im * cos(re))
    else if (im <= 1.15d+77) then
        tmp = ((re * re) * (im * (0.5d0 + ((re * re) * (-0.041666666666666664d0))))) - im
    else if (im <= 1.4d+154) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (Math.cos(re) * ((68719476736.0 - ((im * im) * (im * im))) / ((im * im) + 262144.0))) / (im + -512.0);
	double t_1 = (Math.cos(re) * -(im * im)) / (im + -512.0);
	double tmp;
	if (im <= -1.35e+154) {
		tmp = t_1;
	} else if (im <= -8e+76) {
		tmp = t_0;
	} else if (im <= -1000.0) {
		tmp = ((re * (re * -0.5)) + 1.0) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 750000000000.0) {
		tmp = -(im * Math.cos(re));
	} else if (im <= 1.15e+77) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 1.4e+154) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.cos(re) * ((68719476736.0 - ((im * im) * (im * im))) / ((im * im) + 262144.0))) / (im + -512.0)
	t_1 = (math.cos(re) * -(im * im)) / (im + -512.0)
	tmp = 0
	if im <= -1.35e+154:
		tmp = t_1
	elif im <= -8e+76:
		tmp = t_0
	elif im <= -1000.0:
		tmp = ((re * (re * -0.5)) + 1.0) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	elif im <= 750000000000.0:
		tmp = -(im * math.cos(re))
	elif im <= 1.15e+77:
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im
	elif im <= 1.4e+154:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(cos(re) * Float64(Float64(68719476736.0 - Float64(Float64(im * im) * Float64(im * im))) / Float64(Float64(im * im) + 262144.0))) / Float64(im + -512.0))
	t_1 = Float64(Float64(cos(re) * Float64(-Float64(im * im))) / Float64(im + -512.0))
	tmp = 0.0
	if (im <= -1.35e+154)
		tmp = t_1;
	elseif (im <= -8e+76)
		tmp = t_0;
	elseif (im <= -1000.0)
		tmp = Float64(Float64(Float64(re * Float64(re * -0.5)) + 1.0) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	elseif (im <= 750000000000.0)
		tmp = Float64(-Float64(im * cos(re)));
	elseif (im <= 1.15e+77)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * Float64(0.5 + Float64(Float64(re * re) * -0.041666666666666664)))) - im);
	elseif (im <= 1.4e+154)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (cos(re) * ((68719476736.0 - ((im * im) * (im * im))) / ((im * im) + 262144.0))) / (im + -512.0);
	t_1 = (cos(re) * -(im * im)) / (im + -512.0);
	tmp = 0.0;
	if (im <= -1.35e+154)
		tmp = t_1;
	elseif (im <= -8e+76)
		tmp = t_0;
	elseif (im <= -1000.0)
		tmp = ((re * (re * -0.5)) + 1.0) * (((im ^ 3.0) * -0.16666666666666666) - im);
	elseif (im <= 750000000000.0)
		tmp = -(im * cos(re));
	elseif (im <= 1.15e+77)
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	elseif (im <= 1.4e+154)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Cos[re], $MachinePrecision] * N[(N[(68719476736.0 - N[(N[(im * im), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(im * im), $MachinePrecision] + 262144.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * (-N[(im * im), $MachinePrecision])), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.35e+154], t$95$1, If[LessEqual[im, -8e+76], t$95$0, If[LessEqual[im, -1000.0], N[(N[(N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 750000000000.0], (-N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), If[LessEqual[im, 1.15e+77], N[(N[(N[(re * re), $MachinePrecision] * N[(im * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 1.4e+154], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\cos re \cdot \frac{68719476736 - \left(im \cdot im\right) \cdot \left(im \cdot im\right)}{im \cdot im + 262144}}{im + -512}\\
t_1 := \frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\
\mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -8 \cdot 10^{+76}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -1000:\\
\;\;\;\;\left(re \cdot \left(re \cdot -0.5\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\

\mathbf{elif}\;im \leq 750000000000:\\
\;\;\;\;-im \cdot \cos re\\

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

\mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < -1.35000000000000003e154 or 1.4e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative7.6%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval100.0%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative100.0%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in im around inf 100.0%

      \[\leadsto \frac{\color{blue}{\left(-1 \cdot {im}^{2}\right)} \cdot \cos re}{im + -512} \]
    11. Step-by-step derivation
      1. unpow2100.0%

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

        \[\leadsto \frac{\color{blue}{\left(-im \cdot im\right)} \cdot \cos re}{im + -512} \]
    12. Simplified100.0%

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

    if -1.35000000000000003e154 < im < -8.0000000000000004e76 or 1.14999999999999997e77 < im < 1.4e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative4.2%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/4.2%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval4.2%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative4.2%

        \[\leadsto \frac{\left(262144 - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -512}} \]
    9. Applied egg-rr4.2%

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Step-by-step derivation
      1. sub-neg4.2%

        \[\leadsto \frac{\color{blue}{\left(262144 + \left(-im \cdot im\right)\right)} \cdot \cos re}{im + -512} \]
      2. flip-+97.4%

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

        \[\leadsto \frac{\frac{\color{blue}{68719476736} - \left(-im \cdot im\right) \cdot \left(-im \cdot im\right)}{262144 - \left(-im \cdot im\right)} \cdot \cos re}{im + -512} \]
    11. Applied egg-rr97.4%

      \[\leadsto \frac{\color{blue}{\frac{68719476736 - \left(-im \cdot im\right) \cdot \left(-im \cdot im\right)}{262144 - \left(-im \cdot im\right)}} \cdot \cos re}{im + -512} \]

    if -8.0000000000000004e76 < im < -1e3

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\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+38.4%

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

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

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

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

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

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

    if -1e3 < im < 7.5e11

    1. Initial program 10.7%

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

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

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

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

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

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

    if 7.5e11 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{4}} + 0.5 \cdot \left(im \cdot {re}^{2}\right)\right) - im \]
      5. metadata-eval12.0%

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

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

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

        \[\leadsto \left(\left(\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{2}\right) \cdot {re}^{2} + \color{blue}{\left(0.5 \cdot im\right) \cdot {re}^{2}}\right) - im \]
      9. distribute-rgt-out31.0%

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

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

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

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

        \[\leadsto \left(re \cdot re\right) \cdot \left(im \cdot \left(-0.041666666666666664 \cdot {re}^{2}\right) + \color{blue}{im \cdot 0.5}\right) - im \]
      14. distribute-lft-out31.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \mathbf{elif}\;im \leq -8 \cdot 10^{+76}:\\ \;\;\;\;\frac{\cos re \cdot \frac{68719476736 - \left(im \cdot im\right) \cdot \left(im \cdot im\right)}{im \cdot im + 262144}}{im + -512}\\ \mathbf{elif}\;im \leq -1000:\\ \;\;\;\;\left(re \cdot \left(re \cdot -0.5\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 750000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \frac{68719476736 - \left(im \cdot im\right) \cdot \left(im \cdot im\right)}{im \cdot im + 262144}}{im + -512}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \end{array} \]

Alternative 7: 84.2% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(re \cdot \left(re \cdot -0.5\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ t_1 := \frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -1000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 750000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 3.1 \cdot 10^{+92}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (*
          (+ (* re (* re -0.5)) 1.0)
          (- (* (pow im 3.0) -0.16666666666666666) im)))
        (t_1 (/ (* (cos re) (- (* im im))) (+ im -512.0))))
   (if (<= im -1.35e+154)
     t_1
     (if (<= im -1000.0)
       t_0
       (if (<= im 750000000000.0)
         (- (* im (cos re)))
         (if (<= im 3.1e+92)
           (-
            (* (* re re) (* im (+ 0.5 (* (* re re) -0.041666666666666664))))
            im)
           (if (<= im 1.4e+154) t_0 t_1)))))))
double code(double re, double im) {
	double t_0 = ((re * (re * -0.5)) + 1.0) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	double t_1 = (cos(re) * -(im * im)) / (im + -512.0);
	double tmp;
	if (im <= -1.35e+154) {
		tmp = t_1;
	} else if (im <= -1000.0) {
		tmp = t_0;
	} else if (im <= 750000000000.0) {
		tmp = -(im * cos(re));
	} else if (im <= 3.1e+92) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 1.4e+154) {
		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 = ((re * (re * (-0.5d0))) + 1.0d0) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    t_1 = (cos(re) * -(im * im)) / (im + (-512.0d0))
    if (im <= (-1.35d+154)) then
        tmp = t_1
    else if (im <= (-1000.0d0)) then
        tmp = t_0
    else if (im <= 750000000000.0d0) then
        tmp = -(im * cos(re))
    else if (im <= 3.1d+92) then
        tmp = ((re * re) * (im * (0.5d0 + ((re * re) * (-0.041666666666666664d0))))) - im
    else if (im <= 1.4d+154) 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 = ((re * (re * -0.5)) + 1.0) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	double t_1 = (Math.cos(re) * -(im * im)) / (im + -512.0);
	double tmp;
	if (im <= -1.35e+154) {
		tmp = t_1;
	} else if (im <= -1000.0) {
		tmp = t_0;
	} else if (im <= 750000000000.0) {
		tmp = -(im * Math.cos(re));
	} else if (im <= 3.1e+92) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 1.4e+154) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = ((re * (re * -0.5)) + 1.0) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	t_1 = (math.cos(re) * -(im * im)) / (im + -512.0)
	tmp = 0
	if im <= -1.35e+154:
		tmp = t_1
	elif im <= -1000.0:
		tmp = t_0
	elif im <= 750000000000.0:
		tmp = -(im * math.cos(re))
	elif im <= 3.1e+92:
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im
	elif im <= 1.4e+154:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(Float64(re * Float64(re * -0.5)) + 1.0) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im))
	t_1 = Float64(Float64(cos(re) * Float64(-Float64(im * im))) / Float64(im + -512.0))
	tmp = 0.0
	if (im <= -1.35e+154)
		tmp = t_1;
	elseif (im <= -1000.0)
		tmp = t_0;
	elseif (im <= 750000000000.0)
		tmp = Float64(-Float64(im * cos(re)));
	elseif (im <= 3.1e+92)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * Float64(0.5 + Float64(Float64(re * re) * -0.041666666666666664)))) - im);
	elseif (im <= 1.4e+154)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = ((re * (re * -0.5)) + 1.0) * (((im ^ 3.0) * -0.16666666666666666) - im);
	t_1 = (cos(re) * -(im * im)) / (im + -512.0);
	tmp = 0.0;
	if (im <= -1.35e+154)
		tmp = t_1;
	elseif (im <= -1000.0)
		tmp = t_0;
	elseif (im <= 750000000000.0)
		tmp = -(im * cos(re));
	elseif (im <= 3.1e+92)
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	elseif (im <= 1.4e+154)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(re * N[(re * -0.5), $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[(N[Cos[re], $MachinePrecision] * (-N[(im * im), $MachinePrecision])), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.35e+154], t$95$1, If[LessEqual[im, -1000.0], t$95$0, If[LessEqual[im, 750000000000.0], (-N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), If[LessEqual[im, 3.1e+92], N[(N[(N[(re * re), $MachinePrecision] * N[(im * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 1.4e+154], t$95$0, t$95$1]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 750000000000:\\
\;\;\;\;-im \cdot \cos re\\

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

\mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -1.35000000000000003e154 or 1.4e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative7.6%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval100.0%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative100.0%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in im around inf 100.0%

      \[\leadsto \frac{\color{blue}{\left(-1 \cdot {im}^{2}\right)} \cdot \cos re}{im + -512} \]
    11. Step-by-step derivation
      1. unpow2100.0%

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

        \[\leadsto \frac{\color{blue}{\left(-im \cdot im\right)} \cdot \cos re}{im + -512} \]
    12. Simplified100.0%

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

    if -1.35000000000000003e154 < im < -1e3 or 3.1000000000000002e92 < im < 1.4e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\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+22.8%

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

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

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

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

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

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

    if -1e3 < im < 7.5e11

    1. Initial program 10.7%

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

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

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

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

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

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

    if 7.5e11 < im < 3.1000000000000002e92

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{4}} + 0.5 \cdot \left(im \cdot {re}^{2}\right)\right) - im \]
      5. metadata-eval14.8%

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

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

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

        \[\leadsto \left(\left(\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{2}\right) \cdot {re}^{2} + \color{blue}{\left(0.5 \cdot im\right) \cdot {re}^{2}}\right) - im \]
      9. distribute-rgt-out35.6%

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

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

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

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

        \[\leadsto \left(re \cdot re\right) \cdot \left(im \cdot \left(-0.041666666666666664 \cdot {re}^{2}\right) + \color{blue}{im \cdot 0.5}\right) - im \]
      14. distribute-lft-out35.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \mathbf{elif}\;im \leq -1000:\\ \;\;\;\;\left(re \cdot \left(re \cdot -0.5\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 750000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 3.1 \cdot 10^{+92}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\ \;\;\;\;\left(re \cdot \left(re \cdot -0.5\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \end{array} \]

Alternative 8: 79.5% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ t_1 := \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{if}\;im \leq -6.4 \cdot 10^{+100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -150000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 750000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+95}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 5.4 \cdot 10^{+133}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666))
        (t_1
         (/
          (+
           262144.0
           (- (* -0.5 (* (* re re) (- 262144.0 (* im im)))) (* im im)))
          (+ im -512.0))))
   (if (<= im -6.4e+100)
     t_0
     (if (<= im -150000000000.0)
       t_1
       (if (<= im 750000000000.0)
         (- (* im (cos re)))
         (if (<= im 1.35e+95)
           (-
            (* (* re re) (* im (+ 0.5 (* (* re re) -0.041666666666666664))))
            im)
           (if (<= im 5.4e+133)
             t_1
             (if (<= im 1.4e+154)
               t_0
               (/ (* (cos re) (- (* im im))) (+ im -512.0))))))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0);
	double tmp;
	if (im <= -6.4e+100) {
		tmp = t_0;
	} else if (im <= -150000000000.0) {
		tmp = t_1;
	} else if (im <= 750000000000.0) {
		tmp = -(im * cos(re));
	} else if (im <= 1.35e+95) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 5.4e+133) {
		tmp = t_1;
	} else if (im <= 1.4e+154) {
		tmp = t_0;
	} else {
		tmp = (cos(re) * -(im * im)) / (im + -512.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)
    t_1 = (262144.0d0 + (((-0.5d0) * ((re * re) * (262144.0d0 - (im * im)))) - (im * im))) / (im + (-512.0d0))
    if (im <= (-6.4d+100)) then
        tmp = t_0
    else if (im <= (-150000000000.0d0)) then
        tmp = t_1
    else if (im <= 750000000000.0d0) then
        tmp = -(im * cos(re))
    else if (im <= 1.35d+95) then
        tmp = ((re * re) * (im * (0.5d0 + ((re * re) * (-0.041666666666666664d0))))) - im
    else if (im <= 5.4d+133) then
        tmp = t_1
    else if (im <= 1.4d+154) then
        tmp = t_0
    else
        tmp = (cos(re) * -(im * im)) / (im + (-512.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 3.0) * -0.16666666666666666;
	double t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0);
	double tmp;
	if (im <= -6.4e+100) {
		tmp = t_0;
	} else if (im <= -150000000000.0) {
		tmp = t_1;
	} else if (im <= 750000000000.0) {
		tmp = -(im * Math.cos(re));
	} else if (im <= 1.35e+95) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 5.4e+133) {
		tmp = t_1;
	} else if (im <= 1.4e+154) {
		tmp = t_0;
	} else {
		tmp = (Math.cos(re) * -(im * im)) / (im + -512.0);
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0)
	tmp = 0
	if im <= -6.4e+100:
		tmp = t_0
	elif im <= -150000000000.0:
		tmp = t_1
	elif im <= 750000000000.0:
		tmp = -(im * math.cos(re))
	elif im <= 1.35e+95:
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im
	elif im <= 5.4e+133:
		tmp = t_1
	elif im <= 1.4e+154:
		tmp = t_0
	else:
		tmp = (math.cos(re) * -(im * im)) / (im + -512.0)
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	t_1 = Float64(Float64(262144.0 + Float64(Float64(-0.5 * Float64(Float64(re * re) * Float64(262144.0 - Float64(im * im)))) - Float64(im * im))) / Float64(im + -512.0))
	tmp = 0.0
	if (im <= -6.4e+100)
		tmp = t_0;
	elseif (im <= -150000000000.0)
		tmp = t_1;
	elseif (im <= 750000000000.0)
		tmp = Float64(-Float64(im * cos(re)));
	elseif (im <= 1.35e+95)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * Float64(0.5 + Float64(Float64(re * re) * -0.041666666666666664)))) - im);
	elseif (im <= 5.4e+133)
		tmp = t_1;
	elseif (im <= 1.4e+154)
		tmp = t_0;
	else
		tmp = Float64(Float64(cos(re) * Float64(-Float64(im * im))) / Float64(im + -512.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0);
	tmp = 0.0;
	if (im <= -6.4e+100)
		tmp = t_0;
	elseif (im <= -150000000000.0)
		tmp = t_1;
	elseif (im <= 750000000000.0)
		tmp = -(im * cos(re));
	elseif (im <= 1.35e+95)
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	elseif (im <= 5.4e+133)
		tmp = t_1;
	elseif (im <= 1.4e+154)
		tmp = t_0;
	else
		tmp = (cos(re) * -(im * im)) / (im + -512.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, Block[{t$95$1 = N[(N[(262144.0 + N[(N[(-0.5 * N[(N[(re * re), $MachinePrecision] * N[(262144.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.4e+100], t$95$0, If[LessEqual[im, -150000000000.0], t$95$1, If[LessEqual[im, 750000000000.0], (-N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), If[LessEqual[im, 1.35e+95], N[(N[(N[(re * re), $MachinePrecision] * N[(im * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 5.4e+133], t$95$1, If[LessEqual[im, 1.4e+154], t$95$0, N[(N[(N[Cos[re], $MachinePrecision] * (-N[(im * im), $MachinePrecision])), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
t_1 := \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\
\mathbf{if}\;im \leq -6.4 \cdot 10^{+100}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 750000000000:\\
\;\;\;\;-im \cdot \cos re\\

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

\mathbf{elif}\;im \leq 5.4 \cdot 10^{+133}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < -6.3999999999999998e100 or 5.4000000000000004e133 < im < 1.4e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around inf 86.6%

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

    if -6.3999999999999998e100 < im < -1.5e11 or 1.35e95 < im < 5.4000000000000004e133

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/3.8%

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

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative3.8%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in re around 0 51.5%

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

        \[\leadsto \frac{\left(262144 + -0.5 \cdot \left({re}^{2} \cdot \left(262144 - {im}^{2}\right)\right)\right) - \color{blue}{im \cdot im}}{im + -512} \]
      2. associate--l+51.5%

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

        \[\leadsto \frac{262144 + \left(-0.5 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot \left(262144 - {im}^{2}\right)\right) - im \cdot im\right)}{im + -512} \]
      4. unpow251.5%

        \[\leadsto \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - \color{blue}{im \cdot im}\right)\right) - im \cdot im\right)}{im + -512} \]
    12. Simplified51.5%

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

    if -1.5e11 < im < 7.5e11

    1. Initial program 12.1%

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

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

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

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

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

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

    if 7.5e11 < im < 1.35e95

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{2}\right) \cdot {re}^{2} + \color{blue}{\left(0.5 \cdot im\right) \cdot {re}^{2}}\right) - im \]
      9. distribute-rgt-out34.4%

        \[\leadsto \color{blue}{{re}^{2} \cdot \left(\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{2} + 0.5 \cdot im\right)} - im \]
      10. unpow234.4%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot \left(\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{2} + 0.5 \cdot im\right) - im \]
      11. *-commutative34.4%

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

        \[\leadsto \left(re \cdot re\right) \cdot \left(\color{blue}{im \cdot \left(-0.041666666666666664 \cdot {re}^{2}\right)} + 0.5 \cdot im\right) - im \]
      13. *-commutative34.4%

        \[\leadsto \left(re \cdot re\right) \cdot \left(im \cdot \left(-0.041666666666666664 \cdot {re}^{2}\right) + \color{blue}{im \cdot 0.5}\right) - im \]
      14. distribute-lft-out34.4%

        \[\leadsto \left(re \cdot re\right) \cdot \color{blue}{\left(im \cdot \left(-0.041666666666666664 \cdot {re}^{2} + 0.5\right)\right)} - im \]
      15. unpow234.4%

        \[\leadsto \left(re \cdot re\right) \cdot \left(im \cdot \left(-0.041666666666666664 \cdot \color{blue}{\left(re \cdot re\right)} + 0.5\right)\right) - im \]
    9. Simplified34.4%

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

    if 1.4e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative7.4%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/100.0%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval100.0%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative100.0%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in im around inf 100.0%

      \[\leadsto \frac{\color{blue}{\left(-1 \cdot {im}^{2}\right)} \cdot \cos re}{im + -512} \]
    11. Step-by-step derivation
      1. unpow2100.0%

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

        \[\leadsto \frac{\color{blue}{\left(-im \cdot im\right)} \cdot \cos re}{im + -512} \]
    12. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.4 \cdot 10^{+100}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -150000000000:\\ \;\;\;\;\frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{elif}\;im \leq 750000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+95}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 5.4 \cdot 10^{+133}:\\ \;\;\;\;\frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(-im \cdot im\right)}{im + -512}\\ \end{array} \]

Alternative 9: 76.5% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ t_1 := \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{if}\;im \leq -6.8 \cdot 10^{+100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -150000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 1500000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 1.5 \cdot 10^{+93}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 3 \cdot 10^{+134}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0 - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666))
        (t_1
         (/
          (+
           262144.0
           (- (* -0.5 (* (* re re) (- 262144.0 (* im im)))) (* im im)))
          (+ im -512.0))))
   (if (<= im -6.8e+100)
     t_0
     (if (<= im -150000000000.0)
       t_1
       (if (<= im 1500000000000.0)
         (- (* im (cos re)))
         (if (<= im 1.5e+93)
           (-
            (* (* re re) (* im (+ 0.5 (* (* re re) -0.041666666666666664))))
            im)
           (if (<= im 3e+134) t_1 (- t_0 im))))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0);
	double tmp;
	if (im <= -6.8e+100) {
		tmp = t_0;
	} else if (im <= -150000000000.0) {
		tmp = t_1;
	} else if (im <= 1500000000000.0) {
		tmp = -(im * cos(re));
	} else if (im <= 1.5e+93) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 3e+134) {
		tmp = t_1;
	} else {
		tmp = t_0 - im;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (im ** 3.0d0) * (-0.16666666666666666d0)
    t_1 = (262144.0d0 + (((-0.5d0) * ((re * re) * (262144.0d0 - (im * im)))) - (im * im))) / (im + (-512.0d0))
    if (im <= (-6.8d+100)) then
        tmp = t_0
    else if (im <= (-150000000000.0d0)) then
        tmp = t_1
    else if (im <= 1500000000000.0d0) then
        tmp = -(im * cos(re))
    else if (im <= 1.5d+93) then
        tmp = ((re * re) * (im * (0.5d0 + ((re * re) * (-0.041666666666666664d0))))) - im
    else if (im <= 3d+134) then
        tmp = t_1
    else
        tmp = t_0 - im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 3.0) * -0.16666666666666666;
	double t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0);
	double tmp;
	if (im <= -6.8e+100) {
		tmp = t_0;
	} else if (im <= -150000000000.0) {
		tmp = t_1;
	} else if (im <= 1500000000000.0) {
		tmp = -(im * Math.cos(re));
	} else if (im <= 1.5e+93) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 3e+134) {
		tmp = t_1;
	} else {
		tmp = t_0 - im;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0)
	tmp = 0
	if im <= -6.8e+100:
		tmp = t_0
	elif im <= -150000000000.0:
		tmp = t_1
	elif im <= 1500000000000.0:
		tmp = -(im * math.cos(re))
	elif im <= 1.5e+93:
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im
	elif im <= 3e+134:
		tmp = t_1
	else:
		tmp = t_0 - im
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	t_1 = Float64(Float64(262144.0 + Float64(Float64(-0.5 * Float64(Float64(re * re) * Float64(262144.0 - Float64(im * im)))) - Float64(im * im))) / Float64(im + -512.0))
	tmp = 0.0
	if (im <= -6.8e+100)
		tmp = t_0;
	elseif (im <= -150000000000.0)
		tmp = t_1;
	elseif (im <= 1500000000000.0)
		tmp = Float64(-Float64(im * cos(re)));
	elseif (im <= 1.5e+93)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * Float64(0.5 + Float64(Float64(re * re) * -0.041666666666666664)))) - im);
	elseif (im <= 3e+134)
		tmp = t_1;
	else
		tmp = Float64(t_0 - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0);
	tmp = 0.0;
	if (im <= -6.8e+100)
		tmp = t_0;
	elseif (im <= -150000000000.0)
		tmp = t_1;
	elseif (im <= 1500000000000.0)
		tmp = -(im * cos(re));
	elseif (im <= 1.5e+93)
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	elseif (im <= 3e+134)
		tmp = t_1;
	else
		tmp = t_0 - im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, Block[{t$95$1 = N[(N[(262144.0 + N[(N[(-0.5 * N[(N[(re * re), $MachinePrecision] * N[(262144.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.8e+100], t$95$0, If[LessEqual[im, -150000000000.0], t$95$1, If[LessEqual[im, 1500000000000.0], (-N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), If[LessEqual[im, 1.5e+93], N[(N[(N[(re * re), $MachinePrecision] * N[(im * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 3e+134], t$95$1, N[(t$95$0 - im), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
t_1 := \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\
\mathbf{if}\;im \leq -6.8 \cdot 10^{+100}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 1500000000000:\\
\;\;\;\;-im \cdot \cos re\\

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

\mathbf{elif}\;im \leq 3 \cdot 10^{+134}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < -6.79999999999999988e100

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around inf 84.9%

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

    if -6.79999999999999988e100 < im < -1.5e11 or 1.49999999999999989e93 < im < 2.99999999999999997e134

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/3.8%

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

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative3.8%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in re around 0 51.5%

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

        \[\leadsto \frac{\left(262144 + -0.5 \cdot \left({re}^{2} \cdot \left(262144 - {im}^{2}\right)\right)\right) - \color{blue}{im \cdot im}}{im + -512} \]
      2. associate--l+51.5%

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

        \[\leadsto \frac{262144 + \left(-0.5 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot \left(262144 - {im}^{2}\right)\right) - im \cdot im\right)}{im + -512} \]
      4. unpow251.5%

        \[\leadsto \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - \color{blue}{im \cdot im}\right)\right) - im \cdot im\right)}{im + -512} \]
    12. Simplified51.5%

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

    if -1.5e11 < im < 1.5e12

    1. Initial program 12.1%

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

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

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

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

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

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

    if 1.5e12 < im < 1.49999999999999989e93

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{2}\right) \cdot {re}^{2} + \color{blue}{\left(0.5 \cdot im\right) \cdot {re}^{2}}\right) - im \]
      9. distribute-rgt-out34.4%

        \[\leadsto \color{blue}{{re}^{2} \cdot \left(\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{2} + 0.5 \cdot im\right)} - im \]
      10. unpow234.4%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot \left(\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{2} + 0.5 \cdot im\right) - im \]
      11. *-commutative34.4%

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

        \[\leadsto \left(re \cdot re\right) \cdot \left(\color{blue}{im \cdot \left(-0.041666666666666664 \cdot {re}^{2}\right)} + 0.5 \cdot im\right) - im \]
      13. *-commutative34.4%

        \[\leadsto \left(re \cdot re\right) \cdot \left(im \cdot \left(-0.041666666666666664 \cdot {re}^{2}\right) + \color{blue}{im \cdot 0.5}\right) - im \]
      14. distribute-lft-out34.4%

        \[\leadsto \left(re \cdot re\right) \cdot \color{blue}{\left(im \cdot \left(-0.041666666666666664 \cdot {re}^{2} + 0.5\right)\right)} - im \]
      15. unpow234.4%

        \[\leadsto \left(re \cdot re\right) \cdot \left(im \cdot \left(-0.041666666666666664 \cdot \color{blue}{\left(re \cdot re\right)} + 0.5\right)\right) - im \]
    9. Simplified34.4%

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

    if 2.99999999999999997e134 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.8 \cdot 10^{+100}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -150000000000:\\ \;\;\;\;\frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{elif}\;im \leq 1500000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 1.5 \cdot 10^{+93}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 3 \cdot 10^{+134}:\\ \;\;\;\;\frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 10: 54.6% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ t_1 := \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{if}\;im \leq -7 \cdot 10^{+100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -150000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 235000000000:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 3.9 \cdot 10^{+93}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 5.4 \cdot 10^{+133}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666))
        (t_1
         (/
          (+
           262144.0
           (- (* -0.5 (* (* re re) (- 262144.0 (* im im)))) (* im im)))
          (+ im -512.0))))
   (if (<= im -7e+100)
     t_0
     (if (<= im -150000000000.0)
       t_1
       (if (<= im 235000000000.0)
         (- im)
         (if (<= im 3.9e+93)
           (-
            (* (* re re) (* im (+ 0.5 (* (* re re) -0.041666666666666664))))
            im)
           (if (<= im 5.4e+133) t_1 t_0)))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0);
	double tmp;
	if (im <= -7e+100) {
		tmp = t_0;
	} else if (im <= -150000000000.0) {
		tmp = t_1;
	} else if (im <= 235000000000.0) {
		tmp = -im;
	} else if (im <= 3.9e+93) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 5.4e+133) {
		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 = (im ** 3.0d0) * (-0.16666666666666666d0)
    t_1 = (262144.0d0 + (((-0.5d0) * ((re * re) * (262144.0d0 - (im * im)))) - (im * im))) / (im + (-512.0d0))
    if (im <= (-7d+100)) then
        tmp = t_0
    else if (im <= (-150000000000.0d0)) then
        tmp = t_1
    else if (im <= 235000000000.0d0) then
        tmp = -im
    else if (im <= 3.9d+93) then
        tmp = ((re * re) * (im * (0.5d0 + ((re * re) * (-0.041666666666666664d0))))) - im
    else if (im <= 5.4d+133) 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 = Math.pow(im, 3.0) * -0.16666666666666666;
	double t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0);
	double tmp;
	if (im <= -7e+100) {
		tmp = t_0;
	} else if (im <= -150000000000.0) {
		tmp = t_1;
	} else if (im <= 235000000000.0) {
		tmp = -im;
	} else if (im <= 3.9e+93) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 5.4e+133) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0)
	tmp = 0
	if im <= -7e+100:
		tmp = t_0
	elif im <= -150000000000.0:
		tmp = t_1
	elif im <= 235000000000.0:
		tmp = -im
	elif im <= 3.9e+93:
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im
	elif im <= 5.4e+133:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	t_1 = Float64(Float64(262144.0 + Float64(Float64(-0.5 * Float64(Float64(re * re) * Float64(262144.0 - Float64(im * im)))) - Float64(im * im))) / Float64(im + -512.0))
	tmp = 0.0
	if (im <= -7e+100)
		tmp = t_0;
	elseif (im <= -150000000000.0)
		tmp = t_1;
	elseif (im <= 235000000000.0)
		tmp = Float64(-im);
	elseif (im <= 3.9e+93)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * Float64(0.5 + Float64(Float64(re * re) * -0.041666666666666664)))) - im);
	elseif (im <= 5.4e+133)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0);
	tmp = 0.0;
	if (im <= -7e+100)
		tmp = t_0;
	elseif (im <= -150000000000.0)
		tmp = t_1;
	elseif (im <= 235000000000.0)
		tmp = -im;
	elseif (im <= 3.9e+93)
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	elseif (im <= 5.4e+133)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, Block[{t$95$1 = N[(N[(262144.0 + N[(N[(-0.5 * N[(N[(re * re), $MachinePrecision] * N[(262144.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7e+100], t$95$0, If[LessEqual[im, -150000000000.0], t$95$1, If[LessEqual[im, 235000000000.0], (-im), If[LessEqual[im, 3.9e+93], N[(N[(N[(re * re), $MachinePrecision] * N[(im * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 5.4e+133], t$95$1, t$95$0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
t_1 := \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\
\mathbf{if}\;im \leq -7 \cdot 10^{+100}:\\
\;\;\;\;t_0\\

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

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

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

\mathbf{elif}\;im \leq 5.4 \cdot 10^{+133}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -6.99999999999999953e100 or 5.4000000000000004e133 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around inf 84.0%

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

    if -6.99999999999999953e100 < im < -1.5e11 or 3.9000000000000002e93 < im < 5.4000000000000004e133

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/3.8%

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

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative3.8%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in re around 0 51.5%

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

        \[\leadsto \frac{\left(262144 + -0.5 \cdot \left({re}^{2} \cdot \left(262144 - {im}^{2}\right)\right)\right) - \color{blue}{im \cdot im}}{im + -512} \]
      2. associate--l+51.5%

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

        \[\leadsto \frac{262144 + \left(-0.5 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot \left(262144 - {im}^{2}\right)\right) - im \cdot im\right)}{im + -512} \]
      4. unpow251.5%

        \[\leadsto \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - \color{blue}{im \cdot im}\right)\right) - im \cdot im\right)}{im + -512} \]
    12. Simplified51.5%

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

    if -1.5e11 < im < 2.35e11

    1. Initial program 11.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around 0 57.0%

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

        \[\leadsto \color{blue}{-im} \]
    10. Simplified57.0%

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

    if 2.35e11 < im < 3.9000000000000002e93

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{4}} + 0.5 \cdot \left(im \cdot {re}^{2}\right)\right) - im \]
      5. metadata-eval13.9%

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

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

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

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

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

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

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

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

        \[\leadsto \left(re \cdot re\right) \cdot \left(im \cdot \left(-0.041666666666666664 \cdot {re}^{2}\right) + \color{blue}{im \cdot 0.5}\right) - im \]
      14. distribute-lft-out33.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7 \cdot 10^{+100}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -150000000000:\\ \;\;\;\;\frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{elif}\;im \leq 235000000000:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 3.9 \cdot 10^{+93}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 5.4 \cdot 10^{+133}:\\ \;\;\;\;\frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \end{array} \]

Alternative 11: 76.4% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ t_1 := \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{if}\;im \leq -7 \cdot 10^{+100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -150000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 750000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 10^{+97}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 5.4 \cdot 10^{+133}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666))
        (t_1
         (/
          (+
           262144.0
           (- (* -0.5 (* (* re re) (- 262144.0 (* im im)))) (* im im)))
          (+ im -512.0))))
   (if (<= im -7e+100)
     t_0
     (if (<= im -150000000000.0)
       t_1
       (if (<= im 750000000000.0)
         (- (* im (cos re)))
         (if (<= im 1e+97)
           (-
            (* (* re re) (* im (+ 0.5 (* (* re re) -0.041666666666666664))))
            im)
           (if (<= im 5.4e+133) t_1 t_0)))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0);
	double tmp;
	if (im <= -7e+100) {
		tmp = t_0;
	} else if (im <= -150000000000.0) {
		tmp = t_1;
	} else if (im <= 750000000000.0) {
		tmp = -(im * cos(re));
	} else if (im <= 1e+97) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 5.4e+133) {
		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 = (im ** 3.0d0) * (-0.16666666666666666d0)
    t_1 = (262144.0d0 + (((-0.5d0) * ((re * re) * (262144.0d0 - (im * im)))) - (im * im))) / (im + (-512.0d0))
    if (im <= (-7d+100)) then
        tmp = t_0
    else if (im <= (-150000000000.0d0)) then
        tmp = t_1
    else if (im <= 750000000000.0d0) then
        tmp = -(im * cos(re))
    else if (im <= 1d+97) then
        tmp = ((re * re) * (im * (0.5d0 + ((re * re) * (-0.041666666666666664d0))))) - im
    else if (im <= 5.4d+133) 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 = Math.pow(im, 3.0) * -0.16666666666666666;
	double t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0);
	double tmp;
	if (im <= -7e+100) {
		tmp = t_0;
	} else if (im <= -150000000000.0) {
		tmp = t_1;
	} else if (im <= 750000000000.0) {
		tmp = -(im * Math.cos(re));
	} else if (im <= 1e+97) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 5.4e+133) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0)
	tmp = 0
	if im <= -7e+100:
		tmp = t_0
	elif im <= -150000000000.0:
		tmp = t_1
	elif im <= 750000000000.0:
		tmp = -(im * math.cos(re))
	elif im <= 1e+97:
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im
	elif im <= 5.4e+133:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	t_1 = Float64(Float64(262144.0 + Float64(Float64(-0.5 * Float64(Float64(re * re) * Float64(262144.0 - Float64(im * im)))) - Float64(im * im))) / Float64(im + -512.0))
	tmp = 0.0
	if (im <= -7e+100)
		tmp = t_0;
	elseif (im <= -150000000000.0)
		tmp = t_1;
	elseif (im <= 750000000000.0)
		tmp = Float64(-Float64(im * cos(re)));
	elseif (im <= 1e+97)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * Float64(0.5 + Float64(Float64(re * re) * -0.041666666666666664)))) - im);
	elseif (im <= 5.4e+133)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	t_1 = (262144.0 + ((-0.5 * ((re * re) * (262144.0 - (im * im)))) - (im * im))) / (im + -512.0);
	tmp = 0.0;
	if (im <= -7e+100)
		tmp = t_0;
	elseif (im <= -150000000000.0)
		tmp = t_1;
	elseif (im <= 750000000000.0)
		tmp = -(im * cos(re));
	elseif (im <= 1e+97)
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	elseif (im <= 5.4e+133)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, Block[{t$95$1 = N[(N[(262144.0 + N[(N[(-0.5 * N[(N[(re * re), $MachinePrecision] * N[(262144.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7e+100], t$95$0, If[LessEqual[im, -150000000000.0], t$95$1, If[LessEqual[im, 750000000000.0], (-N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), If[LessEqual[im, 1e+97], N[(N[(N[(re * re), $MachinePrecision] * N[(im * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 5.4e+133], t$95$1, t$95$0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
t_1 := \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\
\mathbf{if}\;im \leq -7 \cdot 10^{+100}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 750000000000:\\
\;\;\;\;-im \cdot \cos re\\

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

\mathbf{elif}\;im \leq 5.4 \cdot 10^{+133}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -6.99999999999999953e100 or 5.4000000000000004e133 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around inf 84.0%

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

    if -6.99999999999999953e100 < im < -1.5e11 or 1.0000000000000001e97 < im < 5.4000000000000004e133

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/3.8%

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

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative3.8%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in re around 0 51.5%

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

        \[\leadsto \frac{\left(262144 + -0.5 \cdot \left({re}^{2} \cdot \left(262144 - {im}^{2}\right)\right)\right) - \color{blue}{im \cdot im}}{im + -512} \]
      2. associate--l+51.5%

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

        \[\leadsto \frac{262144 + \left(-0.5 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot \left(262144 - {im}^{2}\right)\right) - im \cdot im\right)}{im + -512} \]
      4. unpow251.5%

        \[\leadsto \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - \color{blue}{im \cdot im}\right)\right) - im \cdot im\right)}{im + -512} \]
    12. Simplified51.5%

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

    if -1.5e11 < im < 7.5e11

    1. Initial program 12.1%

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

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

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

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

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

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

    if 7.5e11 < im < 1.0000000000000001e97

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{2}\right) \cdot {re}^{2} + \color{blue}{\left(0.5 \cdot im\right) \cdot {re}^{2}}\right) - im \]
      9. distribute-rgt-out34.4%

        \[\leadsto \color{blue}{{re}^{2} \cdot \left(\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{2} + 0.5 \cdot im\right)} - im \]
      10. unpow234.4%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot \left(\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{2} + 0.5 \cdot im\right) - im \]
      11. *-commutative34.4%

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

        \[\leadsto \left(re \cdot re\right) \cdot \left(\color{blue}{im \cdot \left(-0.041666666666666664 \cdot {re}^{2}\right)} + 0.5 \cdot im\right) - im \]
      13. *-commutative34.4%

        \[\leadsto \left(re \cdot re\right) \cdot \left(im \cdot \left(-0.041666666666666664 \cdot {re}^{2}\right) + \color{blue}{im \cdot 0.5}\right) - im \]
      14. distribute-lft-out34.4%

        \[\leadsto \left(re \cdot re\right) \cdot \color{blue}{\left(im \cdot \left(-0.041666666666666664 \cdot {re}^{2} + 0.5\right)\right)} - im \]
      15. unpow234.4%

        \[\leadsto \left(re \cdot re\right) \cdot \left(im \cdot \left(-0.041666666666666664 \cdot \color{blue}{\left(re \cdot re\right)} + 0.5\right)\right) - im \]
    9. Simplified34.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7 \cdot 10^{+100}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -150000000000:\\ \;\;\;\;\frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{elif}\;im \leq 750000000000:\\ \;\;\;\;-im \cdot \cos re\\ \mathbf{elif}\;im \leq 10^{+97}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 5.4 \cdot 10^{+133}:\\ \;\;\;\;\frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \end{array} \]

Alternative 12: 51.2% accurate, 9.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 262144 - im \cdot im\\ t_1 := \frac{t_0}{im + -512}\\ t_2 := \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot t_0\right) - im \cdot im\right)}{im + -512}\\ \mathbf{if}\;im \leq -7.2 \cdot 10^{+141}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -150000000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq 235000000000:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 2.5 \cdot 10^{+96}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- 262144.0 (* im im)))
        (t_1 (/ t_0 (+ im -512.0)))
        (t_2
         (/
          (+ 262144.0 (- (* -0.5 (* (* re re) t_0)) (* im im)))
          (+ im -512.0))))
   (if (<= im -7.2e+141)
     t_1
     (if (<= im -150000000000.0)
       t_2
       (if (<= im 235000000000.0)
         (- im)
         (if (<= im 2.5e+96)
           (-
            (* (* re re) (* im (+ 0.5 (* (* re re) -0.041666666666666664))))
            im)
           (if (<= im 1.55e+135) t_2 t_1)))))))
double code(double re, double im) {
	double t_0 = 262144.0 - (im * im);
	double t_1 = t_0 / (im + -512.0);
	double t_2 = (262144.0 + ((-0.5 * ((re * re) * t_0)) - (im * im))) / (im + -512.0);
	double tmp;
	if (im <= -7.2e+141) {
		tmp = t_1;
	} else if (im <= -150000000000.0) {
		tmp = t_2;
	} else if (im <= 235000000000.0) {
		tmp = -im;
	} else if (im <= 2.5e+96) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 1.55e+135) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = 262144.0d0 - (im * im)
    t_1 = t_0 / (im + (-512.0d0))
    t_2 = (262144.0d0 + (((-0.5d0) * ((re * re) * t_0)) - (im * im))) / (im + (-512.0d0))
    if (im <= (-7.2d+141)) then
        tmp = t_1
    else if (im <= (-150000000000.0d0)) then
        tmp = t_2
    else if (im <= 235000000000.0d0) then
        tmp = -im
    else if (im <= 2.5d+96) then
        tmp = ((re * re) * (im * (0.5d0 + ((re * re) * (-0.041666666666666664d0))))) - im
    else if (im <= 1.55d+135) then
        tmp = t_2
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 262144.0 - (im * im);
	double t_1 = t_0 / (im + -512.0);
	double t_2 = (262144.0 + ((-0.5 * ((re * re) * t_0)) - (im * im))) / (im + -512.0);
	double tmp;
	if (im <= -7.2e+141) {
		tmp = t_1;
	} else if (im <= -150000000000.0) {
		tmp = t_2;
	} else if (im <= 235000000000.0) {
		tmp = -im;
	} else if (im <= 2.5e+96) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 1.55e+135) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = 262144.0 - (im * im)
	t_1 = t_0 / (im + -512.0)
	t_2 = (262144.0 + ((-0.5 * ((re * re) * t_0)) - (im * im))) / (im + -512.0)
	tmp = 0
	if im <= -7.2e+141:
		tmp = t_1
	elif im <= -150000000000.0:
		tmp = t_2
	elif im <= 235000000000.0:
		tmp = -im
	elif im <= 2.5e+96:
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im
	elif im <= 1.55e+135:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(262144.0 - Float64(im * im))
	t_1 = Float64(t_0 / Float64(im + -512.0))
	t_2 = Float64(Float64(262144.0 + Float64(Float64(-0.5 * Float64(Float64(re * re) * t_0)) - Float64(im * im))) / Float64(im + -512.0))
	tmp = 0.0
	if (im <= -7.2e+141)
		tmp = t_1;
	elseif (im <= -150000000000.0)
		tmp = t_2;
	elseif (im <= 235000000000.0)
		tmp = Float64(-im);
	elseif (im <= 2.5e+96)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * Float64(0.5 + Float64(Float64(re * re) * -0.041666666666666664)))) - im);
	elseif (im <= 1.55e+135)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 262144.0 - (im * im);
	t_1 = t_0 / (im + -512.0);
	t_2 = (262144.0 + ((-0.5 * ((re * re) * t_0)) - (im * im))) / (im + -512.0);
	tmp = 0.0;
	if (im <= -7.2e+141)
		tmp = t_1;
	elseif (im <= -150000000000.0)
		tmp = t_2;
	elseif (im <= 235000000000.0)
		tmp = -im;
	elseif (im <= 2.5e+96)
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	elseif (im <= 1.55e+135)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(262144.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(262144.0 + N[(N[(-0.5 * N[(N[(re * re), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.2e+141], t$95$1, If[LessEqual[im, -150000000000.0], t$95$2, If[LessEqual[im, 235000000000.0], (-im), If[LessEqual[im, 2.5e+96], N[(N[(N[(re * re), $MachinePrecision] * N[(im * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 1.55e+135], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 262144 - im \cdot im\\
t_1 := \frac{t_0}{im + -512}\\
t_2 := \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot t_0\right) - im \cdot im\right)}{im + -512}\\
\mathbf{if}\;im \leq -7.2 \cdot 10^{+141}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -150000000000:\\
\;\;\;\;t_2\\

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

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

\mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -7.2000000000000003e141 or 1.55000000000000011e135 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative7.2%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/87.9%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval87.9%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative87.9%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in re around 0 73.6%

      \[\leadsto \color{blue}{\frac{262144 - {im}^{2}}{im - 512}} \]
    11. Step-by-step derivation
      1. unpow273.6%

        \[\leadsto \frac{262144 - \color{blue}{im \cdot im}}{im - 512} \]
      2. sub-neg73.6%

        \[\leadsto \frac{262144 - im \cdot im}{\color{blue}{im + \left(-512\right)}} \]
      3. metadata-eval73.6%

        \[\leadsto \frac{262144 - im \cdot im}{im + \color{blue}{-512}} \]
    12. Simplified73.6%

      \[\leadsto \color{blue}{\frac{262144 - im \cdot im}{im + -512}} \]

    if -7.2000000000000003e141 < im < -1.5e11 or 2.5000000000000002e96 < im < 1.55000000000000011e135

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative3.9%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/3.9%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval3.9%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative3.9%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in re around 0 47.5%

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

        \[\leadsto \frac{\left(262144 + -0.5 \cdot \left({re}^{2} \cdot \left(262144 - {im}^{2}\right)\right)\right) - \color{blue}{im \cdot im}}{im + -512} \]
      2. associate--l+47.5%

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

        \[\leadsto \frac{262144 + \left(-0.5 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot \left(262144 - {im}^{2}\right)\right) - im \cdot im\right)}{im + -512} \]
      4. unpow247.5%

        \[\leadsto \frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - \color{blue}{im \cdot im}\right)\right) - im \cdot im\right)}{im + -512} \]
    12. Simplified47.5%

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

    if -1.5e11 < im < 2.35e11

    1. Initial program 11.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around 0 57.0%

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

        \[\leadsto \color{blue}{-im} \]
    10. Simplified57.0%

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

    if 2.35e11 < im < 2.5000000000000002e96

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{4}} + 0.5 \cdot \left(im \cdot {re}^{2}\right)\right) - im \]
      5. metadata-eval13.9%

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

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

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

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

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

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

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

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

        \[\leadsto \left(re \cdot re\right) \cdot \left(im \cdot \left(-0.041666666666666664 \cdot {re}^{2}\right) + \color{blue}{im \cdot 0.5}\right) - im \]
      14. distribute-lft-out33.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.2 \cdot 10^{+141}:\\ \;\;\;\;\frac{262144 - im \cdot im}{im + -512}\\ \mathbf{elif}\;im \leq -150000000000:\\ \;\;\;\;\frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{elif}\;im \leq 235000000000:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 2.5 \cdot 10^{+96}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\ \;\;\;\;\frac{262144 + \left(-0.5 \cdot \left(\left(re \cdot re\right) \cdot \left(262144 - im \cdot im\right)\right) - im \cdot im\right)}{im + -512}\\ \mathbf{else}:\\ \;\;\;\;\frac{262144 - im \cdot im}{im + -512}\\ \end{array} \]

Alternative 13: 50.8% accurate, 13.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{262144 - im \cdot im}{im + -512}\\ t_1 := \left(im \cdot 0.5\right) \cdot \left(re \cdot re + -2\right)\\ \mathbf{if}\;im \leq -7.2 \cdot 10^{+141}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -5.5 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 235000000000:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 2.9 \cdot 10^{+93}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (/ (- 262144.0 (* im im)) (+ im -512.0)))
        (t_1 (* (* im 0.5) (+ (* re re) -2.0))))
   (if (<= im -7.2e+141)
     t_0
     (if (<= im -5.5e-14)
       t_1
       (if (<= im 235000000000.0)
         (- im)
         (if (<= im 2.9e+93)
           (-
            (* (* re re) (* im (+ 0.5 (* (* re re) -0.041666666666666664))))
            im)
           (if (<= im 1.55e+135) t_1 t_0)))))))
double code(double re, double im) {
	double t_0 = (262144.0 - (im * im)) / (im + -512.0);
	double t_1 = (im * 0.5) * ((re * re) + -2.0);
	double tmp;
	if (im <= -7.2e+141) {
		tmp = t_0;
	} else if (im <= -5.5e-14) {
		tmp = t_1;
	} else if (im <= 235000000000.0) {
		tmp = -im;
	} else if (im <= 2.9e+93) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 1.55e+135) {
		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 = (262144.0d0 - (im * im)) / (im + (-512.0d0))
    t_1 = (im * 0.5d0) * ((re * re) + (-2.0d0))
    if (im <= (-7.2d+141)) then
        tmp = t_0
    else if (im <= (-5.5d-14)) then
        tmp = t_1
    else if (im <= 235000000000.0d0) then
        tmp = -im
    else if (im <= 2.9d+93) then
        tmp = ((re * re) * (im * (0.5d0 + ((re * re) * (-0.041666666666666664d0))))) - im
    else if (im <= 1.55d+135) 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 = (262144.0 - (im * im)) / (im + -512.0);
	double t_1 = (im * 0.5) * ((re * re) + -2.0);
	double tmp;
	if (im <= -7.2e+141) {
		tmp = t_0;
	} else if (im <= -5.5e-14) {
		tmp = t_1;
	} else if (im <= 235000000000.0) {
		tmp = -im;
	} else if (im <= 2.9e+93) {
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	} else if (im <= 1.55e+135) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (262144.0 - (im * im)) / (im + -512.0)
	t_1 = (im * 0.5) * ((re * re) + -2.0)
	tmp = 0
	if im <= -7.2e+141:
		tmp = t_0
	elif im <= -5.5e-14:
		tmp = t_1
	elif im <= 235000000000.0:
		tmp = -im
	elif im <= 2.9e+93:
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im
	elif im <= 1.55e+135:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64(262144.0 - Float64(im * im)) / Float64(im + -512.0))
	t_1 = Float64(Float64(im * 0.5) * Float64(Float64(re * re) + -2.0))
	tmp = 0.0
	if (im <= -7.2e+141)
		tmp = t_0;
	elseif (im <= -5.5e-14)
		tmp = t_1;
	elseif (im <= 235000000000.0)
		tmp = Float64(-im);
	elseif (im <= 2.9e+93)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * Float64(0.5 + Float64(Float64(re * re) * -0.041666666666666664)))) - im);
	elseif (im <= 1.55e+135)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (262144.0 - (im * im)) / (im + -512.0);
	t_1 = (im * 0.5) * ((re * re) + -2.0);
	tmp = 0.0;
	if (im <= -7.2e+141)
		tmp = t_0;
	elseif (im <= -5.5e-14)
		tmp = t_1;
	elseif (im <= 235000000000.0)
		tmp = -im;
	elseif (im <= 2.9e+93)
		tmp = ((re * re) * (im * (0.5 + ((re * re) * -0.041666666666666664)))) - im;
	elseif (im <= 1.55e+135)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(262144.0 - N[(im * im), $MachinePrecision]), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(im * 0.5), $MachinePrecision] * N[(N[(re * re), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.2e+141], t$95$0, If[LessEqual[im, -5.5e-14], t$95$1, If[LessEqual[im, 235000000000.0], (-im), If[LessEqual[im, 2.9e+93], N[(N[(N[(re * re), $MachinePrecision] * N[(im * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 1.55e+135], t$95$1, t$95$0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{262144 - im \cdot im}{im + -512}\\
t_1 := \left(im \cdot 0.5\right) \cdot \left(re \cdot re + -2\right)\\
\mathbf{if}\;im \leq -7.2 \cdot 10^{+141}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -5.5 \cdot 10^{-14}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -7.2000000000000003e141 or 1.55000000000000011e135 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative7.2%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/87.9%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval87.9%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative87.9%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in re around 0 73.6%

      \[\leadsto \color{blue}{\frac{262144 - {im}^{2}}{im - 512}} \]
    11. Step-by-step derivation
      1. unpow273.6%

        \[\leadsto \frac{262144 - \color{blue}{im \cdot im}}{im - 512} \]
      2. sub-neg73.6%

        \[\leadsto \frac{262144 - im \cdot im}{\color{blue}{im + \left(-512\right)}} \]
      3. metadata-eval73.6%

        \[\leadsto \frac{262144 - im \cdot im}{im + \color{blue}{-512}} \]
    12. Simplified73.6%

      \[\leadsto \color{blue}{\frac{262144 - im \cdot im}{im + -512}} \]

    if -7.2000000000000003e141 < im < -5.49999999999999991e-14 or 2.8999999999999998e93 < im < 1.55000000000000011e135

    1. Initial program 95.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot im\right) \cdot {re}^{2}} + \left(-im\right) \]
      4. neg-mul-138.7%

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

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

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

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

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

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

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

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

    if -5.49999999999999991e-14 < im < 2.35e11

    1. Initial program 7.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around 0 58.5%

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

        \[\leadsto \color{blue}{-im} \]
    10. Simplified58.5%

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

    if 2.35e11 < im < 2.8999999999999998e93

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(-0.041666666666666664 \cdot im\right) \cdot {re}^{4}} + 0.5 \cdot \left(im \cdot {re}^{2}\right)\right) - im \]
      5. metadata-eval13.9%

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

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

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

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

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

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

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

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

        \[\leadsto \left(re \cdot re\right) \cdot \left(im \cdot \left(-0.041666666666666664 \cdot {re}^{2}\right) + \color{blue}{im \cdot 0.5}\right) - im \]
      14. distribute-lft-out33.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.2 \cdot 10^{+141}:\\ \;\;\;\;\frac{262144 - im \cdot im}{im + -512}\\ \mathbf{elif}\;im \leq -5.5 \cdot 10^{-14}:\\ \;\;\;\;\left(im \cdot 0.5\right) \cdot \left(re \cdot re + -2\right)\\ \mathbf{elif}\;im \leq 235000000000:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 2.9 \cdot 10^{+93}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.041666666666666664\right)\right) - im\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\ \;\;\;\;\left(im \cdot 0.5\right) \cdot \left(re \cdot re + -2\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{262144 - im \cdot im}{im + -512}\\ \end{array} \]

Alternative 14: 50.4% accurate, 16.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{262144 - im \cdot im}{im + -512}\\ \mathbf{if}\;im \leq -7.2 \cdot 10^{+141}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -9 \cdot 10^{-14}:\\ \;\;\;\;\left(im \cdot 0.5\right) \cdot \left(re \cdot re + -2\right)\\ \mathbf{elif}\;im \leq 0.175:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\ \;\;\;\;\left(im + 512\right) \cdot \left(-1 + re \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (/ (- 262144.0 (* im im)) (+ im -512.0))))
   (if (<= im -7.2e+141)
     t_0
     (if (<= im -9e-14)
       (* (* im 0.5) (+ (* re re) -2.0))
       (if (<= im 0.175)
         (- im)
         (if (<= im 1.55e+135)
           (* (+ im 512.0) (+ -1.0 (* re (* 0.5 re))))
           t_0))))))
double code(double re, double im) {
	double t_0 = (262144.0 - (im * im)) / (im + -512.0);
	double tmp;
	if (im <= -7.2e+141) {
		tmp = t_0;
	} else if (im <= -9e-14) {
		tmp = (im * 0.5) * ((re * re) + -2.0);
	} else if (im <= 0.175) {
		tmp = -im;
	} else if (im <= 1.55e+135) {
		tmp = (im + 512.0) * (-1.0 + (re * (0.5 * re)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (262144.0d0 - (im * im)) / (im + (-512.0d0))
    if (im <= (-7.2d+141)) then
        tmp = t_0
    else if (im <= (-9d-14)) then
        tmp = (im * 0.5d0) * ((re * re) + (-2.0d0))
    else if (im <= 0.175d0) then
        tmp = -im
    else if (im <= 1.55d+135) then
        tmp = (im + 512.0d0) * ((-1.0d0) + (re * (0.5d0 * re)))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (262144.0 - (im * im)) / (im + -512.0);
	double tmp;
	if (im <= -7.2e+141) {
		tmp = t_0;
	} else if (im <= -9e-14) {
		tmp = (im * 0.5) * ((re * re) + -2.0);
	} else if (im <= 0.175) {
		tmp = -im;
	} else if (im <= 1.55e+135) {
		tmp = (im + 512.0) * (-1.0 + (re * (0.5 * re)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (262144.0 - (im * im)) / (im + -512.0)
	tmp = 0
	if im <= -7.2e+141:
		tmp = t_0
	elif im <= -9e-14:
		tmp = (im * 0.5) * ((re * re) + -2.0)
	elif im <= 0.175:
		tmp = -im
	elif im <= 1.55e+135:
		tmp = (im + 512.0) * (-1.0 + (re * (0.5 * re)))
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64(262144.0 - Float64(im * im)) / Float64(im + -512.0))
	tmp = 0.0
	if (im <= -7.2e+141)
		tmp = t_0;
	elseif (im <= -9e-14)
		tmp = Float64(Float64(im * 0.5) * Float64(Float64(re * re) + -2.0));
	elseif (im <= 0.175)
		tmp = Float64(-im);
	elseif (im <= 1.55e+135)
		tmp = Float64(Float64(im + 512.0) * Float64(-1.0 + Float64(re * Float64(0.5 * re))));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (262144.0 - (im * im)) / (im + -512.0);
	tmp = 0.0;
	if (im <= -7.2e+141)
		tmp = t_0;
	elseif (im <= -9e-14)
		tmp = (im * 0.5) * ((re * re) + -2.0);
	elseif (im <= 0.175)
		tmp = -im;
	elseif (im <= 1.55e+135)
		tmp = (im + 512.0) * (-1.0 + (re * (0.5 * re)));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(262144.0 - N[(im * im), $MachinePrecision]), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.2e+141], t$95$0, If[LessEqual[im, -9e-14], N[(N[(im * 0.5), $MachinePrecision] * N[(N[(re * re), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 0.175], (-im), If[LessEqual[im, 1.55e+135], N[(N[(im + 512.0), $MachinePrecision] * N[(-1.0 + N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{262144 - im \cdot im}{im + -512}\\
\mathbf{if}\;im \leq -7.2 \cdot 10^{+141}:\\
\;\;\;\;t_0\\

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

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

\mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\
\;\;\;\;\left(im + 512\right) \cdot \left(-1 + re \cdot \left(0.5 \cdot re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -7.2000000000000003e141 or 1.55000000000000011e135 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative7.2%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/87.9%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval87.9%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative87.9%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in re around 0 73.6%

      \[\leadsto \color{blue}{\frac{262144 - {im}^{2}}{im - 512}} \]
    11. Step-by-step derivation
      1. unpow273.6%

        \[\leadsto \frac{262144 - \color{blue}{im \cdot im}}{im - 512} \]
      2. sub-neg73.6%

        \[\leadsto \frac{262144 - im \cdot im}{\color{blue}{im + \left(-512\right)}} \]
      3. metadata-eval73.6%

        \[\leadsto \frac{262144 - im \cdot im}{im + \color{blue}{-512}} \]
    12. Simplified73.6%

      \[\leadsto \color{blue}{\frac{262144 - im \cdot im}{im + -512}} \]

    if -7.2000000000000003e141 < im < -8.9999999999999995e-14

    1. Initial program 94.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot im\right) \cdot {re}^{2}} + \left(-im\right) \]
      4. neg-mul-133.3%

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

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

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

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

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

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

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

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

    if -8.9999999999999995e-14 < im < 0.17499999999999999

    1. Initial program 6.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around 0 59.5%

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

        \[\leadsto \color{blue}{-im} \]
    10. Simplified59.5%

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

    if 0.17499999999999999 < im < 1.55000000000000011e135

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \left(512 + im\right) + 0.5 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot \left(512 + im\right)\right) \]
      2. associate-*r*20.0%

        \[\leadsto -1 \cdot \left(512 + im\right) + \color{blue}{\left(0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(512 + im\right)} \]
      3. distribute-rgt-out20.0%

        \[\leadsto \color{blue}{\left(512 + im\right) \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right)} \]
      4. +-commutative20.0%

        \[\leadsto \color{blue}{\left(im + 512\right)} \cdot \left(-1 + 0.5 \cdot \left(re \cdot re\right)\right) \]
      5. metadata-eval20.0%

        \[\leadsto \left(im + 512\right) \cdot \left(-1 + \color{blue}{\left(--0.5\right)} \cdot \left(re \cdot re\right)\right) \]
      6. distribute-lft-neg-in20.0%

        \[\leadsto \left(im + 512\right) \cdot \left(-1 + \color{blue}{\left(--0.5 \cdot \left(re \cdot re\right)\right)}\right) \]
      7. associate-*r*20.0%

        \[\leadsto \left(im + 512\right) \cdot \left(-1 + \left(-\color{blue}{\left(-0.5 \cdot re\right) \cdot re}\right)\right) \]
      8. *-commutative20.0%

        \[\leadsto \left(im + 512\right) \cdot \left(-1 + \left(-\color{blue}{re \cdot \left(-0.5 \cdot re\right)}\right)\right) \]
      9. distribute-rgt-neg-in20.0%

        \[\leadsto \left(im + 512\right) \cdot \left(-1 + \color{blue}{re \cdot \left(--0.5 \cdot re\right)}\right) \]
      10. distribute-lft-neg-in20.0%

        \[\leadsto \left(im + 512\right) \cdot \left(-1 + re \cdot \color{blue}{\left(\left(--0.5\right) \cdot re\right)}\right) \]
      11. metadata-eval20.0%

        \[\leadsto \left(im + 512\right) \cdot \left(-1 + re \cdot \left(\color{blue}{0.5} \cdot re\right)\right) \]
    10. Simplified20.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.2 \cdot 10^{+141}:\\ \;\;\;\;\frac{262144 - im \cdot im}{im + -512}\\ \mathbf{elif}\;im \leq -9 \cdot 10^{-14}:\\ \;\;\;\;\left(im \cdot 0.5\right) \cdot \left(re \cdot re + -2\right)\\ \mathbf{elif}\;im \leq 0.175:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\ \;\;\;\;\left(im + 512\right) \cdot \left(-1 + re \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{262144 - im \cdot im}{im + -512}\\ \end{array} \]

Alternative 15: 50.4% accurate, 17.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{262144 - im \cdot im}{im + -512}\\ t_1 := \left(im \cdot 0.5\right) \cdot \left(re \cdot re + -2\right)\\ \mathbf{if}\;im \leq -7.2 \cdot 10^{+141}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -1.02 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 0.175:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (/ (- 262144.0 (* im im)) (+ im -512.0)))
        (t_1 (* (* im 0.5) (+ (* re re) -2.0))))
   (if (<= im -7.2e+141)
     t_0
     (if (<= im -1.02e-13)
       t_1
       (if (<= im 0.175) (- im) (if (<= im 1.55e+135) t_1 t_0))))))
double code(double re, double im) {
	double t_0 = (262144.0 - (im * im)) / (im + -512.0);
	double t_1 = (im * 0.5) * ((re * re) + -2.0);
	double tmp;
	if (im <= -7.2e+141) {
		tmp = t_0;
	} else if (im <= -1.02e-13) {
		tmp = t_1;
	} else if (im <= 0.175) {
		tmp = -im;
	} else if (im <= 1.55e+135) {
		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 = (262144.0d0 - (im * im)) / (im + (-512.0d0))
    t_1 = (im * 0.5d0) * ((re * re) + (-2.0d0))
    if (im <= (-7.2d+141)) then
        tmp = t_0
    else if (im <= (-1.02d-13)) then
        tmp = t_1
    else if (im <= 0.175d0) then
        tmp = -im
    else if (im <= 1.55d+135) 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 = (262144.0 - (im * im)) / (im + -512.0);
	double t_1 = (im * 0.5) * ((re * re) + -2.0);
	double tmp;
	if (im <= -7.2e+141) {
		tmp = t_0;
	} else if (im <= -1.02e-13) {
		tmp = t_1;
	} else if (im <= 0.175) {
		tmp = -im;
	} else if (im <= 1.55e+135) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (262144.0 - (im * im)) / (im + -512.0)
	t_1 = (im * 0.5) * ((re * re) + -2.0)
	tmp = 0
	if im <= -7.2e+141:
		tmp = t_0
	elif im <= -1.02e-13:
		tmp = t_1
	elif im <= 0.175:
		tmp = -im
	elif im <= 1.55e+135:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64(262144.0 - Float64(im * im)) / Float64(im + -512.0))
	t_1 = Float64(Float64(im * 0.5) * Float64(Float64(re * re) + -2.0))
	tmp = 0.0
	if (im <= -7.2e+141)
		tmp = t_0;
	elseif (im <= -1.02e-13)
		tmp = t_1;
	elseif (im <= 0.175)
		tmp = Float64(-im);
	elseif (im <= 1.55e+135)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (262144.0 - (im * im)) / (im + -512.0);
	t_1 = (im * 0.5) * ((re * re) + -2.0);
	tmp = 0.0;
	if (im <= -7.2e+141)
		tmp = t_0;
	elseif (im <= -1.02e-13)
		tmp = t_1;
	elseif (im <= 0.175)
		tmp = -im;
	elseif (im <= 1.55e+135)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(262144.0 - N[(im * im), $MachinePrecision]), $MachinePrecision] / N[(im + -512.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(im * 0.5), $MachinePrecision] * N[(N[(re * re), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.2e+141], t$95$0, If[LessEqual[im, -1.02e-13], t$95$1, If[LessEqual[im, 0.175], (-im), If[LessEqual[im, 1.55e+135], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{262144 - im \cdot im}{im + -512}\\
t_1 := \left(im \cdot 0.5\right) \cdot \left(re \cdot re + -2\right)\\
\mathbf{if}\;im \leq -7.2 \cdot 10^{+141}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -1.02 \cdot 10^{-13}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -7.2000000000000003e141 or 1.55000000000000011e135 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-512} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative7.2%

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

        \[\leadsto \color{blue}{\frac{-512 \cdot -512 - im \cdot im}{-512 + im}} \cdot \cos re \]
      3. associate-*l/87.9%

        \[\leadsto \color{blue}{\frac{\left(-512 \cdot -512 - im \cdot im\right) \cdot \cos re}{-512 + im}} \]
      4. metadata-eval87.9%

        \[\leadsto \frac{\left(\color{blue}{262144} - im \cdot im\right) \cdot \cos re}{-512 + im} \]
      5. +-commutative87.9%

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

      \[\leadsto \color{blue}{\frac{\left(262144 - im \cdot im\right) \cdot \cos re}{im + -512}} \]
    10. Taylor expanded in re around 0 73.6%

      \[\leadsto \color{blue}{\frac{262144 - {im}^{2}}{im - 512}} \]
    11. Step-by-step derivation
      1. unpow273.6%

        \[\leadsto \frac{262144 - \color{blue}{im \cdot im}}{im - 512} \]
      2. sub-neg73.6%

        \[\leadsto \frac{262144 - im \cdot im}{\color{blue}{im + \left(-512\right)}} \]
      3. metadata-eval73.6%

        \[\leadsto \frac{262144 - im \cdot im}{im + \color{blue}{-512}} \]
    12. Simplified73.6%

      \[\leadsto \color{blue}{\frac{262144 - im \cdot im}{im + -512}} \]

    if -7.2000000000000003e141 < im < -1.0199999999999999e-13 or 0.17499999999999999 < im < 1.55000000000000011e135

    1. Initial program 97.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot im\right) \cdot {re}^{2}} + \left(-im\right) \]
      4. neg-mul-125.9%

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

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

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

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

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

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

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

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

    if -1.0199999999999999e-13 < im < 0.17499999999999999

    1. Initial program 6.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around 0 59.5%

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

        \[\leadsto \color{blue}{-im} \]
    10. Simplified59.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.2 \cdot 10^{+141}:\\ \;\;\;\;\frac{262144 - im \cdot im}{im + -512}\\ \mathbf{elif}\;im \leq -1.02 \cdot 10^{-13}:\\ \;\;\;\;\left(im \cdot 0.5\right) \cdot \left(re \cdot re + -2\right)\\ \mathbf{elif}\;im \leq 0.175:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 1.55 \cdot 10^{+135}:\\ \;\;\;\;\left(im \cdot 0.5\right) \cdot \left(re \cdot re + -2\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{262144 - im \cdot im}{im + -512}\\ \end{array} \]

Alternative 16: 36.1% accurate, 23.5× speedup?

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

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

\mathbf{elif}\;re \leq 1.75 \cdot 10^{+233}:\\
\;\;\;\;\left(re \cdot re\right) \cdot -6.75\\

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


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

    1. Initial program 55.9%

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

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

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified50.7%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 39.1%

      \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left(im \cdot {re}^{2}\right)} \]
    8. Step-by-step derivation
      1. neg-mul-139.1%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left(im \cdot {re}^{2}\right) \]
      2. +-commutative39.1%

        \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot {re}^{2}\right) + \left(-im\right)} \]
      3. associate-*r*39.1%

        \[\leadsto \color{blue}{\left(0.5 \cdot im\right) \cdot {re}^{2}} + \left(-im\right) \]
      4. neg-mul-139.1%

        \[\leadsto \left(0.5 \cdot im\right) \cdot {re}^{2} + \color{blue}{-1 \cdot im} \]
      5. metadata-eval39.1%

        \[\leadsto \left(0.5 \cdot im\right) \cdot {re}^{2} + \color{blue}{\left(-2 \cdot 0.5\right)} \cdot im \]
      6. associate-*r*39.1%

        \[\leadsto \left(0.5 \cdot im\right) \cdot {re}^{2} + \color{blue}{-2 \cdot \left(0.5 \cdot im\right)} \]
      7. *-commutative39.1%

        \[\leadsto \left(0.5 \cdot im\right) \cdot {re}^{2} + \color{blue}{\left(0.5 \cdot im\right) \cdot -2} \]
      8. distribute-lft-out39.1%

        \[\leadsto \color{blue}{\left(0.5 \cdot im\right) \cdot \left({re}^{2} + -2\right)} \]
      9. *-commutative39.1%

        \[\leadsto \color{blue}{\left(im \cdot 0.5\right)} \cdot \left({re}^{2} + -2\right) \]
      10. unpow239.1%

        \[\leadsto \left(im \cdot 0.5\right) \cdot \left(\color{blue}{re \cdot re} + -2\right) \]
    9. Simplified39.1%

      \[\leadsto \color{blue}{\left(im \cdot 0.5\right) \cdot \left(re \cdot re + -2\right)} \]

    if 6.5e157 < re < 1.7499999999999999e233

    1. Initial program 39.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub039.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified39.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.0%

      \[\leadsto \color{blue}{-0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

        \[\leadsto \color{blue}{0.5 \cdot \left(e^{-im} - e^{im}\right) + -0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      2. associate-*r*0.0%

        \[\leadsto 0.5 \cdot \left(e^{-im} - e^{im}\right) + \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      3. distribute-rgt-out21.4%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      4. unpow221.4%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    6. Simplified21.4%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    7. Applied egg-rr29.8%

      \[\leadsto \color{blue}{27} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \]
    8. Taylor expanded in re around inf 29.8%

      \[\leadsto \color{blue}{-6.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. unpow229.8%

        \[\leadsto -6.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
      2. *-commutative29.8%

        \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot -6.75} \]
      3. associate-*l*29.8%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -6.75\right)} \]
    10. Simplified29.8%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot -6.75\right)} \]
    11. Taylor expanded in re around 0 29.8%

      \[\leadsto \color{blue}{-6.75 \cdot {re}^{2}} \]
    12. Step-by-step derivation
      1. unpow229.8%

        \[\leadsto -6.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
    13. Simplified29.8%

      \[\leadsto \color{blue}{-6.75 \cdot \left(re \cdot re\right)} \]

    if 1.7499999999999999e233 < re

    1. Initial program 56.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub056.5%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified56.5%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.2%

      \[\leadsto \color{blue}{-0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.2%

        \[\leadsto \color{blue}{0.5 \cdot \left(e^{-im} - e^{im}\right) + -0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      2. associate-*r*0.2%

        \[\leadsto 0.5 \cdot \left(e^{-im} - e^{im}\right) + \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      3. distribute-rgt-out26.9%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      4. unpow226.9%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    6. Simplified26.9%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    7. Applied egg-rr27.6%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification37.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 6.5 \cdot 10^{+157}:\\ \;\;\;\;\left(im \cdot 0.5\right) \cdot \left(re \cdot re + -2\right)\\ \mathbf{elif}\;re \leq 1.75 \cdot 10^{+233}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \cdot -3\\ \end{array} \]

Alternative 17: 36.1% accurate, 23.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 3.6 \cdot 10^{+171}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{elif}\;re \leq 2.3 \cdot 10^{+231}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \cdot -3\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 3.6e+171)
   (- (* 0.5 (* re (* im re))) im)
   (if (<= re 2.3e+231)
     (* (* re re) -6.75)
     (* (+ 0.5 (* -0.25 (* re re))) -3.0))))
double code(double re, double im) {
	double tmp;
	if (re <= 3.6e+171) {
		tmp = (0.5 * (re * (im * re))) - im;
	} else if (re <= 2.3e+231) {
		tmp = (re * re) * -6.75;
	} else {
		tmp = (0.5 + (-0.25 * (re * re))) * -3.0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 3.6d+171) then
        tmp = (0.5d0 * (re * (im * re))) - im
    else if (re <= 2.3d+231) then
        tmp = (re * re) * (-6.75d0)
    else
        tmp = (0.5d0 + ((-0.25d0) * (re * re))) * (-3.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 3.6e+171) {
		tmp = (0.5 * (re * (im * re))) - im;
	} else if (re <= 2.3e+231) {
		tmp = (re * re) * -6.75;
	} else {
		tmp = (0.5 + (-0.25 * (re * re))) * -3.0;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 3.6e+171:
		tmp = (0.5 * (re * (im * re))) - im
	elif re <= 2.3e+231:
		tmp = (re * re) * -6.75
	else:
		tmp = (0.5 + (-0.25 * (re * re))) * -3.0
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 3.6e+171)
		tmp = Float64(Float64(0.5 * Float64(re * Float64(im * re))) - im);
	elseif (re <= 2.3e+231)
		tmp = Float64(Float64(re * re) * -6.75);
	else
		tmp = Float64(Float64(0.5 + Float64(-0.25 * Float64(re * re))) * -3.0);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 3.6e+171)
		tmp = (0.5 * (re * (im * re))) - im;
	elseif (re <= 2.3e+231)
		tmp = (re * re) * -6.75;
	else
		tmp = (0.5 + (-0.25 * (re * re))) * -3.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 3.6e+171], N[(N[(0.5 * N[(re * N[(im * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[re, 2.3e+231], N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision], N[(N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -3.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.6 \cdot 10^{+171}:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\

\mathbf{elif}\;re \leq 2.3 \cdot 10^{+231}:\\
\;\;\;\;\left(re \cdot re\right) \cdot -6.75\\

\mathbf{else}:\\
\;\;\;\;\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \cdot -3\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if re < 3.60000000000000018e171

    1. Initial program 56.1%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub056.1%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified56.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 50.6%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. associate-*r*50.6%

        \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} \]
      2. neg-mul-150.6%

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \cos re \]
    6. Simplified50.6%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \cos re} \]
    7. Taylor expanded in re around 0 39.4%

      \[\leadsto \color{blue}{-1 \cdot im + 0.5 \cdot \left(im \cdot {re}^{2}\right)} \]
    8. Step-by-step derivation
      1. neg-mul-139.4%

        \[\leadsto \color{blue}{\left(-im\right)} + 0.5 \cdot \left(im \cdot {re}^{2}\right) \]
      2. +-commutative39.4%

        \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot {re}^{2}\right) + \left(-im\right)} \]
      3. unsub-neg39.4%

        \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot {re}^{2}\right) - im} \]
      4. *-commutative39.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left({re}^{2} \cdot im\right)} - im \]
      5. unpow239.4%

        \[\leadsto 0.5 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot im\right) - im \]
      6. associate-*l*39.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left(re \cdot \left(re \cdot im\right)\right)} - im \]
    9. Simplified39.4%

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(re \cdot im\right)\right) - im} \]

    if 3.60000000000000018e171 < re < 2.29999999999999999e231

    1. Initial program 34.3%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub034.3%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified34.3%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.0%

      \[\leadsto \color{blue}{-0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.0%

        \[\leadsto \color{blue}{0.5 \cdot \left(e^{-im} - e^{im}\right) + -0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      2. associate-*r*0.0%

        \[\leadsto 0.5 \cdot \left(e^{-im} - e^{im}\right) + \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      3. distribute-rgt-out15.4%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      4. unpow215.4%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    6. Simplified15.4%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    7. Applied egg-rr24.4%

      \[\leadsto \color{blue}{27} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \]
    8. Taylor expanded in re around inf 24.4%

      \[\leadsto \color{blue}{-6.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. unpow224.4%

        \[\leadsto -6.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
      2. *-commutative24.4%

        \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot -6.75} \]
      3. associate-*l*24.4%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -6.75\right)} \]
    10. Simplified24.4%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot -6.75\right)} \]
    11. Taylor expanded in re around 0 24.4%

      \[\leadsto \color{blue}{-6.75 \cdot {re}^{2}} \]
    12. Step-by-step derivation
      1. unpow224.4%

        \[\leadsto -6.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
    13. Simplified24.4%

      \[\leadsto \color{blue}{-6.75 \cdot \left(re \cdot re\right)} \]

    if 2.29999999999999999e231 < re

    1. Initial program 56.5%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub056.5%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified56.5%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 0.2%

      \[\leadsto \color{blue}{-0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.2%

        \[\leadsto \color{blue}{0.5 \cdot \left(e^{-im} - e^{im}\right) + -0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      2. associate-*r*0.2%

        \[\leadsto 0.5 \cdot \left(e^{-im} - e^{im}\right) + \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      3. distribute-rgt-out26.9%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      4. unpow226.9%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    6. Simplified26.9%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    7. Applied egg-rr27.6%

      \[\leadsto \color{blue}{-3} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification38.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 3.6 \cdot 10^{+171}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{elif}\;re \leq 2.3 \cdot 10^{+231}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \cdot -3\\ \end{array} \]

Alternative 18: 31.5% accurate, 43.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 1.05 \cdot 10^{+162}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 1.05e+162) (- im) (* (* re re) -6.75)))
double code(double re, double im) {
	double tmp;
	if (re <= 1.05e+162) {
		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 <= 1.05d+162) 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 <= 1.05e+162) {
		tmp = -im;
	} else {
		tmp = (re * re) * -6.75;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 1.05e+162:
		tmp = -im
	else:
		tmp = (re * re) * -6.75
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 1.05e+162)
		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 <= 1.05e+162)
		tmp = -im;
	else
		tmp = (re * re) * -6.75;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 1.05e+162], (-im), N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.05 \cdot 10^{+162}:\\
\;\;\;\;-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 < 1.05e162

    1. Initial program 55.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub055.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified55.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 79.2%

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
    5. Step-by-step derivation
      1. +-commutative79.2%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + -1 \cdot \left(im \cdot \cos re\right)} \]
      2. mul-1-neg79.2%

        \[\leadsto -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + \color{blue}{\left(-im \cdot \cos re\right)} \]
      3. unsub-neg79.2%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) - im \cdot \cos re} \]
      4. associate-*r*79.2%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} - im \cdot \cos re \]
      5. distribute-rgt-out--79.2%

        \[\leadsto \color{blue}{\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      6. *-commutative79.2%

        \[\leadsto \cos re \cdot \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} - im\right) \]
    6. Simplified79.2%

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Taylor expanded in re around 0 56.9%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Taylor expanded in im around 0 34.1%

      \[\leadsto \color{blue}{-1 \cdot im} \]
    9. Step-by-step derivation
      1. neg-mul-134.1%

        \[\leadsto \color{blue}{-im} \]
    10. Simplified34.1%

      \[\leadsto \color{blue}{-im} \]

    if 1.05e162 < re

    1. Initial program 48.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub048.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified48.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.1%

      \[\leadsto \color{blue}{-0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.1%

        \[\leadsto \color{blue}{0.5 \cdot \left(e^{-im} - e^{im}\right) + -0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      2. associate-*r*0.1%

        \[\leadsto 0.5 \cdot \left(e^{-im} - e^{im}\right) + \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      3. distribute-rgt-out24.2%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      4. unpow224.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    6. Simplified24.2%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    7. Applied egg-rr25.1%

      \[\leadsto \color{blue}{27} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \]
    8. Taylor expanded in re around inf 25.1%

      \[\leadsto \color{blue}{-6.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. unpow225.1%

        \[\leadsto -6.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
      2. *-commutative25.1%

        \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot -6.75} \]
      3. associate-*l*25.1%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -6.75\right)} \]
    10. Simplified25.1%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot -6.75\right)} \]
    11. Taylor expanded in re around 0 25.1%

      \[\leadsto \color{blue}{-6.75 \cdot {re}^{2}} \]
    12. Step-by-step derivation
      1. unpow225.1%

        \[\leadsto -6.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
    13. Simplified25.1%

      \[\leadsto \color{blue}{-6.75 \cdot \left(re \cdot re\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification33.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.05 \cdot 10^{+162}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \]

Alternative 19: 31.5% accurate, 43.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 8.6 \cdot 10^{+161}:\\ \;\;\;\;0.5 \cdot \left(im \cdot -2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 8.6e+161) (* 0.5 (* im -2.0)) (* (* re re) -6.75)))
double code(double re, double im) {
	double tmp;
	if (re <= 8.6e+161) {
		tmp = 0.5 * (im * -2.0);
	} else {
		tmp = (re * re) * -6.75;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 8.6d+161) then
        tmp = 0.5d0 * (im * (-2.0d0))
    else
        tmp = (re * re) * (-6.75d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 8.6e+161) {
		tmp = 0.5 * (im * -2.0);
	} else {
		tmp = (re * re) * -6.75;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 8.6e+161:
		tmp = 0.5 * (im * -2.0)
	else:
		tmp = (re * re) * -6.75
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 8.6e+161)
		tmp = Float64(0.5 * Float64(im * -2.0));
	else
		tmp = Float64(Float64(re * re) * -6.75);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 8.6e+161)
		tmp = 0.5 * (im * -2.0);
	else
		tmp = (re * re) * -6.75;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 8.6e+161], N[(0.5 * N[(im * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * -6.75), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 8.6 \cdot 10^{+161}:\\
\;\;\;\;0.5 \cdot \left(im \cdot -2\right)\\

\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot -6.75\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 8.6e161

    1. Initial program 55.9%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub055.9%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified55.9%

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 44.1%

      \[\leadsto \color{blue}{0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Taylor expanded in im around 0 34.4%

      \[\leadsto 0.5 \cdot \color{blue}{\left(-2 \cdot im\right)} \]

    if 8.6e161 < re

    1. Initial program 48.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. neg-sub048.0%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
    3. Simplified48.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.1%

      \[\leadsto \color{blue}{-0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
    5. Step-by-step derivation
      1. +-commutative0.1%

        \[\leadsto \color{blue}{0.5 \cdot \left(e^{-im} - e^{im}\right) + -0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} \]
      2. associate-*r*0.1%

        \[\leadsto 0.5 \cdot \left(e^{-im} - e^{im}\right) + \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      3. distribute-rgt-out24.2%

        \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
      4. unpow224.2%

        \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    6. Simplified24.2%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
    7. Applied egg-rr25.1%

      \[\leadsto \color{blue}{27} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \]
    8. Taylor expanded in re around inf 25.1%

      \[\leadsto \color{blue}{-6.75 \cdot {re}^{2}} \]
    9. Step-by-step derivation
      1. unpow225.1%

        \[\leadsto -6.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
      2. *-commutative25.1%

        \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot -6.75} \]
      3. associate-*l*25.1%

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -6.75\right)} \]
    10. Simplified25.1%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot -6.75\right)} \]
    11. Taylor expanded in re around 0 25.1%

      \[\leadsto \color{blue}{-6.75 \cdot {re}^{2}} \]
    12. Step-by-step derivation
      1. unpow225.1%

        \[\leadsto -6.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
    13. Simplified25.1%

      \[\leadsto \color{blue}{-6.75 \cdot \left(re \cdot re\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification33.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 8.6 \cdot 10^{+161}:\\ \;\;\;\;0.5 \cdot \left(im \cdot -2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -6.75\\ \end{array} \]

Alternative 20: 29.8% accurate, 154.5× speedup?

\[\begin{array}{l} \\ -im \end{array} \]
(FPCore (re im) :precision binary64 (- im))
double code(double re, double im) {
	return -im;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = -im
end function
public static double code(double re, double im) {
	return -im;
}
def code(re, im):
	return -im
function code(re, im)
	return Float64(-im)
end
function tmp = code(re, im)
	tmp = -im;
end
code[re_, im_] := (-im)
\begin{array}{l}

\\
-im
\end{array}
Derivation
  1. Initial program 55.0%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. neg-sub055.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
  3. Simplified55.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 79.5%

    \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \cos re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right)} \]
  5. Step-by-step derivation
    1. +-commutative79.5%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + -1 \cdot \left(im \cdot \cos re\right)} \]
    2. mul-1-neg79.5%

      \[\leadsto -0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + \color{blue}{\left(-im \cdot \cos re\right)} \]
    3. unsub-neg79.5%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) - im \cdot \cos re} \]
    4. associate-*r*79.5%

      \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \cos re} - im \cdot \cos re \]
    5. distribute-rgt-out--79.5%

      \[\leadsto \color{blue}{\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
    6. *-commutative79.5%

      \[\leadsto \cos re \cdot \left(\color{blue}{{im}^{3} \cdot -0.16666666666666666} - im\right) \]
  6. Simplified79.5%

    \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
  7. Taylor expanded in re around 0 52.8%

    \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
  8. Taylor expanded in im around 0 31.1%

    \[\leadsto \color{blue}{-1 \cdot im} \]
  9. Step-by-step derivation
    1. neg-mul-131.1%

      \[\leadsto \color{blue}{-im} \]
  10. Simplified31.1%

    \[\leadsto \color{blue}{-im} \]
  11. Final simplification31.1%

    \[\leadsto -im \]

Alternative 21: 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 55.0%

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
  2. Step-by-step derivation
    1. neg-sub055.0%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(e^{\color{blue}{-im}} - e^{im}\right) \]
  3. Simplified55.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 2.4%

    \[\leadsto \color{blue}{-0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right) + 0.5 \cdot \left(e^{-im} - e^{im}\right)} \]
  5. Step-by-step derivation
    1. +-commutative2.4%

      \[\leadsto \color{blue}{0.5 \cdot \left(e^{-im} - e^{im}\right) + -0.25 \cdot \left({re}^{2} \cdot \left(e^{-im} - e^{im}\right)\right)} \]
    2. associate-*r*2.4%

      \[\leadsto 0.5 \cdot \left(e^{-im} - e^{im}\right) + \color{blue}{\left(-0.25 \cdot {re}^{2}\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    3. distribute-rgt-out39.5%

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot {re}^{2}\right)} \]
    4. unpow239.5%

      \[\leadsto \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
  6. Simplified39.5%

    \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
  7. Applied egg-rr8.4%

    \[\leadsto \color{blue}{27} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \]
  8. Taylor expanded in re around 0 2.8%

    \[\leadsto \color{blue}{13.5} \]
  9. Final simplification2.8%

    \[\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 2023271 
(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))))