math.sin on complex, imaginary part

Percentage Accurate: 54.7% → 99.8%
Time: 10.0s
Alternatives: 17
Speedup: 2.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 alternatives:

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

Initial Program: 54.7% 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.4 \lor \neg \left(t_0 \leq 5 \cdot 10^{-9}\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.4) (not (<= t_0 5e-9)))
     (* (* 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.4) || !(t_0 <= 5e-9)) {
		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.4d0)) .or. (.not. (t_0 <= 5d-9))) 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.4) || !(t_0 <= 5e-9)) {
		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.4) or not (t_0 <= 5e-9):
		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.4) || !(t_0 <= 5e-9))
		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.4) || ~((t_0 <= 5e-9)))
		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.4], N[Not[LessEqual[t$95$0, 5e-9]], $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.4 \lor \neg \left(t_0 \leq 5 \cdot 10^{-9}\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.40000000000000002 or 5.0000000000000001e-9 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 100.0%

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

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

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

    if -0.40000000000000002 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 5.0000000000000001e-9

    1. Initial program 7.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -0.4 \lor \neg \left(e^{-im} - e^{im} \leq 5 \cdot 10^{-9}\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: 95.2% 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 -2.5 \cdot 10^{+116}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -11.5:\\ \;\;\;\;0.5 \cdot t_0\\ \mathbf{elif}\;im \leq 0.046 \lor \neg \left(im \leq 5.7 \cdot 10^{+102}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \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 -2.5e+116)
     t_1
     (if (<= im -11.5)
       (* 0.5 t_0)
       (if (or (<= im 0.046) (not (<= im 5.7e+102)))
         t_1
         (* t_0 (+ 0.5 (* re (* re -0.25)))))))))
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 <= -2.5e+116) {
		tmp = t_1;
	} else if (im <= -11.5) {
		tmp = 0.5 * t_0;
	} else if ((im <= 0.046) || !(im <= 5.7e+102)) {
		tmp = t_1;
	} else {
		tmp = t_0 * (0.5 + (re * (re * -0.25)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: 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 <= (-2.5d+116)) then
        tmp = t_1
    else if (im <= (-11.5d0)) then
        tmp = 0.5d0 * t_0
    else if ((im <= 0.046d0) .or. (.not. (im <= 5.7d+102))) then
        tmp = t_1
    else
        tmp = t_0 * (0.5d0 + (re * (re * (-0.25d0))))
    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 <= -2.5e+116) {
		tmp = t_1;
	} else if (im <= -11.5) {
		tmp = 0.5 * t_0;
	} else if ((im <= 0.046) || !(im <= 5.7e+102)) {
		tmp = t_1;
	} else {
		tmp = t_0 * (0.5 + (re * (re * -0.25)));
	}
	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 <= -2.5e+116:
		tmp = t_1
	elif im <= -11.5:
		tmp = 0.5 * t_0
	elif (im <= 0.046) or not (im <= 5.7e+102):
		tmp = t_1
	else:
		tmp = t_0 * (0.5 + (re * (re * -0.25)))
	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 <= -2.5e+116)
		tmp = t_1;
	elseif (im <= -11.5)
		tmp = Float64(0.5 * t_0);
	elseif ((im <= 0.046) || !(im <= 5.7e+102))
		tmp = t_1;
	else
		tmp = Float64(t_0 * Float64(0.5 + Float64(re * Float64(re * -0.25))));
	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 <= -2.5e+116)
		tmp = t_1;
	elseif (im <= -11.5)
		tmp = 0.5 * t_0;
	elseif ((im <= 0.046) || ~((im <= 5.7e+102)))
		tmp = t_1;
	else
		tmp = t_0 * (0.5 + (re * (re * -0.25)));
	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, -2.5e+116], t$95$1, If[LessEqual[im, -11.5], N[(0.5 * t$95$0), $MachinePrecision], If[Or[LessEqual[im, 0.046], N[Not[LessEqual[im, 5.7e+102]], $MachinePrecision]], t$95$1, N[(t$95$0 * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 -2.5 \cdot 10^{+116}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 0.046 \lor \neg \left(im \leq 5.7 \cdot 10^{+102}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.50000000000000013e116 or -11.5 < im < 0.045999999999999999 or 5.6999999999999999e102 < im

    1. Initial program 40.8%

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

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

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

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

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

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

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

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

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

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

    if -2.50000000000000013e116 < im < -11.5

    1. Initial program 100.0%

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

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

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

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

    if 0.045999999999999999 < im < 5.6999999999999999e102

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.5 \cdot 10^{+116}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq -11.5:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.046 \lor \neg \left(im \leq 5.7 \cdot 10^{+102}\right):\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \end{array} \]

Alternative 3: 94.9% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -2.2 \cdot 10^{+116} \lor \neg \left(im \leq -11.5 \lor \neg \left(im \leq 0.046\right) \land im \leq 5.7 \cdot 10^{+102}\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 < -2.2e116 or -11.5 < im < 0.045999999999999999 or 5.6999999999999999e102 < im

    1. Initial program 40.8%

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

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

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

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

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

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

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

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

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

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

    if -2.2e116 < im < -11.5 or 0.045999999999999999 < im < 5.6999999999999999e102

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.2 \cdot 10^{+116} \lor \neg \left(im \leq -11.5 \lor \neg \left(im \leq 0.046\right) \land im \leq 5.7 \cdot 10^{+102}\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: 92.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := \frac{\cos re \cdot \left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{if}\;im \leq -1.32 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -11.5:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.0005:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
        (t_1
         (/
          (* (cos re) (- 1.4551915228366852e-11 (* im im)))
          (+ im -3.814697265625e-6))))
   (if (<= im -1.32e+154)
     t_1
     (if (<= im -11.5)
       t_0
       (if (<= im 0.0005)
         (* (cos re) (- im))
         (if (<= im 1.35e+154) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double t_1 = (cos(re) * (1.4551915228366852e-11 - (im * im))) / (im + -3.814697265625e-6);
	double tmp;
	if (im <= -1.32e+154) {
		tmp = t_1;
	} else if (im <= -11.5) {
		tmp = t_0;
	} else if (im <= 0.0005) {
		tmp = cos(re) * -im;
	} else if (im <= 1.35e+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 = 0.5d0 * (exp(-im) - exp(im))
    t_1 = (cos(re) * (1.4551915228366852d-11 - (im * im))) / (im + (-3.814697265625d-6))
    if (im <= (-1.32d+154)) then
        tmp = t_1
    else if (im <= (-11.5d0)) then
        tmp = t_0
    else if (im <= 0.0005d0) then
        tmp = cos(re) * -im
    else if (im <= 1.35d+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 = 0.5 * (Math.exp(-im) - Math.exp(im));
	double t_1 = (Math.cos(re) * (1.4551915228366852e-11 - (im * im))) / (im + -3.814697265625e-6);
	double tmp;
	if (im <= -1.32e+154) {
		tmp = t_1;
	} else if (im <= -11.5) {
		tmp = t_0;
	} else if (im <= 0.0005) {
		tmp = Math.cos(re) * -im;
	} else if (im <= 1.35e+154) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * (math.exp(-im) - math.exp(im))
	t_1 = (math.cos(re) * (1.4551915228366852e-11 - (im * im))) / (im + -3.814697265625e-6)
	tmp = 0
	if im <= -1.32e+154:
		tmp = t_1
	elif im <= -11.5:
		tmp = t_0
	elif im <= 0.0005:
		tmp = math.cos(re) * -im
	elif im <= 1.35e+154:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	t_1 = Float64(Float64(cos(re) * Float64(1.4551915228366852e-11 - Float64(im * im))) / Float64(im + -3.814697265625e-6))
	tmp = 0.0
	if (im <= -1.32e+154)
		tmp = t_1;
	elseif (im <= -11.5)
		tmp = t_0;
	elseif (im <= 0.0005)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 1.35e+154)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * (exp(-im) - exp(im));
	t_1 = (cos(re) * (1.4551915228366852e-11 - (im * im))) / (im + -3.814697265625e-6);
	tmp = 0.0;
	if (im <= -1.32e+154)
		tmp = t_1;
	elseif (im <= -11.5)
		tmp = t_0;
	elseif (im <= 0.0005)
		tmp = cos(re) * -im;
	elseif (im <= 1.35e+154)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * N[(1.4551915228366852e-11 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.814697265625e-6), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.32e+154], t$95$1, If[LessEqual[im, -11.5], t$95$0, If[LessEqual[im, 0.0005], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1.35e+154], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := \frac{\cos re \cdot \left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right)}{im + -3.814697265625 \cdot 10^{-6}}\\
\mathbf{if}\;im \leq -1.32 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-3.814697265625 \cdot 10^{-6}} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative6.9%

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

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

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

        \[\leadsto \frac{\left(\color{blue}{1.4551915228366852 \cdot 10^{-11}} - im \cdot im\right) \cdot \cos re}{-3.814697265625 \cdot 10^{-6} + im} \]
      5. +-commutative100.0%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -3.814697265625 \cdot 10^{-6}}} \]
    9. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{im + -3.814697265625 \cdot 10^{-6}}} \]

    if -1.31999999999999998e154 < im < -11.5 or 5.0000000000000001e-4 < im < 1.35000000000000003e154

    1. Initial program 100.0%

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

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

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

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

    if -11.5 < im < 5.0000000000000001e-4

    1. Initial program 8.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.32 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{elif}\;im \leq -11.5:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.0005:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \end{array} \]

Alternative 5: 82.2% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ t_1 := \frac{\cos re \cdot \left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{if}\;im \leq -1.32 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -2.35 \cdot 10^{+92}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -1.55 \cdot 10^{+23}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 0.062:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;t_0 - im\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666))
        (t_1
         (/
          (* (cos re) (- 1.4551915228366852e-11 (* im im)))
          (+ im -3.814697265625e-6))))
   (if (<= im -1.32e+154)
     t_1
     (if (<= im -2.35e+92)
       t_0
       (if (<= im -1.55e+23)
         (- (* (* re re) (* im 0.5)) im)
         (if (<= im 0.062)
           (* (cos re) (- im))
           (if (<= im 1.35e+154) (- t_0 im) t_1)))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double t_1 = (cos(re) * (1.4551915228366852e-11 - (im * im))) / (im + -3.814697265625e-6);
	double tmp;
	if (im <= -1.32e+154) {
		tmp = t_1;
	} else if (im <= -2.35e+92) {
		tmp = t_0;
	} else if (im <= -1.55e+23) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else if (im <= 0.062) {
		tmp = cos(re) * -im;
	} else if (im <= 1.35e+154) {
		tmp = t_0 - im;
	} 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 = (im ** 3.0d0) * (-0.16666666666666666d0)
    t_1 = (cos(re) * (1.4551915228366852d-11 - (im * im))) / (im + (-3.814697265625d-6))
    if (im <= (-1.32d+154)) then
        tmp = t_1
    else if (im <= (-2.35d+92)) then
        tmp = t_0
    else if (im <= (-1.55d+23)) then
        tmp = ((re * re) * (im * 0.5d0)) - im
    else if (im <= 0.062d0) then
        tmp = cos(re) * -im
    else if (im <= 1.35d+154) then
        tmp = t_0 - im
    else
        tmp = t_1
    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 = (Math.cos(re) * (1.4551915228366852e-11 - (im * im))) / (im + -3.814697265625e-6);
	double tmp;
	if (im <= -1.32e+154) {
		tmp = t_1;
	} else if (im <= -2.35e+92) {
		tmp = t_0;
	} else if (im <= -1.55e+23) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else if (im <= 0.062) {
		tmp = Math.cos(re) * -im;
	} else if (im <= 1.35e+154) {
		tmp = t_0 - im;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	t_1 = (math.cos(re) * (1.4551915228366852e-11 - (im * im))) / (im + -3.814697265625e-6)
	tmp = 0
	if im <= -1.32e+154:
		tmp = t_1
	elif im <= -2.35e+92:
		tmp = t_0
	elif im <= -1.55e+23:
		tmp = ((re * re) * (im * 0.5)) - im
	elif im <= 0.062:
		tmp = math.cos(re) * -im
	elif im <= 1.35e+154:
		tmp = t_0 - im
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	t_1 = Float64(Float64(cos(re) * Float64(1.4551915228366852e-11 - Float64(im * im))) / Float64(im + -3.814697265625e-6))
	tmp = 0.0
	if (im <= -1.32e+154)
		tmp = t_1;
	elseif (im <= -2.35e+92)
		tmp = t_0;
	elseif (im <= -1.55e+23)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) - im);
	elseif (im <= 0.062)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 1.35e+154)
		tmp = Float64(t_0 - im);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	t_1 = (cos(re) * (1.4551915228366852e-11 - (im * im))) / (im + -3.814697265625e-6);
	tmp = 0.0;
	if (im <= -1.32e+154)
		tmp = t_1;
	elseif (im <= -2.35e+92)
		tmp = t_0;
	elseif (im <= -1.55e+23)
		tmp = ((re * re) * (im * 0.5)) - im;
	elseif (im <= 0.062)
		tmp = cos(re) * -im;
	elseif (im <= 1.35e+154)
		tmp = t_0 - im;
	else
		tmp = t_1;
	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[(N[Cos[re], $MachinePrecision] * N[(1.4551915228366852e-11 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.814697265625e-6), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.32e+154], t$95$1, If[LessEqual[im, -2.35e+92], t$95$0, If[LessEqual[im, -1.55e+23], N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 0.062], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(t$95$0 - im), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
t_1 := \frac{\cos re \cdot \left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right)}{im + -3.814697265625 \cdot 10^{-6}}\\
\mathbf{if}\;im \leq -1.32 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -2.35 \cdot 10^{+92}:\\
\;\;\;\;t_0\\

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-3.814697265625 \cdot 10^{-6}} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative6.9%

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

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

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

        \[\leadsto \frac{\left(\color{blue}{1.4551915228366852 \cdot 10^{-11}} - im \cdot im\right) \cdot \cos re}{-3.814697265625 \cdot 10^{-6} + im} \]
      5. +-commutative100.0%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -3.814697265625 \cdot 10^{-6}}} \]
    9. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{im + -3.814697265625 \cdot 10^{-6}}} \]

    if -1.31999999999999998e154 < im < -2.35e92

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\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 -2.35e92 < im < -1.54999999999999985e23

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.54999999999999985e23 < im < 0.062

    1. Initial program 13.5%

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

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

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

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

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

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

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

    if 0.062 < im < 1.35000000000000003e154

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.32 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{elif}\;im \leq -2.35 \cdot 10^{+92}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -1.55 \cdot 10^{+23}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 0.062:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \end{array} \]

