math.sin on complex, imaginary part

Percentage Accurate: 52.8% → 99.8%
Time: 8.9s
Alternatives: 16
Speedup: 2.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 16 alternatives:

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

Initial Program: 52.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 8.0%

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in im around 0 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.2 \lor \neg \left(e^{-im} - e^{im} \leq 10^{-7}\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.4% 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 -6.8 \cdot 10^{+95}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.0225:\\ \;\;\;\;0.5 \cdot t_0\\ \mathbf{elif}\;im \leq 0.043 \lor \neg \left(im \leq 5.8 \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 -6.8e+95)
     t_1
     (if (<= im -0.0225)
       (* 0.5 t_0)
       (if (or (<= im 0.043) (not (<= im 5.8e+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 <= -6.8e+95) {
		tmp = t_1;
	} else if (im <= -0.0225) {
		tmp = 0.5 * t_0;
	} else if ((im <= 0.043) || !(im <= 5.8e+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 <= (-6.8d+95)) then
        tmp = t_1
    else if (im <= (-0.0225d0)) then
        tmp = 0.5d0 * t_0
    else if ((im <= 0.043d0) .or. (.not. (im <= 5.8d+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 <= -6.8e+95) {
		tmp = t_1;
	} else if (im <= -0.0225) {
		tmp = 0.5 * t_0;
	} else if ((im <= 0.043) || !(im <= 5.8e+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 <= -6.8e+95:
		tmp = t_1
	elif im <= -0.0225:
		tmp = 0.5 * t_0
	elif (im <= 0.043) or not (im <= 5.8e+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 <= -6.8e+95)
		tmp = t_1;
	elseif (im <= -0.0225)
		tmp = Float64(0.5 * t_0);
	elseif ((im <= 0.043) || !(im <= 5.8e+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 <= -6.8e+95)
		tmp = t_1;
	elseif (im <= -0.0225)
		tmp = 0.5 * t_0;
	elseif ((im <= 0.043) || ~((im <= 5.8e+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, -6.8e+95], t$95$1, If[LessEqual[im, -0.0225], N[(0.5 * t$95$0), $MachinePrecision], If[Or[LessEqual[im, 0.043], N[Not[LessEqual[im, 5.8e+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 -6.8 \cdot 10^{+95}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 0.043 \lor \neg \left(im \leq 5.8 \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 < -6.80000000000000043e95 or -0.022499999999999999 < im < 0.042999999999999997 or 5.8000000000000005e102 < im

    1. Initial program 46.4%

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

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

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

      \[\leadsto \color{blue}{-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 -6.80000000000000043e95 < im < -0.022499999999999999

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

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

    if 0.042999999999999997 < im < 5.8000000000000005e102

    1. Initial program 99.8%

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    4. Taylor expanded in re around 0 7.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. *-commutative7.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*7.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-out92.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.8 \cdot 10^{+95}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq -0.0225:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.043 \lor \neg \left(im \leq 5.8 \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: 95.2% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -6.8 \cdot 10^{+95} \lor \neg \left(im \leq -0.04 \lor \neg \left(im \leq 0.016\right) \land im \leq 5.8 \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 -6.8e+95)
         (not (or (<= im -0.04) (and (not (<= im 0.016)) (<= im 5.8e+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 <= -6.8e+95) || !((im <= -0.04) || (!(im <= 0.016) && (im <= 5.8e+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 <= (-6.8d+95)) .or. (.not. (im <= (-0.04d0)) .or. (.not. (im <= 0.016d0)) .and. (im <= 5.8d+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 <= -6.8e+95) || !((im <= -0.04) || (!(im <= 0.016) && (im <= 5.8e+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 <= -6.8e+95) or not ((im <= -0.04) or (not (im <= 0.016) and (im <= 5.8e+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 <= -6.8e+95) || !((im <= -0.04) || (!(im <= 0.016) && (im <= 5.8e+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 <= -6.8e+95) || ~(((im <= -0.04) || (~((im <= 0.016)) && (im <= 5.8e+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, -6.8e+95], N[Not[Or[LessEqual[im, -0.04], And[N[Not[LessEqual[im, 0.016]], $MachinePrecision], LessEqual[im, 5.8e+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 -6.8 \cdot 10^{+95} \lor \neg \left(im \leq -0.04 \lor \neg \left(im \leq 0.016\right) \land im \leq 5.8 \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 < -6.80000000000000043e95 or -0.0400000000000000008 < im < 0.016 or 5.8000000000000005e102 < im

    1. Initial program 46.4%

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

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

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

      \[\leadsto \color{blue}{-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 -6.80000000000000043e95 < im < -0.0400000000000000008 or 0.016 < im < 5.8000000000000005e102

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.8 \cdot 10^{+95} \lor \neg \left(im \leq -0.04 \lor \neg \left(im \leq 0.016\right) \land im \leq 5.8 \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: 89.7% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{if}\;im \leq -0.0004:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 4.7 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+150}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (- (exp (- im)) (exp im)))))
   (if (<= im -0.0004)
     t_0
     (if (<= im 4.7e-5)
       (* im (- (cos re)))
       (if (<= im 1.8e+150)
         t_0
         (/
          (* (cos re) (- 5.960464477539063e-8 (* im im)))
          (+ im 0.000244140625)))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double tmp;
	if (im <= -0.0004) {
		tmp = t_0;
	} else if (im <= 4.7e-5) {
		tmp = im * -cos(re);
	} else if (im <= 1.8e+150) {
		tmp = t_0;
	} else {
		tmp = (cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 0.5d0 * (exp(-im) - exp(im))
    if (im <= (-0.0004d0)) then
        tmp = t_0
    else if (im <= 4.7d-5) then
        tmp = im * -cos(re)
    else if (im <= 1.8d+150) then
        tmp = t_0
    else
        tmp = (cos(re) * (5.960464477539063d-8 - (im * im))) / (im + 0.000244140625d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
	double tmp;
	if (im <= -0.0004) {
		tmp = t_0;
	} else if (im <= 4.7e-5) {
		tmp = im * -Math.cos(re);
	} else if (im <= 1.8e+150) {
		tmp = t_0;
	} else {
		tmp = (Math.cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625);
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * (math.exp(-im) - math.exp(im))
	tmp = 0
	if im <= -0.0004:
		tmp = t_0
	elif im <= 4.7e-5:
		tmp = im * -math.cos(re)
	elif im <= 1.8e+150:
		tmp = t_0
	else:
		tmp = (math.cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625)
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	tmp = 0.0
	if (im <= -0.0004)
		tmp = t_0;
	elseif (im <= 4.7e-5)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 1.8e+150)
		tmp = t_0;
	else
		tmp = Float64(Float64(cos(re) * Float64(5.960464477539063e-8 - Float64(im * im))) / Float64(im + 0.000244140625));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * (exp(-im) - exp(im));
	tmp = 0.0;
	if (im <= -0.0004)
		tmp = t_0;
	elseif (im <= 4.7e-5)
		tmp = im * -cos(re);
	elseif (im <= 1.8e+150)
		tmp = t_0;
	else
		tmp = (cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -0.0004], t$95$0, If[LessEqual[im, 4.7e-5], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.8e+150], t$95$0, N[(N[(N[Cos[re], $MachinePrecision] * N[(5.960464477539063e-8 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + 0.000244140625), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4.00000000000000019e-4 or 4.69999999999999972e-5 < im < 1.79999999999999993e150

    1. Initial program 99.8%

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

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

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

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

    if -4.00000000000000019e-4 < im < 4.69999999999999972e-5

    1. Initial program 7.4%

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

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

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

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

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

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

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

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

    if 1.79999999999999993e150 < 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.5%

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

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

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

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

        \[\leadsto \frac{\left(\color{blue}{5.960464477539063 \cdot 10^{-8}} - im \cdot im\right) \cdot \cos re}{0.000244140625 + im} \]
      5. +-commutative96.8%

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

      \[\leadsto \color{blue}{\frac{\left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right) \cdot \cos re}{im + 0.000244140625}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -0.0004:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 4.7 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+150}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\ \end{array} \]

Alternative 5: 83.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -4 \cdot 10^{+49}:\\ \;\;\;\;\sqrt{{im}^{6} \cdot 0.027777777777777776}\\ \mathbf{elif}\;im \leq 4.7 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -4e+49)
   (sqrt (* (pow im 6.0) 0.027777777777777776))
   (if (<= im 4.7e-5)
     (* im (- (cos re)))
     (if (<= im 1.35e+154)
       (*
        (+ (* -0.5 (* re re)) 1.0)
        (- (* (pow im 3.0) -0.16666666666666666) im))
       (/
        (* (cos re) (- 5.960464477539063e-8 (* im im)))
        (+ im 0.000244140625))))))
double code(double re, double im) {
	double tmp;
	if (im <= -4e+49) {
		tmp = sqrt((pow(im, 6.0) * 0.027777777777777776));
	} else if (im <= 4.7e-5) {
		tmp = im * -cos(re);
	} else if (im <= 1.35e+154) {
		tmp = ((-0.5 * (re * re)) + 1.0) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else {
		tmp = (cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= (-4d+49)) then
        tmp = sqrt(((im ** 6.0d0) * 0.027777777777777776d0))
    else if (im <= 4.7d-5) then
        tmp = im * -cos(re)
    else if (im <= 1.35d+154) then
        tmp = (((-0.5d0) * (re * re)) + 1.0d0) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    else
        tmp = (cos(re) * (5.960464477539063d-8 - (im * im))) / (im + 0.000244140625d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -4e+49) {
		tmp = Math.sqrt((Math.pow(im, 6.0) * 0.027777777777777776));
	} else if (im <= 4.7e-5) {
		tmp = im * -Math.cos(re);
	} else if (im <= 1.35e+154) {
		tmp = ((-0.5 * (re * re)) + 1.0) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else {
		tmp = (Math.cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -4e+49:
		tmp = math.sqrt((math.pow(im, 6.0) * 0.027777777777777776))
	elif im <= 4.7e-5:
		tmp = im * -math.cos(re)
	elif im <= 1.35e+154:
		tmp = ((-0.5 * (re * re)) + 1.0) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	else:
		tmp = (math.cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -4e+49)
		tmp = sqrt(Float64((im ^ 6.0) * 0.027777777777777776));
	elseif (im <= 4.7e-5)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 1.35e+154)
		tmp = Float64(Float64(Float64(-0.5 * Float64(re * re)) + 1.0) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	else
		tmp = Float64(Float64(cos(re) * Float64(5.960464477539063e-8 - Float64(im * im))) / Float64(im + 0.000244140625));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -4e+49)
		tmp = sqrt(((im ^ 6.0) * 0.027777777777777776));
	elseif (im <= 4.7e-5)
		tmp = im * -cos(re);
	elseif (im <= 1.35e+154)
		tmp = ((-0.5 * (re * re)) + 1.0) * (((im ^ 3.0) * -0.16666666666666666) - im);
	else
		tmp = (cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -4e+49], N[Sqrt[N[(N[Power[im, 6.0], $MachinePrecision] * 0.027777777777777776), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 4.7e-5], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[re], $MachinePrecision] * N[(5.960464477539063e-8 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + 0.000244140625), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -4 \cdot 10^{+49}:\\
\;\;\;\;\sqrt{{im}^{6} \cdot 0.027777777777777776}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\


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

    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 80.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-neg80.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt64.0%

        \[\leadsto \color{blue}{\sqrt{-0.16666666666666666 \cdot {im}^{3}} \cdot \sqrt{-0.16666666666666666 \cdot {im}^{3}}} \]
      2. sqrt-unprod79.6%

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

        \[\leadsto \sqrt{\color{blue}{\left({im}^{3} \cdot -0.16666666666666666\right)} \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right)} \]
      4. *-commutative79.6%

        \[\leadsto \sqrt{\left({im}^{3} \cdot -0.16666666666666666\right) \cdot \color{blue}{\left({im}^{3} \cdot -0.16666666666666666\right)}} \]
      5. swap-sqr79.6%

        \[\leadsto \sqrt{\color{blue}{\left({im}^{3} \cdot {im}^{3}\right) \cdot \left(-0.16666666666666666 \cdot -0.16666666666666666\right)}} \]
      6. pow-prod-up79.6%

        \[\leadsto \sqrt{\color{blue}{{im}^{\left(3 + 3\right)}} \cdot \left(-0.16666666666666666 \cdot -0.16666666666666666\right)} \]
      7. metadata-eval79.6%

        \[\leadsto \sqrt{{im}^{\color{blue}{6}} \cdot \left(-0.16666666666666666 \cdot -0.16666666666666666\right)} \]
      8. metadata-eval79.6%

        \[\leadsto \sqrt{{im}^{6} \cdot \color{blue}{0.027777777777777776}} \]
    10. Applied egg-rr79.6%

      \[\leadsto \color{blue}{\sqrt{{im}^{6} \cdot 0.027777777777777776}} \]

    if -3.99999999999999979e49 < im < 4.69999999999999972e-5

    1. Initial program 17.2%

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

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

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

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

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

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

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

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

    if 4.69999999999999972e-5 < im < 1.35000000000000003e154

    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 62.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-neg62.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(\color{blue}{5.960464477539063 \cdot 10^{-8}} - im \cdot im\right) \cdot \cos re}{0.000244140625 + im} \]
      5. +-commutative100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4 \cdot 10^{+49}:\\ \;\;\;\;\sqrt{{im}^{6} \cdot 0.027777777777777776}\\ \mathbf{elif}\;im \leq 4.7 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\ \end{array} \]

Alternative 6: 85.0% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ t_1 := \frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\ \mathbf{if}\;im \leq -4.5 \cdot 10^{+163}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.03:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 4.7 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\cos re\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 (* re re)) 1.0)
          (- (* (pow im 3.0) -0.16666666666666666) im)))
        (t_1
         (/
          (* (cos re) (- 5.960464477539063e-8 (* im im)))
          (+ im 0.000244140625))))
   (if (<= im -4.5e+163)
     t_1
     (if (<= im -0.03)
       t_0
       (if (<= im 4.7e-5)
         (* im (- (cos re)))
         (if (<= im 1.35e+154) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = ((-0.5 * (re * re)) + 1.0) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	double t_1 = (cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625);
	double tmp;
	if (im <= -4.5e+163) {
		tmp = t_1;
	} else if (im <= -0.03) {
		tmp = t_0;
	} else if (im <= 4.7e-5) {
		tmp = im * -cos(re);
	} 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) * (re * re)) + 1.0d0) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    t_1 = (cos(re) * (5.960464477539063d-8 - (im * im))) / (im + 0.000244140625d0)
    if (im <= (-4.5d+163)) then
        tmp = t_1
    else if (im <= (-0.03d0)) then
        tmp = t_0
    else if (im <= 4.7d-5) then
        tmp = im * -cos(re)
    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 * (re * re)) + 1.0) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	double t_1 = (Math.cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625);
	double tmp;
	if (im <= -4.5e+163) {
		tmp = t_1;
	} else if (im <= -0.03) {
		tmp = t_0;
	} else if (im <= 4.7e-5) {
		tmp = im * -Math.cos(re);
	} else if (im <= 1.35e+154) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = ((-0.5 * (re * re)) + 1.0) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	t_1 = (math.cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625)
	tmp = 0
	if im <= -4.5e+163:
		tmp = t_1
	elif im <= -0.03:
		tmp = t_0
	elif im <= 4.7e-5:
		tmp = im * -math.cos(re)
	elif im <= 1.35e+154:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(Float64(-0.5 * Float64(re * re)) + 1.0) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im))
	t_1 = Float64(Float64(cos(re) * Float64(5.960464477539063e-8 - Float64(im * im))) / Float64(im + 0.000244140625))
	tmp = 0.0
	if (im <= -4.5e+163)
		tmp = t_1;
	elseif (im <= -0.03)
		tmp = t_0;
	elseif (im <= 4.7e-5)
		tmp = Float64(im * Float64(-cos(re)));
	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 * (re * re)) + 1.0) * (((im ^ 3.0) * -0.16666666666666666) - im);
	t_1 = (cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625);
	tmp = 0.0;
	if (im <= -4.5e+163)
		tmp = t_1;
	elseif (im <= -0.03)
		tmp = t_0;
	elseif (im <= 4.7e-5)
		tmp = im * -cos(re);
	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[(N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * N[(5.960464477539063e-8 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + 0.000244140625), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.5e+163], t$95$1, If[LessEqual[im, -0.03], t$95$0, If[LessEqual[im, 4.7e-5], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.35e+154], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 4.7 \cdot 10^{-5}:\\
\;\;\;\;im \cdot \left(-\cos re\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 < -4.49999999999999988e163 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.5%

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

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

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

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

        \[\leadsto \frac{\left(\color{blue}{5.960464477539063 \cdot 10^{-8}} - im \cdot im\right) \cdot \cos re}{0.000244140625 + im} \]
      5. +-commutative100.0%

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

      \[\leadsto \color{blue}{\frac{\left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right) \cdot \cos re}{im + 0.000244140625}} \]

    if -4.49999999999999988e163 < im < -0.029999999999999999 or 4.69999999999999972e-5 < im < 1.35000000000000003e154

    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 53.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-neg53.5%

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.029999999999999999 < im < 4.69999999999999972e-5

    1. Initial program 7.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.5 \cdot 10^{+163}:\\ \;\;\;\;\frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\ \mathbf{elif}\;im \leq -0.03:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 4.7 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\ \end{array} \]

Alternative 7: 84.9% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ t_1 := \frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\ \mathbf{if}\;im \leq -4.5 \cdot 10^{+163}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -3.2 \cdot 10^{+18}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 520:\\ \;\;\;\;im \cdot \left(-\cos re\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 (* re re)) 1.0) (* (pow im 3.0) -0.16666666666666666)))
        (t_1
         (/
          (* (cos re) (- 5.960464477539063e-8 (* im im)))
          (+ im 0.000244140625))))
   (if (<= im -4.5e+163)
     t_1
     (if (<= im -3.2e+18)
       t_0
       (if (<= im 520.0)
         (* im (- (cos re)))
         (if (<= im 1.35e+154) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = ((-0.5 * (re * re)) + 1.0) * (pow(im, 3.0) * -0.16666666666666666);
	double t_1 = (cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625);
	double tmp;
	if (im <= -4.5e+163) {
		tmp = t_1;
	} else if (im <= -3.2e+18) {
		tmp = t_0;
	} else if (im <= 520.0) {
		tmp = im * -cos(re);
	} 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) * (re * re)) + 1.0d0) * ((im ** 3.0d0) * (-0.16666666666666666d0))
    t_1 = (cos(re) * (5.960464477539063d-8 - (im * im))) / (im + 0.000244140625d0)
    if (im <= (-4.5d+163)) then
        tmp = t_1
    else if (im <= (-3.2d+18)) then
        tmp = t_0
    else if (im <= 520.0d0) then
        tmp = im * -cos(re)
    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 * (re * re)) + 1.0) * (Math.pow(im, 3.0) * -0.16666666666666666);
	double t_1 = (Math.cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625);
	double tmp;
	if (im <= -4.5e+163) {
		tmp = t_1;
	} else if (im <= -3.2e+18) {
		tmp = t_0;
	} else if (im <= 520.0) {
		tmp = im * -Math.cos(re);
	} else if (im <= 1.35e+154) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = ((-0.5 * (re * re)) + 1.0) * (math.pow(im, 3.0) * -0.16666666666666666)
	t_1 = (math.cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625)
	tmp = 0
	if im <= -4.5e+163:
		tmp = t_1
	elif im <= -3.2e+18:
		tmp = t_0
	elif im <= 520.0:
		tmp = im * -math.cos(re)
	elif im <= 1.35e+154:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(Float64(-0.5 * Float64(re * re)) + 1.0) * Float64((im ^ 3.0) * -0.16666666666666666))
	t_1 = Float64(Float64(cos(re) * Float64(5.960464477539063e-8 - Float64(im * im))) / Float64(im + 0.000244140625))
	tmp = 0.0
	if (im <= -4.5e+163)
		tmp = t_1;
	elseif (im <= -3.2e+18)
		tmp = t_0;
	elseif (im <= 520.0)
		tmp = Float64(im * Float64(-cos(re)));
	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 * (re * re)) + 1.0) * ((im ^ 3.0) * -0.16666666666666666);
	t_1 = (cos(re) * (5.960464477539063e-8 - (im * im))) / (im + 0.000244140625);
	tmp = 0.0;
	if (im <= -4.5e+163)
		tmp = t_1;
	elseif (im <= -3.2e+18)
		tmp = t_0;
	elseif (im <= 520.0)
		tmp = im * -cos(re);
	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[(N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * N[(5.960464477539063e-8 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + 0.000244140625), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.5e+163], t$95$1, If[LessEqual[im, -3.2e+18], t$95$0, If[LessEqual[im, 520.0], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.35e+154], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -3.2 \cdot 10^{+18}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 520:\\
\;\;\;\;im \cdot \left(-\cos re\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 < -4.49999999999999988e163 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.5%

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

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

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

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

        \[\leadsto \frac{\left(\color{blue}{5.960464477539063 \cdot 10^{-8}} - im \cdot im\right) \cdot \cos re}{0.000244140625 + im} \]
      5. +-commutative100.0%

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

      \[\leadsto \color{blue}{\frac{\left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right) \cdot \cos re}{im + 0.000244140625}} \]

    if -4.49999999999999988e163 < im < -3.2e18 or 520 < 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 im around 0 55.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-neg55.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.2e18 < im < 520

    1. Initial program 11.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.5 \cdot 10^{+163}:\\ \;\;\;\;\frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\ \mathbf{elif}\;im \leq -3.2 \cdot 10^{+18}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \mathbf{elif}\;im \leq 520:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\ \end{array} \]

Alternative 8: 78.5% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
\mathbf{if}\;im \leq -0.000225:\\
\;\;\;\;t_0\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.2499999999999999e-4 or 4.69999999999999972e-5 < im < 1.79999999999999993e150

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

    if -2.2499999999999999e-4 < im < 4.69999999999999972e-5

    1. Initial program 7.4%

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

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

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

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

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

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

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

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

    if 1.79999999999999993e150 < 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.5%

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

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

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

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

        \[\leadsto \frac{\left(\color{blue}{5.960464477539063 \cdot 10^{-8}} - im \cdot im\right) \cdot \cos re}{0.000244140625 + im} \]
      5. +-commutative96.8%

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

      \[\leadsto \color{blue}{\frac{\left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right) \cdot \cos re}{im + 0.000244140625}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification80.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -0.000225:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 4.7 \cdot 10^{-5}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+150}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(5.960464477539063 \cdot 10^{-8} - im \cdot im\right)}{im + 0.000244140625}\\ \end{array} \]

Alternative 9: 40.3% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\cos re \leq -0.02:\\ \;\;\;\;\left(im \cdot re\right) \cdot \left(0.5 \cdot re\right) - im\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= (cos re) -0.02) (- (* (* im re) (* 0.5 re)) im) (- im)))
double code(double re, double im) {
	double tmp;
	if (cos(re) <= -0.02) {
		tmp = ((im * re) * (0.5 * re)) - im;
	} else {
		tmp = -im;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (cos(re) <= (-0.02d0)) then
        tmp = ((im * re) * (0.5d0 * re)) - im
    else
        tmp = -im
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (Math.cos(re) <= -0.02) {
		tmp = ((im * re) * (0.5 * re)) - im;
	} else {
		tmp = -im;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if math.cos(re) <= -0.02:
		tmp = ((im * re) * (0.5 * re)) - im
	else:
		tmp = -im
	return tmp
function code(re, im)
	tmp = 0.0
	if (cos(re) <= -0.02)
		tmp = Float64(Float64(Float64(im * re) * Float64(0.5 * re)) - im);
	else
		tmp = Float64(-im);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (cos(re) <= -0.02)
		tmp = ((im * re) * (0.5 * re)) - im;
	else
		tmp = -im;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[N[Cos[re], $MachinePrecision], -0.02], N[(N[(N[(im * re), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], (-im)]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\cos re \leq -0.02:\\
\;\;\;\;\left(im \cdot re\right) \cdot \left(0.5 \cdot re\right) - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 re) < -0.0200000000000000004

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \color{blue}{\left(re \cdot \left(re \cdot 0.5\right)\right)} - im \]
      6. associate-*r*46.8%

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

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

    if -0.0200000000000000004 < (cos.f64 re)

    1. Initial program 52.1%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos re \leq -0.02:\\ \;\;\;\;\left(im \cdot re\right) \cdot \left(0.5 \cdot re\right) - im\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]

Alternative 10: 75.4% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.00165 \lor \neg \left(im \leq 2.3 \cdot 10^{-5}\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -0.00165 or 2.3e-5 < im

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

    if -0.00165 < im < 2.3e-5

    1. Initial program 7.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -0.00165 \lor \neg \left(im \leq 2.3 \cdot 10^{-5}\right):\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 11: 52.4% accurate, 2.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -9.0000000000000004e101 or 2.7999999999999999e70 < 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 98.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-neg98.0%

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

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

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

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

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

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

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

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

    if -9.0000000000000004e101 < im < 2.7999999999999999e70

    1. Initial program 28.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \color{blue}{\left(re \cdot \left(re \cdot 0.5\right)\right)} - im \]
      6. associate-*r*49.2%

        \[\leadsto \color{blue}{\left(im \cdot re\right) \cdot \left(re \cdot 0.5\right)} - im \]
    12. Simplified49.2%

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

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

Alternative 12: 75.5% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.2 \cdot 10^{+50} \lor \neg \left(im \leq 1.7 \cdot 10^{+62}\right):\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -1.2000000000000001e50 or 1.70000000000000007e62 < 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 88.2%

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

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

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

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

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

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

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

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

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

    if -1.2000000000000001e50 < im < 1.70000000000000007e62

    1. Initial program 23.6%

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

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

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

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

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

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

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

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

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

Alternative 13: 32.5% accurate, 23.5× speedup?

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

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

\mathbf{elif}\;re \leq 2.3 \cdot 10^{+201}:\\
\;\;\;\;\left(re \cdot re\right) \cdot -6.75\\

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


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

    1. Initial program 52.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.1999999999999998e153 < re < 2.3000000000000001e201

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.3000000000000001e201 < re

    1. Initial program 63.7%

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

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

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

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

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

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

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

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

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

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

Alternative 14: 32.5% accurate, 43.8× speedup?

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

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

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


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

    1. Initial program 52.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.80000000000000004e153 < re

    1. Initial program 68.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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 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} \\ 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 54.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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