Alternative 6: 82.5% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ t_1 := \frac{\cos re \cdot \left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ t_2 := t_0 - im\\ \mathbf{if}\;im \leq -1.32 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -5 \cdot 10^{+128}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -2.2 \cdot 10^{+23}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot t_2\\ \mathbf{elif}\;im \leq 0.0027:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+153}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666))
        (t_1
         (/
          (* (cos re) (- 1.4551915228366852e-11 (* im im)))
          (+ im -3.814697265625e-6)))
        (t_2 (- t_0 im)))
   (if (<= im -1.32e+154)
     t_1
     (if (<= im -5e+128)
       t_0
       (if (<= im -2.2e+23)
         (* (+ (* -0.5 (* re re)) 1.0) t_2)
         (if (<= im 0.0027)
           (* (cos re) (- im))
           (if (<= im 5e+153) t_2 t_1)))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double t_1 = (cos(re) * (1.4551915228366852e-11 - (im * im))) / (im + -3.814697265625e-6);
	double t_2 = t_0 - im;
	double tmp;
	if (im <= -1.32e+154) {
		tmp = t_1;
	} else if (im <= -5e+128) {
		tmp = t_0;
	} else if (im <= -2.2e+23) {
		tmp = ((-0.5 * (re * re)) + 1.0) * t_2;
	} else if (im <= 0.0027) {
		tmp = cos(re) * -im;
	} else if (im <= 5e+153) {
		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 = (im ** 3.0d0) * (-0.16666666666666666d0)
    t_1 = (cos(re) * (1.4551915228366852d-11 - (im * im))) / (im + (-3.814697265625d-6))
    t_2 = t_0 - im
    if (im <= (-1.32d+154)) then
        tmp = t_1
    else if (im <= (-5d+128)) then
        tmp = t_0
    else if (im <= (-2.2d+23)) then
        tmp = (((-0.5d0) * (re * re)) + 1.0d0) * t_2
    else if (im <= 0.0027d0) then
        tmp = cos(re) * -im
    else if (im <= 5d+153) 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 = Math.pow(im, 3.0) * -0.16666666666666666;
	double t_1 = (Math.cos(re) * (1.4551915228366852e-11 - (im * im))) / (im + -3.814697265625e-6);
	double t_2 = t_0 - im;
	double tmp;
	if (im <= -1.32e+154) {
		tmp = t_1;
	} else if (im <= -5e+128) {
		tmp = t_0;
	} else if (im <= -2.2e+23) {
		tmp = ((-0.5 * (re * re)) + 1.0) * t_2;
	} else if (im <= 0.0027) {
		tmp = Math.cos(re) * -im;
	} else if (im <= 5e+153) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	t_1 = (math.cos(re) * (1.4551915228366852e-11 - (im * im))) / (im + -3.814697265625e-6)
	t_2 = t_0 - im
	tmp = 0
	if im <= -1.32e+154:
		tmp = t_1
	elif im <= -5e+128:
		tmp = t_0
	elif im <= -2.2e+23:
		tmp = ((-0.5 * (re * re)) + 1.0) * t_2
	elif im <= 0.0027:
		tmp = math.cos(re) * -im
	elif im <= 5e+153:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	t_1 = Float64(Float64(cos(re) * Float64(1.4551915228366852e-11 - Float64(im * im))) / Float64(im + -3.814697265625e-6))
	t_2 = Float64(t_0 - im)
	tmp = 0.0
	if (im <= -1.32e+154)
		tmp = t_1;
	elseif (im <= -5e+128)
		tmp = t_0;
	elseif (im <= -2.2e+23)
		tmp = Float64(Float64(Float64(-0.5 * Float64(re * re)) + 1.0) * t_2);
	elseif (im <= 0.0027)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 5e+153)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	t_1 = (cos(re) * (1.4551915228366852e-11 - (im * im))) / (im + -3.814697265625e-6);
	t_2 = t_0 - im;
	tmp = 0.0;
	if (im <= -1.32e+154)
		tmp = t_1;
	elseif (im <= -5e+128)
		tmp = t_0;
	elseif (im <= -2.2e+23)
		tmp = ((-0.5 * (re * re)) + 1.0) * t_2;
	elseif (im <= 0.0027)
		tmp = cos(re) * -im;
	elseif (im <= 5e+153)
		tmp = t_2;
	else
		tmp = t_1;
	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[(N[Cos[re], $MachinePrecision] * N[(1.4551915228366852e-11 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.814697265625e-6), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - im), $MachinePrecision]}, If[LessEqual[im, -1.32e+154], t$95$1, If[LessEqual[im, -5e+128], t$95$0, If[LessEqual[im, -2.2e+23], N[(N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[im, 0.0027], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 5e+153], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
t_1 := \frac{\cos re \cdot \left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right)}{im + -3.814697265625 \cdot 10^{-6}}\\
t_2 := t_0 - im\\
\mathbf{if}\;im \leq -1.32 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq -2.2 \cdot 10^{+23}:\\
\;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot t_2\\

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

\mathbf{elif}\;im \leq 5 \cdot 10^{+153}:\\
\;\;\;\;t_2\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-3.814697265625 \cdot 10^{-6}} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative6.9%

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

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

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

        \[\leadsto \frac{\left(\color{blue}{1.4551915228366852 \cdot 10^{-11}} - im \cdot im\right) \cdot \cos re}{-3.814697265625 \cdot 10^{-6} + im} \]
      5. +-commutative100.0%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -3.814697265625 \cdot 10^{-6}}} \]
    9. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{im + -3.814697265625 \cdot 10^{-6}}} \]

    if -1.31999999999999998e154 < im < -5e128

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5e128 < im < -2.20000000000000008e23

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)} \]
    7. Taylor expanded in re around 0 20.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+20.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*20.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-in34.6%

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

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

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

    if -2.20000000000000008e23 < im < 0.0027000000000000001

    1. Initial program 13.5%

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

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

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

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

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

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

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

    if 0.0027000000000000001 < im < 5.00000000000000018e153

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.32 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{elif}\;im \leq -5 \cdot 10^{+128}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -2.2 \cdot 10^{+23}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 0.0027:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+153}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \end{array} \]

Alternative 7: 55.6% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ t_1 := {im}^{3} \cdot -0.16666666666666666\\ \mathbf{if}\;im \leq -1.6 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -2.35 \cdot 10^{+92}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -1.55 \cdot 10^{+23}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 2.15 \cdot 10^{-7}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 4.3 \cdot 10^{+95}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (/
          (* (- 1.4551915228366852e-11 (* im im)) (+ (* -0.5 (* re re)) 1.0))
          (+ im -3.814697265625e-6)))
        (t_1 (* (pow im 3.0) -0.16666666666666666)))
   (if (<= im -1.6e+154)
     t_0
     (if (<= im -2.35e+92)
       t_1
       (if (<= im -1.55e+23)
         (- (* (* re re) (* im 0.5)) im)
         (if (<= im 2.15e-7) (- im) (if (<= im 4.3e+95) t_0 t_1)))))))
double code(double re, double im) {
	double t_0 = ((1.4551915228366852e-11 - (im * im)) * ((-0.5 * (re * re)) + 1.0)) / (im + -3.814697265625e-6);
	double t_1 = pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -1.6e+154) {
		tmp = t_0;
	} else if (im <= -2.35e+92) {
		tmp = t_1;
	} else if (im <= -1.55e+23) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else if (im <= 2.15e-7) {
		tmp = -im;
	} else if (im <= 4.3e+95) {
		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 = ((1.4551915228366852d-11 - (im * im)) * (((-0.5d0) * (re * re)) + 1.0d0)) / (im + (-3.814697265625d-6))
    t_1 = (im ** 3.0d0) * (-0.16666666666666666d0)
    if (im <= (-1.6d+154)) then
        tmp = t_0
    else if (im <= (-2.35d+92)) then
        tmp = t_1
    else if (im <= (-1.55d+23)) then
        tmp = ((re * re) * (im * 0.5d0)) - im
    else if (im <= 2.15d-7) then
        tmp = -im
    else if (im <= 4.3d+95) 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 = ((1.4551915228366852e-11 - (im * im)) * ((-0.5 * (re * re)) + 1.0)) / (im + -3.814697265625e-6);
	double t_1 = Math.pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -1.6e+154) {
		tmp = t_0;
	} else if (im <= -2.35e+92) {
		tmp = t_1;
	} else if (im <= -1.55e+23) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else if (im <= 2.15e-7) {
		tmp = -im;
	} else if (im <= 4.3e+95) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = ((1.4551915228366852e-11 - (im * im)) * ((-0.5 * (re * re)) + 1.0)) / (im + -3.814697265625e-6)
	t_1 = math.pow(im, 3.0) * -0.16666666666666666
	tmp = 0
	if im <= -1.6e+154:
		tmp = t_0
	elif im <= -2.35e+92:
		tmp = t_1
	elif im <= -1.55e+23:
		tmp = ((re * re) * (im * 0.5)) - im
	elif im <= 2.15e-7:
		tmp = -im
	elif im <= 4.3e+95:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(Float64(1.4551915228366852e-11 - Float64(im * im)) * Float64(Float64(-0.5 * Float64(re * re)) + 1.0)) / Float64(im + -3.814697265625e-6))
	t_1 = Float64((im ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im <= -1.6e+154)
		tmp = t_0;
	elseif (im <= -2.35e+92)
		tmp = t_1;
	elseif (im <= -1.55e+23)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) - im);
	elseif (im <= 2.15e-7)
		tmp = Float64(-im);
	elseif (im <= 4.3e+95)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = ((1.4551915228366852e-11 - (im * im)) * ((-0.5 * (re * re)) + 1.0)) / (im + -3.814697265625e-6);
	t_1 = (im ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im <= -1.6e+154)
		tmp = t_0;
	elseif (im <= -2.35e+92)
		tmp = t_1;
	elseif (im <= -1.55e+23)
		tmp = ((re * re) * (im * 0.5)) - im;
	elseif (im <= 2.15e-7)
		tmp = -im;
	elseif (im <= 4.3e+95)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(1.4551915228366852e-11 - N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(im + -3.814697265625e-6), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, If[LessEqual[im, -1.6e+154], t$95$0, If[LessEqual[im, -2.35e+92], t$95$1, If[LessEqual[im, -1.55e+23], N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 2.15e-7], (-im), If[LessEqual[im, 4.3e+95], t$95$0, t$95$1]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)}{im + -3.814697265625 \cdot 10^{-6}}\\
t_1 := {im}^{3} \cdot -0.16666666666666666\\
\mathbf{if}\;im \leq -1.6 \cdot 10^{+154}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -2.35 \cdot 10^{+92}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 4.3 \cdot 10^{+95}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -1.6e154 or 2.1500000000000001e-7 < im < 4.3e95

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-3.814697265625 \cdot 10^{-6} - im\right) \cdot \cos re} \]
      2. flip--72.0%

        \[\leadsto \color{blue}{\frac{-3.814697265625 \cdot 10^{-6} \cdot -3.814697265625 \cdot 10^{-6} - im \cdot im}{-3.814697265625 \cdot 10^{-6} + im}} \cdot \cos re \]
      3. associate-*l/72.0%

        \[\leadsto \color{blue}{\frac{\left(-3.814697265625 \cdot 10^{-6} \cdot -3.814697265625 \cdot 10^{-6} - im \cdot im\right) \cdot \cos re}{-3.814697265625 \cdot 10^{-6} + im}} \]
      4. metadata-eval72.0%

        \[\leadsto \frac{\left(\color{blue}{1.4551915228366852 \cdot 10^{-11}} - im \cdot im\right) \cdot \cos re}{-3.814697265625 \cdot 10^{-6} + im} \]
      5. +-commutative72.0%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -3.814697265625 \cdot 10^{-6}}} \]
    9. Applied egg-rr72.0%

      \[\leadsto \color{blue}{\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{im + -3.814697265625 \cdot 10^{-6}}} \]
    10. Taylor expanded in re around 0 8.6%

      \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} + -0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right)\right) - {im}^{2}}}{im + -3.814697265625 \cdot 10^{-6}} \]
    11. Step-by-step derivation
      1. sub-neg8.6%

        \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} + -0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right)\right) + \left(-{im}^{2}\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      2. +-commutative8.6%

        \[\leadsto \frac{\color{blue}{\left(-0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right) + 1.4551915228366852 \cdot 10^{-11}\right)} + \left(-{im}^{2}\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      3. associate-+l+8.6%

        \[\leadsto \frac{\color{blue}{-0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right) + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      4. *-commutative8.6%

        \[\leadsto \frac{\color{blue}{\left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right) \cdot -0.5} + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      5. unpow28.6%

        \[\leadsto \frac{\left(\left(1.4551915228366852 \cdot 10^{-11} - \color{blue}{im \cdot im}\right) \cdot {re}^{2}\right) \cdot -0.5 + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      6. associate-*l*8.6%

        \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right)} + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      7. sub-neg8.6%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right) + \color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      8. unpow28.6%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right) + \left(1.4551915228366852 \cdot 10^{-11} - \color{blue}{im \cdot im}\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      9. *-rgt-identity8.6%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right) + \color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot 1}}{im + -3.814697265625 \cdot 10^{-6}} \]
      10. distribute-lft-out69.1%

        \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5 + 1\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      11. unpow269.1%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot -0.5 + 1\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
    12. Simplified69.1%

      \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(\left(re \cdot re\right) \cdot -0.5 + 1\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]

    if -1.6e154 < im < -2.35e92 or 4.3e95 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.35e92 < im < -1.54999999999999985e23

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.54999999999999985e23 < im < 2.1500000000000001e-7

    1. Initial program 13.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.6 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{elif}\;im \leq -2.35 \cdot 10^{+92}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -1.55 \cdot 10^{+23}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 2.15 \cdot 10^{-7}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 4.3 \cdot 10^{+95}:\\ \;\;\;\;\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \end{array} \]

Alternative 8: 75.7% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ \mathbf{if}\;im \leq -2 \cdot 10^{+155}:\\ \;\;\;\;\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{elif}\;im \leq -2.7 \cdot 10^{+91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -8 \cdot 10^{+24}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 7 \cdot 10^{-6}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666)))
   (if (<= im -2e+155)
     (/
      (* (- 1.4551915228366852e-11 (* im im)) (+ (* -0.5 (* re re)) 1.0))
      (+ im -3.814697265625e-6))
     (if (<= im -2.7e+91)
       t_0
       (if (<= im -8e+24)
         (- (* (* re re) (* im 0.5)) im)
         (if (<= im 7e-6) (* (cos re) (- im)) (- t_0 im)))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -2e+155) {
		tmp = ((1.4551915228366852e-11 - (im * im)) * ((-0.5 * (re * re)) + 1.0)) / (im + -3.814697265625e-6);
	} else if (im <= -2.7e+91) {
		tmp = t_0;
	} else if (im <= -8e+24) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else if (im <= 7e-6) {
		tmp = cos(re) * -im;
	} 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) :: tmp
    t_0 = (im ** 3.0d0) * (-0.16666666666666666d0)
    if (im <= (-2d+155)) then
        tmp = ((1.4551915228366852d-11 - (im * im)) * (((-0.5d0) * (re * re)) + 1.0d0)) / (im + (-3.814697265625d-6))
    else if (im <= (-2.7d+91)) then
        tmp = t_0
    else if (im <= (-8d+24)) then
        tmp = ((re * re) * (im * 0.5d0)) - im
    else if (im <= 7d-6) then
        tmp = cos(re) * -im
    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 tmp;
	if (im <= -2e+155) {
		tmp = ((1.4551915228366852e-11 - (im * im)) * ((-0.5 * (re * re)) + 1.0)) / (im + -3.814697265625e-6);
	} else if (im <= -2.7e+91) {
		tmp = t_0;
	} else if (im <= -8e+24) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else if (im <= 7e-6) {
		tmp = Math.cos(re) * -im;
	} else {
		tmp = t_0 - im;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	tmp = 0
	if im <= -2e+155:
		tmp = ((1.4551915228366852e-11 - (im * im)) * ((-0.5 * (re * re)) + 1.0)) / (im + -3.814697265625e-6)
	elif im <= -2.7e+91:
		tmp = t_0
	elif im <= -8e+24:
		tmp = ((re * re) * (im * 0.5)) - im
	elif im <= 7e-6:
		tmp = math.cos(re) * -im
	else:
		tmp = t_0 - im
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im <= -2e+155)
		tmp = Float64(Float64(Float64(1.4551915228366852e-11 - Float64(im * im)) * Float64(Float64(-0.5 * Float64(re * re)) + 1.0)) / Float64(im + -3.814697265625e-6));
	elseif (im <= -2.7e+91)
		tmp = t_0;
	elseif (im <= -8e+24)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) - im);
	elseif (im <= 7e-6)
		tmp = Float64(cos(re) * Float64(-im));
	else
		tmp = Float64(t_0 - im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im <= -2e+155)
		tmp = ((1.4551915228366852e-11 - (im * im)) * ((-0.5 * (re * re)) + 1.0)) / (im + -3.814697265625e-6);
	elseif (im <= -2.7e+91)
		tmp = t_0;
	elseif (im <= -8e+24)
		tmp = ((re * re) * (im * 0.5)) - im;
	elseif (im <= 7e-6)
		tmp = cos(re) * -im;
	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]}, If[LessEqual[im, -2e+155], N[(N[(N[(1.4551915228366852e-11 - N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(im + -3.814697265625e-6), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -2.7e+91], t$95$0, If[LessEqual[im, -8e+24], N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 7e-6], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(t$95$0 - im), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
\mathbf{if}\;im \leq -2 \cdot 10^{+155}:\\
\;\;\;\;\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)}{im + -3.814697265625 \cdot 10^{-6}}\\

\mathbf{elif}\;im \leq -2.7 \cdot 10^{+91}:\\
\;\;\;\;t_0\\

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-3.814697265625 \cdot 10^{-6}} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative6.9%

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

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

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

        \[\leadsto \frac{\left(\color{blue}{1.4551915228366852 \cdot 10^{-11}} - im \cdot im\right) \cdot \cos re}{-3.814697265625 \cdot 10^{-6} + im} \]
      5. +-commutative100.0%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -3.814697265625 \cdot 10^{-6}}} \]
    9. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{im + -3.814697265625 \cdot 10^{-6}}} \]
    10. Taylor expanded in re around 0 0.0%

      \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} + -0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right)\right) - {im}^{2}}}{im + -3.814697265625 \cdot 10^{-6}} \]
    11. Step-by-step derivation
      1. sub-neg0.0%

        \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} + -0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right)\right) + \left(-{im}^{2}\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      2. +-commutative0.0%

        \[\leadsto \frac{\color{blue}{\left(-0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right) + 1.4551915228366852 \cdot 10^{-11}\right)} + \left(-{im}^{2}\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      3. associate-+l+0.0%

        \[\leadsto \frac{\color{blue}{-0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right) + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      4. *-commutative0.0%

        \[\leadsto \frac{\color{blue}{\left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right) \cdot -0.5} + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      5. unpow20.0%

        \[\leadsto \frac{\left(\left(1.4551915228366852 \cdot 10^{-11} - \color{blue}{im \cdot im}\right) \cdot {re}^{2}\right) \cdot -0.5 + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      6. associate-*l*0.0%

        \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right)} + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      7. sub-neg0.0%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right) + \color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      8. unpow20.0%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right) + \left(1.4551915228366852 \cdot 10^{-11} - \color{blue}{im \cdot im}\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      9. *-rgt-identity0.0%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right) + \color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot 1}}{im + -3.814697265625 \cdot 10^{-6}} \]
      10. distribute-lft-out86.7%

        \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5 + 1\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      11. unpow286.7%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot -0.5 + 1\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
    12. Simplified86.7%

      \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(\left(re \cdot re\right) \cdot -0.5 + 1\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]

    if -2.00000000000000001e155 < im < -2.7e91

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\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 -2.7e91 < im < -7.9999999999999999e24

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.9999999999999999e24 < im < 6.99999999999999989e-6

    1. Initial program 13.5%

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

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

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

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

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

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

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

    if 6.99999999999999989e-6 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2 \cdot 10^{+155}:\\ \;\;\;\;\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{elif}\;im \leq -2.7 \cdot 10^{+91}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -8 \cdot 10^{+24}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 7 \cdot 10^{-6}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 9: 75.7% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666\\ \mathbf{if}\;im \leq -3 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{elif}\;im \leq -1.3 \cdot 10^{+92}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -1.55 \cdot 10^{+23}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 1.05 \cdot 10^{+85}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (pow im 3.0) -0.16666666666666666)))
   (if (<= im -3e+154)
     (/
      (* (- 1.4551915228366852e-11 (* im im)) (+ (* -0.5 (* re re)) 1.0))
      (+ im -3.814697265625e-6))
     (if (<= im -1.3e+92)
       t_0
       (if (<= im -1.55e+23)
         (- (* (* re re) (* im 0.5)) im)
         (if (<= im 1.05e+85) (* (cos re) (- im)) t_0))))))
double code(double re, double im) {
	double t_0 = pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -3e+154) {
		tmp = ((1.4551915228366852e-11 - (im * im)) * ((-0.5 * (re * re)) + 1.0)) / (im + -3.814697265625e-6);
	} else if (im <= -1.3e+92) {
		tmp = t_0;
	} else if (im <= -1.55e+23) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else if (im <= 1.05e+85) {
		tmp = cos(re) * -im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (im ** 3.0d0) * (-0.16666666666666666d0)
    if (im <= (-3d+154)) then
        tmp = ((1.4551915228366852d-11 - (im * im)) * (((-0.5d0) * (re * re)) + 1.0d0)) / (im + (-3.814697265625d-6))
    else if (im <= (-1.3d+92)) then
        tmp = t_0
    else if (im <= (-1.55d+23)) then
        tmp = ((re * re) * (im * 0.5d0)) - im
    else if (im <= 1.05d+85) then
        tmp = cos(re) * -im
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = Math.pow(im, 3.0) * -0.16666666666666666;
	double tmp;
	if (im <= -3e+154) {
		tmp = ((1.4551915228366852e-11 - (im * im)) * ((-0.5 * (re * re)) + 1.0)) / (im + -3.814697265625e-6);
	} else if (im <= -1.3e+92) {
		tmp = t_0;
	} else if (im <= -1.55e+23) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else if (im <= 1.05e+85) {
		tmp = Math.cos(re) * -im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = math.pow(im, 3.0) * -0.16666666666666666
	tmp = 0
	if im <= -3e+154:
		tmp = ((1.4551915228366852e-11 - (im * im)) * ((-0.5 * (re * re)) + 1.0)) / (im + -3.814697265625e-6)
	elif im <= -1.3e+92:
		tmp = t_0
	elif im <= -1.55e+23:
		tmp = ((re * re) * (im * 0.5)) - im
	elif im <= 1.05e+85:
		tmp = math.cos(re) * -im
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64((im ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im <= -3e+154)
		tmp = Float64(Float64(Float64(1.4551915228366852e-11 - Float64(im * im)) * Float64(Float64(-0.5 * Float64(re * re)) + 1.0)) / Float64(im + -3.814697265625e-6));
	elseif (im <= -1.3e+92)
		tmp = t_0;
	elseif (im <= -1.55e+23)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) - im);
	elseif (im <= 1.05e+85)
		tmp = Float64(cos(re) * Float64(-im));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im <= -3e+154)
		tmp = ((1.4551915228366852e-11 - (im * im)) * ((-0.5 * (re * re)) + 1.0)) / (im + -3.814697265625e-6);
	elseif (im <= -1.3e+92)
		tmp = t_0;
	elseif (im <= -1.55e+23)
		tmp = ((re * re) * (im * 0.5)) - im;
	elseif (im <= 1.05e+85)
		tmp = cos(re) * -im;
	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]}, If[LessEqual[im, -3e+154], N[(N[(N[(1.4551915228366852e-11 - N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(im + -3.814697265625e-6), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -1.3e+92], t$95$0, If[LessEqual[im, -1.55e+23], N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[im, 1.05e+85], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666\\
\mathbf{if}\;im \leq -3 \cdot 10^{+154}:\\
\;\;\;\;\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)}{im + -3.814697265625 \cdot 10^{-6}}\\

\mathbf{elif}\;im \leq -1.3 \cdot 10^{+92}:\\
\;\;\;\;t_0\\

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-3.814697265625 \cdot 10^{-6}} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative6.9%

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

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

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

        \[\leadsto \frac{\left(\color{blue}{1.4551915228366852 \cdot 10^{-11}} - im \cdot im\right) \cdot \cos re}{-3.814697265625 \cdot 10^{-6} + im} \]
      5. +-commutative100.0%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -3.814697265625 \cdot 10^{-6}}} \]
    9. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{im + -3.814697265625 \cdot 10^{-6}}} \]
    10. Taylor expanded in re around 0 0.0%

      \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} + -0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right)\right) - {im}^{2}}}{im + -3.814697265625 \cdot 10^{-6}} \]
    11. Step-by-step derivation
      1. sub-neg0.0%

        \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} + -0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right)\right) + \left(-{im}^{2}\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      2. +-commutative0.0%

        \[\leadsto \frac{\color{blue}{\left(-0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right) + 1.4551915228366852 \cdot 10^{-11}\right)} + \left(-{im}^{2}\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      3. associate-+l+0.0%

        \[\leadsto \frac{\color{blue}{-0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right) + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      4. *-commutative0.0%

        \[\leadsto \frac{\color{blue}{\left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right) \cdot -0.5} + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      5. unpow20.0%

        \[\leadsto \frac{\left(\left(1.4551915228366852 \cdot 10^{-11} - \color{blue}{im \cdot im}\right) \cdot {re}^{2}\right) \cdot -0.5 + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      6. associate-*l*0.0%

        \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right)} + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      7. sub-neg0.0%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right) + \color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      8. unpow20.0%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right) + \left(1.4551915228366852 \cdot 10^{-11} - \color{blue}{im \cdot im}\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      9. *-rgt-identity0.0%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right) + \color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot 1}}{im + -3.814697265625 \cdot 10^{-6}} \]
      10. distribute-lft-out86.7%

        \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5 + 1\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      11. unpow286.7%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot -0.5 + 1\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
    12. Simplified86.7%

      \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(\left(re \cdot re\right) \cdot -0.5 + 1\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]

    if -3.00000000000000026e154 < im < -1.2999999999999999e92 or 1.05000000000000005e85 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.2999999999999999e92 < im < -1.54999999999999985e23

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.54999999999999985e23 < im < 1.05000000000000005e85

    1. Initial program 20.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{elif}\;im \leq -1.3 \cdot 10^{+92}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \mathbf{elif}\;im \leq -1.55 \cdot 10^{+23}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{elif}\;im \leq 1.05 \cdot 10^{+85}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666\\ \end{array} \]

Alternative 10: 52.1% accurate, 14.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.55 \cdot 10^{+23} \lor \neg \left(im \leq 2.15 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)}{im + -3.814697265625 \cdot 10^{-6}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -1.54999999999999985e23 or 2.1500000000000001e-7 < im

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-3.814697265625 \cdot 10^{-6} - im\right) \cdot \cos re} \]
      2. flip--49.9%

        \[\leadsto \color{blue}{\frac{-3.814697265625 \cdot 10^{-6} \cdot -3.814697265625 \cdot 10^{-6} - im \cdot im}{-3.814697265625 \cdot 10^{-6} + im}} \cdot \cos re \]
      3. associate-*l/49.9%

        \[\leadsto \color{blue}{\frac{\left(-3.814697265625 \cdot 10^{-6} \cdot -3.814697265625 \cdot 10^{-6} - im \cdot im\right) \cdot \cos re}{-3.814697265625 \cdot 10^{-6} + im}} \]
      4. metadata-eval49.9%

        \[\leadsto \frac{\left(\color{blue}{1.4551915228366852 \cdot 10^{-11}} - im \cdot im\right) \cdot \cos re}{-3.814697265625 \cdot 10^{-6} + im} \]
      5. +-commutative49.9%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -3.814697265625 \cdot 10^{-6}}} \]
    9. Applied egg-rr49.9%

      \[\leadsto \color{blue}{\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{im + -3.814697265625 \cdot 10^{-6}}} \]
    10. Taylor expanded in re around 0 9.6%

      \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} + -0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right)\right) - {im}^{2}}}{im + -3.814697265625 \cdot 10^{-6}} \]
    11. Step-by-step derivation
      1. sub-neg9.6%

        \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} + -0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right)\right) + \left(-{im}^{2}\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      2. +-commutative9.6%

        \[\leadsto \frac{\color{blue}{\left(-0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right) + 1.4551915228366852 \cdot 10^{-11}\right)} + \left(-{im}^{2}\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      3. associate-+l+9.6%

        \[\leadsto \frac{\color{blue}{-0.5 \cdot \left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right) + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      4. *-commutative9.6%

        \[\leadsto \frac{\color{blue}{\left(\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right) \cdot {re}^{2}\right) \cdot -0.5} + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      5. unpow29.6%

        \[\leadsto \frac{\left(\left(1.4551915228366852 \cdot 10^{-11} - \color{blue}{im \cdot im}\right) \cdot {re}^{2}\right) \cdot -0.5 + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      6. associate-*l*9.6%

        \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right)} + \left(1.4551915228366852 \cdot 10^{-11} + \left(-{im}^{2}\right)\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      7. sub-neg9.6%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right) + \color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - {im}^{2}\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      8. unpow29.6%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right) + \left(1.4551915228366852 \cdot 10^{-11} - \color{blue}{im \cdot im}\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
      9. *-rgt-identity9.6%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5\right) + \color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot 1}}{im + -3.814697265625 \cdot 10^{-6}} \]
      10. distribute-lft-out48.2%

        \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left({re}^{2} \cdot -0.5 + 1\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]
      11. unpow248.2%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot -0.5 + 1\right)}{im + -3.814697265625 \cdot 10^{-6}} \]
    12. Simplified48.2%

      \[\leadsto \frac{\color{blue}{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(\left(re \cdot re\right) \cdot -0.5 + 1\right)}}{im + -3.814697265625 \cdot 10^{-6}} \]

    if -1.54999999999999985e23 < im < 2.1500000000000001e-7

    1. Initial program 13.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.55 \cdot 10^{+23} \lor \neg \left(im \leq 2.15 \cdot 10^{-7}\right):\\ \;\;\;\;\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]

Alternative 11: 50.3% accurate, 17.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1.4551915228366852 \cdot 10^{-11} - im \cdot im}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{if}\;im \leq -6.5 \cdot 10^{+150}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -520:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{elif}\;im \leq 2.15 \cdot 10^{-7}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 2.9 \cdot 10^{+156}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0
         (/ (- 1.4551915228366852e-11 (* im im)) (+ im -3.814697265625e-6))))
   (if (<= im -6.5e+150)
     t_0
     (if (<= im -520.0)
       (* (* re re) 0.75)
       (if (<= im 2.15e-7)
         (- im)
         (if (<= im 2.9e+156) (- (* (* re re) (* im 0.5)) im) t_0))))))
double code(double re, double im) {
	double t_0 = (1.4551915228366852e-11 - (im * im)) / (im + -3.814697265625e-6);
	double tmp;
	if (im <= -6.5e+150) {
		tmp = t_0;
	} else if (im <= -520.0) {
		tmp = (re * re) * 0.75;
	} else if (im <= 2.15e-7) {
		tmp = -im;
	} else if (im <= 2.9e+156) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (1.4551915228366852d-11 - (im * im)) / (im + (-3.814697265625d-6))
    if (im <= (-6.5d+150)) then
        tmp = t_0
    else if (im <= (-520.0d0)) then
        tmp = (re * re) * 0.75d0
    else if (im <= 2.15d-7) then
        tmp = -im
    else if (im <= 2.9d+156) then
        tmp = ((re * re) * (im * 0.5d0)) - im
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (1.4551915228366852e-11 - (im * im)) / (im + -3.814697265625e-6);
	double tmp;
	if (im <= -6.5e+150) {
		tmp = t_0;
	} else if (im <= -520.0) {
		tmp = (re * re) * 0.75;
	} else if (im <= 2.15e-7) {
		tmp = -im;
	} else if (im <= 2.9e+156) {
		tmp = ((re * re) * (im * 0.5)) - im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (1.4551915228366852e-11 - (im * im)) / (im + -3.814697265625e-6)
	tmp = 0
	if im <= -6.5e+150:
		tmp = t_0
	elif im <= -520.0:
		tmp = (re * re) * 0.75
	elif im <= 2.15e-7:
		tmp = -im
	elif im <= 2.9e+156:
		tmp = ((re * re) * (im * 0.5)) - im
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64(1.4551915228366852e-11 - Float64(im * im)) / Float64(im + -3.814697265625e-6))
	tmp = 0.0
	if (im <= -6.5e+150)
		tmp = t_0;
	elseif (im <= -520.0)
		tmp = Float64(Float64(re * re) * 0.75);
	elseif (im <= 2.15e-7)
		tmp = Float64(-im);
	elseif (im <= 2.9e+156)
		tmp = Float64(Float64(Float64(re * re) * Float64(im * 0.5)) - im);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (1.4551915228366852e-11 - (im * im)) / (im + -3.814697265625e-6);
	tmp = 0.0;
	if (im <= -6.5e+150)
		tmp = t_0;
	elseif (im <= -520.0)
		tmp = (re * re) * 0.75;
	elseif (im <= 2.15e-7)
		tmp = -im;
	elseif (im <= 2.9e+156)
		tmp = ((re * re) * (im * 0.5)) - im;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(1.4551915228366852e-11 - N[(im * im), $MachinePrecision]), $MachinePrecision] / N[(im + -3.814697265625e-6), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -6.5e+150], t$95$0, If[LessEqual[im, -520.0], N[(N[(re * re), $MachinePrecision] * 0.75), $MachinePrecision], If[LessEqual[im, 2.15e-7], (-im), If[LessEqual[im, 2.9e+156], N[(N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1.4551915228366852 \cdot 10^{-11} - im \cdot im}{im + -3.814697265625 \cdot 10^{-6}}\\
\mathbf{if}\;im \leq -6.5 \cdot 10^{+150}:\\
\;\;\;\;t_0\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -6.50000000000000033e150 or 2.9000000000000001e156 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{-3.814697265625 \cdot 10^{-6}} - im\right) \]
    8. Step-by-step derivation
      1. *-commutative6.9%

        \[\leadsto \color{blue}{\left(-3.814697265625 \cdot 10^{-6} - im\right) \cdot \cos re} \]
      2. flip--98.2%

        \[\leadsto \color{blue}{\frac{-3.814697265625 \cdot 10^{-6} \cdot -3.814697265625 \cdot 10^{-6} - im \cdot im}{-3.814697265625 \cdot 10^{-6} + im}} \cdot \cos re \]
      3. associate-*l/98.2%

        \[\leadsto \color{blue}{\frac{\left(-3.814697265625 \cdot 10^{-6} \cdot -3.814697265625 \cdot 10^{-6} - im \cdot im\right) \cdot \cos re}{-3.814697265625 \cdot 10^{-6} + im}} \]
      4. metadata-eval98.2%

        \[\leadsto \frac{\left(\color{blue}{1.4551915228366852 \cdot 10^{-11}} - im \cdot im\right) \cdot \cos re}{-3.814697265625 \cdot 10^{-6} + im} \]
      5. +-commutative98.2%

        \[\leadsto \frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{\color{blue}{im + -3.814697265625 \cdot 10^{-6}}} \]
    9. Applied egg-rr98.2%

      \[\leadsto \color{blue}{\frac{\left(1.4551915228366852 \cdot 10^{-11} - im \cdot im\right) \cdot \cos re}{im + -3.814697265625 \cdot 10^{-6}}} \]
    10. Taylor expanded in re around 0 64.9%

      \[\leadsto \frac{\color{blue}{1.4551915228366852 \cdot 10^{-11} - {im}^{2}}}{im + -3.814697265625 \cdot 10^{-6}} \]
    11. Step-by-step derivation
      1. unpow264.9%

        \[\leadsto \frac{1.4551915228366852 \cdot 10^{-11} - \color{blue}{im \cdot im}}{im + -3.814697265625 \cdot 10^{-6}} \]
    12. Simplified64.9%

      \[\leadsto \frac{\color{blue}{1.4551915228366852 \cdot 10^{-11} - im \cdot im}}{im + -3.814697265625 \cdot 10^{-6}} \]

    if -6.50000000000000033e150 < im < -520

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -520 < im < 2.1500000000000001e-7

    1. Initial program 8.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-im} \]
    10. Simplified58.8%

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

    if 2.1500000000000001e-7 < im < 2.9000000000000001e156

    1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.5 \cdot 10^{+150}:\\ \;\;\;\;\frac{1.4551915228366852 \cdot 10^{-11} - im \cdot im}{im + -3.814697265625 \cdot 10^{-6}}\\ \mathbf{elif}\;im \leq -520:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{elif}\;im \leq 2.15 \cdot 10^{-7}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 2.9 \cdot 10^{+156}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right) - im\\ \mathbf{else}:\\ \;\;\;\;\frac{1.4551915228366852 \cdot 10^{-11} - im \cdot im}{im + -3.814697265625 \cdot 10^{-6}}\\ \end{array} \]

Alternative 12: 37.3% accurate, 27.8× speedup?

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

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

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

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


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

    1. Initial program 50.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.99999999999999952e166 < re < 1.4499999999999999e273

    1. Initial program 57.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.4499999999999999e273 < re

    1. Initial program 59.0%

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

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

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

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

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

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

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

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

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

Alternative 13: 35.0% accurate, 33.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -600 \lor \neg \left(im \leq 24000000000\right):\\
\;\;\;\;\left(re \cdot re\right) \cdot 0.75\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -600 < im < 2.4e10

    1. Initial program 11.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -600 \lor \neg \left(im \leq 24000000000\right):\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]

Alternative 14: 34.5% accurate, 33.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -8 \cdot 10^{+160}:\\
\;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\

\mathbf{elif}\;re \leq 7.8 \cdot 10^{+167}:\\
\;\;\;\;-im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if re < -8.00000000000000005e160

    1. Initial program 54.6%

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

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

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

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

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

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

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

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

    if -8.00000000000000005e160 < re < 7.7999999999999996e167

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-im} \]
    10. Simplified39.2%

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

    if 7.7999999999999996e167 < re

    1. Initial program 61.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -8 \cdot 10^{+160}:\\ \;\;\;\;13.5 + \left(re \cdot re\right) \cdot -6.75\\ \mathbf{elif}\;re \leq 7.8 \cdot 10^{+167}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot 0.75\\ \end{array} \]

Alternative 15: 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 51.7%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-im} \]
  11. Final simplification33.0%

    \[\leadsto -im \]

Alternative 16: 2.9% accurate, 309.0× speedup?

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

\\
-1.5
\end{array}
Derivation
  1. Initial program 51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -1.5 \]

Alternative 17: 2.8% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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