math.sin on complex, imaginary part

Percentage Accurate: 53.7% → 99.9%
Time: 20.3s
Alternatives: 15
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 15 alternatives:

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

Initial Program: 53.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

    if -1 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 0.050000000000000003

    1. Initial program 9.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.9% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

    if -1 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 0.050000000000000003

    1. Initial program 9.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -1 \lor \neg \left(e^{-im} - e^{im} \leq 0.05\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im \cdot -2 + \left({im}^{5} \cdot -0.016666666666666666 + {im}^{3} \cdot -0.3333333333333333\right)\right)\\ \end{array} \]

Alternative 3: 99.8% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

    if -1 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 5.0000000000000001e-4

    1. Initial program 9.0%

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

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

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

      \[\leadsto \color{blue}{-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.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -1 \lor \neg \left(e^{-im} - e^{im} \leq 0.0005\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 4: 94.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -3.5 \cdot 10^{+155} \lor \neg \left(im \leq -0.19\right) \land \left(im \leq 0.66 \lor \neg \left(im \leq 1.65 \cdot 10^{+100}\right)\right):\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -3.5e+155)
         (and (not (<= im -0.19)) (or (<= im 0.66) (not (<= im 1.65e+100)))))
   (* (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 <= -3.5e+155) || (!(im <= -0.19) && ((im <= 0.66) || !(im <= 1.65e+100)))) {
		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 <= (-3.5d+155)) .or. (.not. (im <= (-0.19d0))) .and. (im <= 0.66d0) .or. (.not. (im <= 1.65d+100))) 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 <= -3.5e+155) || (!(im <= -0.19) && ((im <= 0.66) || !(im <= 1.65e+100)))) {
		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 <= -3.5e+155) or (not (im <= -0.19) and ((im <= 0.66) or not (im <= 1.65e+100))):
		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 <= -3.5e+155) || (!(im <= -0.19) && ((im <= 0.66) || !(im <= 1.65e+100))))
		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 <= -3.5e+155) || (~((im <= -0.19)) && ((im <= 0.66) || ~((im <= 1.65e+100)))))
		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, -3.5e+155], And[N[Not[LessEqual[im, -0.19]], $MachinePrecision], Or[LessEqual[im, 0.66], N[Not[LessEqual[im, 1.65e+100]], $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 -3.5 \cdot 10^{+155} \lor \neg \left(im \leq -0.19\right) \land \left(im \leq 0.66 \lor \neg \left(im \leq 1.65 \cdot 10^{+100}\right)\right):\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -3.49999999999999985e155 or -0.19 < im < 0.660000000000000031 or 1.6500000000000001e100 < im

    1. Initial program 45.6%

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

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

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

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

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

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

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

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

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

    if -3.49999999999999985e155 < im < -0.19 or 0.660000000000000031 < im < 1.6500000000000001e100

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

\mathbf{elif}\;im \leq 0.66 \lor \neg \left(im \leq 1.65 \cdot 10^{+100}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -6.4999999999999998e80 or -0.599999999999999978 < im < 0.660000000000000031 or 1.6500000000000001e100 < im

    1. Initial program 48.8%

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

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

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

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

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

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

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

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

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

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

    if -6.4999999999999998e80 < im < -0.599999999999999978

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.660000000000000031 < im < 1.6500000000000001e100

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.5 \cdot 10^{+80}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq -0.6:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{elif}\;im \leq 0.66 \lor \neg \left(im \leq 1.65 \cdot 10^{+100}\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 6: 87.2% 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.027:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.66:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.65 \cdot 10^{+100}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (- (exp (- im)) (exp im)))))
   (if (<= im -0.027)
     t_0
     (if (<= im 0.66)
       (* (cos re) (- im))
       (if (<= im 1.65e+100)
         t_0
         (*
          (- (* (pow im 3.0) -0.16666666666666666) im)
          (+ (* -0.5 (* re re)) 1.0)))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double tmp;
	if (im <= -0.027) {
		tmp = t_0;
	} else if (im <= 0.66) {
		tmp = cos(re) * -im;
	} else if (im <= 1.65e+100) {
		tmp = t_0;
	} else {
		tmp = ((pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 0.5d0 * (exp(-im) - exp(im))
    if (im <= (-0.027d0)) then
        tmp = t_0
    else if (im <= 0.66d0) then
        tmp = cos(re) * -im
    else if (im <= 1.65d+100) then
        tmp = t_0
    else
        tmp = (((im ** 3.0d0) * (-0.16666666666666666d0)) - im) * (((-0.5d0) * (re * re)) + 1.0d0)
    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.027) {
		tmp = t_0;
	} else if (im <= 0.66) {
		tmp = Math.cos(re) * -im;
	} else if (im <= 1.65e+100) {
		tmp = t_0;
	} else {
		tmp = ((Math.pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * (math.exp(-im) - math.exp(im))
	tmp = 0
	if im <= -0.027:
		tmp = t_0
	elif im <= 0.66:
		tmp = math.cos(re) * -im
	elif im <= 1.65e+100:
		tmp = t_0
	else:
		tmp = ((math.pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0)
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	tmp = 0.0
	if (im <= -0.027)
		tmp = t_0;
	elseif (im <= 0.66)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 1.65e+100)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) * Float64(Float64(-0.5 * Float64(re * re)) + 1.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * (exp(-im) - exp(im));
	tmp = 0.0;
	if (im <= -0.027)
		tmp = t_0;
	elseif (im <= 0.66)
		tmp = cos(re) * -im;
	elseif (im <= 1.65e+100)
		tmp = t_0;
	else
		tmp = (((im ^ 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	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.027], t$95$0, If[LessEqual[im, 0.66], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1.65e+100], t$95$0, N[(N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision] * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 1.65 \cdot 10^{+100}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -0.0269999999999999997 or 0.660000000000000031 < im < 1.6500000000000001e100

    1. Initial program 100.0%

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

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

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

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

    if -0.0269999999999999997 < im < 0.660000000000000031

    1. Initial program 10.4%

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

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

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

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

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

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

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

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

    if 1.6500000000000001e100 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -0.027:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.66:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.65 \cdot 10^{+100}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \end{array} \]

Alternative 7: 79.6% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -7.5 \cdot 10^{+38}:\\ \;\;\;\;0.5 \cdot \left(im \cdot -2 + {im}^{5} \cdot -0.016666666666666666\right)\\ \mathbf{elif}\;im \leq 2.45 \cdot 10^{+31}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -7.5e+38)
   (* 0.5 (+ (* im -2.0) (* (pow im 5.0) -0.016666666666666666)))
   (if (<= im 2.45e+31)
     (* (cos re) (- im))
     (*
      (- (* (pow im 3.0) -0.16666666666666666) im)
      (+ (* -0.5 (* re re)) 1.0)))))
double code(double re, double im) {
	double tmp;
	if (im <= -7.5e+38) {
		tmp = 0.5 * ((im * -2.0) + (pow(im, 5.0) * -0.016666666666666666));
	} else if (im <= 2.45e+31) {
		tmp = cos(re) * -im;
	} else {
		tmp = ((pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= (-7.5d+38)) then
        tmp = 0.5d0 * ((im * (-2.0d0)) + ((im ** 5.0d0) * (-0.016666666666666666d0)))
    else if (im <= 2.45d+31) then
        tmp = cos(re) * -im
    else
        tmp = (((im ** 3.0d0) * (-0.16666666666666666d0)) - im) * (((-0.5d0) * (re * re)) + 1.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -7.5e+38) {
		tmp = 0.5 * ((im * -2.0) + (Math.pow(im, 5.0) * -0.016666666666666666));
	} else if (im <= 2.45e+31) {
		tmp = Math.cos(re) * -im;
	} else {
		tmp = ((Math.pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -7.5e+38:
		tmp = 0.5 * ((im * -2.0) + (math.pow(im, 5.0) * -0.016666666666666666))
	elif im <= 2.45e+31:
		tmp = math.cos(re) * -im
	else:
		tmp = ((math.pow(im, 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -7.5e+38)
		tmp = Float64(0.5 * Float64(Float64(im * -2.0) + Float64((im ^ 5.0) * -0.016666666666666666)));
	elseif (im <= 2.45e+31)
		tmp = Float64(cos(re) * Float64(-im));
	else
		tmp = Float64(Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im) * Float64(Float64(-0.5 * Float64(re * re)) + 1.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -7.5e+38)
		tmp = 0.5 * ((im * -2.0) + ((im ^ 5.0) * -0.016666666666666666));
	elseif (im <= 2.45e+31)
		tmp = cos(re) * -im;
	else
		tmp = (((im ^ 3.0) * -0.16666666666666666) - im) * ((-0.5 * (re * re)) + 1.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -7.5e+38], N[(0.5 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.45e+31], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision] * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

    if -7.4999999999999999e38 < im < 2.44999999999999998e31

    1. Initial program 18.7%

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

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

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

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

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

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

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

    if 2.44999999999999998e31 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.5 \cdot 10^{+38}:\\ \;\;\;\;0.5 \cdot \left(im \cdot -2 + {im}^{5} \cdot -0.016666666666666666\right)\\ \mathbf{elif}\;im \leq 2.45 \cdot 10^{+31}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \end{array} \]

Alternative 8: 73.2% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{if}\;im \leq -1.35 \cdot 10^{+48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 2.45 \cdot 10^{+31}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+106} \lor \neg \left(im \leq 5.4 \cdot 10^{+188}\right) \land im \leq 3.3 \cdot 10^{+274}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im)))
   (if (<= im -1.35e+48)
     t_0
     (if (<= im 2.45e+31)
       (* (cos re) (- im))
       (if (or (<= im 1.6e+106) (and (not (<= im 5.4e+188)) (<= im 3.3e+274)))
         (- (* 0.5 (* re (* im re))) im)
         t_0)))))
double code(double re, double im) {
	double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double tmp;
	if (im <= -1.35e+48) {
		tmp = t_0;
	} else if (im <= 2.45e+31) {
		tmp = cos(re) * -im;
	} else if ((im <= 1.6e+106) || (!(im <= 5.4e+188) && (im <= 3.3e+274))) {
		tmp = (0.5 * (re * (im * re))) - im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
    if (im <= (-1.35d+48)) then
        tmp = t_0
    else if (im <= 2.45d+31) then
        tmp = cos(re) * -im
    else if ((im <= 1.6d+106) .or. (.not. (im <= 5.4d+188)) .and. (im <= 3.3d+274)) then
        tmp = (0.5d0 * (re * (im * re))) - im
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
	double tmp;
	if (im <= -1.35e+48) {
		tmp = t_0;
	} else if (im <= 2.45e+31) {
		tmp = Math.cos(re) * -im;
	} else if ((im <= 1.6e+106) || (!(im <= 5.4e+188) && (im <= 3.3e+274))) {
		tmp = (0.5 * (re * (im * re))) - im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im
	tmp = 0
	if im <= -1.35e+48:
		tmp = t_0
	elif im <= 2.45e+31:
		tmp = math.cos(re) * -im
	elif (im <= 1.6e+106) or (not (im <= 5.4e+188) and (im <= 3.3e+274)):
		tmp = (0.5 * (re * (im * re))) - im
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	tmp = 0.0
	if (im <= -1.35e+48)
		tmp = t_0;
	elseif (im <= 2.45e+31)
		tmp = Float64(cos(re) * Float64(-im));
	elseif ((im <= 1.6e+106) || (!(im <= 5.4e+188) && (im <= 3.3e+274)))
		tmp = Float64(Float64(0.5 * Float64(re * Float64(im * re))) - im);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = ((im ^ 3.0) * -0.16666666666666666) - im;
	tmp = 0.0;
	if (im <= -1.35e+48)
		tmp = t_0;
	elseif (im <= 2.45e+31)
		tmp = cos(re) * -im;
	elseif ((im <= 1.6e+106) || (~((im <= 5.4e+188)) && (im <= 3.3e+274)))
		tmp = (0.5 * (re * (im * re))) - im;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, If[LessEqual[im, -1.35e+48], t$95$0, If[LessEqual[im, 2.45e+31], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[Or[LessEqual[im, 1.6e+106], And[N[Not[LessEqual[im, 5.4e+188]], $MachinePrecision], LessEqual[im, 3.3e+274]]], N[(N[(0.5 * N[(re * N[(im * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 1.6 \cdot 10^{+106} \lor \neg \left(im \leq 5.4 \cdot 10^{+188}\right) \land im \leq 3.3 \cdot 10^{+274}:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.35000000000000002e48 or 1.5999999999999999e106 < im < 5.4e188 or 3.30000000000000014e274 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -1.35000000000000002e48 < im < 2.44999999999999998e31

    1. Initial program 18.7%

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

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

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

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

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

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

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

    if 2.44999999999999998e31 < im < 1.5999999999999999e106 or 5.4e188 < im < 3.30000000000000014e274

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.35 \cdot 10^{+48}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 2.45 \cdot 10^{+31}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+106} \lor \neg \left(im \leq 5.4 \cdot 10^{+188}\right) \land im \leq 3.3 \cdot 10^{+274}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 9: 77.3% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(im \cdot -2 + {im}^{5} \cdot -0.016666666666666666\right)\\
\mathbf{if}\;im \leq -1 \cdot 10^{+39}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;im \leq 5.4 \cdot 10^{+188}:\\
\;\;\;\;t_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -9.9999999999999994e38 or 29 < im < 5.4e188

    1. Initial program 100.0%

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

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

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

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

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

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

    if -9.9999999999999994e38 < im < 29

    1. Initial program 15.1%

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

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

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

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

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

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

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

    if 5.4e188 < im < 3.4999999999999996e274

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.4999999999999996e274 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1 \cdot 10^{+39}:\\ \;\;\;\;0.5 \cdot \left(im \cdot -2 + {im}^{5} \cdot -0.016666666666666666\right)\\ \mathbf{elif}\;im \leq 29:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 5.4 \cdot 10^{+188}:\\ \;\;\;\;0.5 \cdot \left(im \cdot -2 + {im}^{5} \cdot -0.016666666666666666\right)\\ \mathbf{elif}\;im \leq 3.5 \cdot 10^{+274}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 10: 79.6% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -1.8 \cdot 10^{+48}:\\ \;\;\;\;0.5 \cdot \left(im \cdot -2 + {im}^{5} \cdot -0.016666666666666666\right)\\ \mathbf{elif}\;im \leq 2.6 \cdot 10^{+31}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -1.8e+48)
   (* 0.5 (+ (* im -2.0) (* (pow im 5.0) -0.016666666666666666)))
   (if (<= im 2.6e+31)
     (* (cos re) (- im))
     (* (* (pow im 3.0) -0.16666666666666666) (+ (* -0.5 (* re re)) 1.0)))))
double code(double re, double im) {
	double tmp;
	if (im <= -1.8e+48) {
		tmp = 0.5 * ((im * -2.0) + (pow(im, 5.0) * -0.016666666666666666));
	} else if (im <= 2.6e+31) {
		tmp = cos(re) * -im;
	} else {
		tmp = (pow(im, 3.0) * -0.16666666666666666) * ((-0.5 * (re * re)) + 1.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= (-1.8d+48)) then
        tmp = 0.5d0 * ((im * (-2.0d0)) + ((im ** 5.0d0) * (-0.016666666666666666d0)))
    else if (im <= 2.6d+31) then
        tmp = cos(re) * -im
    else
        tmp = ((im ** 3.0d0) * (-0.16666666666666666d0)) * (((-0.5d0) * (re * re)) + 1.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= -1.8e+48) {
		tmp = 0.5 * ((im * -2.0) + (Math.pow(im, 5.0) * -0.016666666666666666));
	} else if (im <= 2.6e+31) {
		tmp = Math.cos(re) * -im;
	} else {
		tmp = (Math.pow(im, 3.0) * -0.16666666666666666) * ((-0.5 * (re * re)) + 1.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= -1.8e+48:
		tmp = 0.5 * ((im * -2.0) + (math.pow(im, 5.0) * -0.016666666666666666))
	elif im <= 2.6e+31:
		tmp = math.cos(re) * -im
	else:
		tmp = (math.pow(im, 3.0) * -0.16666666666666666) * ((-0.5 * (re * re)) + 1.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= -1.8e+48)
		tmp = Float64(0.5 * Float64(Float64(im * -2.0) + Float64((im ^ 5.0) * -0.016666666666666666)));
	elseif (im <= 2.6e+31)
		tmp = Float64(cos(re) * Float64(-im));
	else
		tmp = Float64(Float64((im ^ 3.0) * -0.16666666666666666) * Float64(Float64(-0.5 * Float64(re * re)) + 1.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= -1.8e+48)
		tmp = 0.5 * ((im * -2.0) + ((im ^ 5.0) * -0.016666666666666666));
	elseif (im <= 2.6e+31)
		tmp = cos(re) * -im;
	else
		tmp = ((im ^ 3.0) * -0.16666666666666666) * ((-0.5 * (re * re)) + 1.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, -1.8e+48], N[(0.5 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.6e+31], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] * N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

    if -1.79999999999999992e48 < im < 2.6e31

    1. Initial program 18.7%

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

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

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

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

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

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

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

    if 2.6e31 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.8 \cdot 10^{+48}:\\ \;\;\;\;0.5 \cdot \left(im \cdot -2 + {im}^{5} \cdot -0.016666666666666666\right)\\ \mathbf{elif}\;im \leq 2.6 \cdot 10^{+31}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;\left({im}^{3} \cdot -0.16666666666666666\right) \cdot \left(-0.5 \cdot \left(re \cdot re\right) + 1\right)\\ \end{array} \]

Alternative 11: 62.2% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(re \cdot re\right) \cdot \left(\left(im \cdot -2\right) \cdot -0.25\right)\\ t_1 := \frac{im \cdot im - t_0 \cdot t_0}{\left(-im\right) - t_0}\\ \mathbf{if}\;im \leq -1.3 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 3.1 \cdot 10^{+31}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 6.8 \cdot 10^{+135} \lor \neg \left(im \leq 5 \cdot 10^{+188}\right):\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* re re) (* (* im -2.0) -0.25)))
        (t_1 (/ (- (* im im) (* t_0 t_0)) (- (- im) t_0))))
   (if (<= im -1.3e+154)
     t_1
     (if (<= im 3.1e+31)
       (* (cos re) (- im))
       (if (or (<= im 6.8e+135) (not (<= im 5e+188)))
         (- (* 0.5 (* re (* im re))) im)
         t_1)))))
double code(double re, double im) {
	double t_0 = (re * re) * ((im * -2.0) * -0.25);
	double t_1 = ((im * im) - (t_0 * t_0)) / (-im - t_0);
	double tmp;
	if (im <= -1.3e+154) {
		tmp = t_1;
	} else if (im <= 3.1e+31) {
		tmp = cos(re) * -im;
	} else if ((im <= 6.8e+135) || !(im <= 5e+188)) {
		tmp = (0.5 * (re * (im * re))) - im;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (re * re) * ((im * (-2.0d0)) * (-0.25d0))
    t_1 = ((im * im) - (t_0 * t_0)) / (-im - t_0)
    if (im <= (-1.3d+154)) then
        tmp = t_1
    else if (im <= 3.1d+31) then
        tmp = cos(re) * -im
    else if ((im <= 6.8d+135) .or. (.not. (im <= 5d+188))) then
        tmp = (0.5d0 * (re * (im * re))) - im
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (re * re) * ((im * -2.0) * -0.25);
	double t_1 = ((im * im) - (t_0 * t_0)) / (-im - t_0);
	double tmp;
	if (im <= -1.3e+154) {
		tmp = t_1;
	} else if (im <= 3.1e+31) {
		tmp = Math.cos(re) * -im;
	} else if ((im <= 6.8e+135) || !(im <= 5e+188)) {
		tmp = (0.5 * (re * (im * re))) - im;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = (re * re) * ((im * -2.0) * -0.25)
	t_1 = ((im * im) - (t_0 * t_0)) / (-im - t_0)
	tmp = 0
	if im <= -1.3e+154:
		tmp = t_1
	elif im <= 3.1e+31:
		tmp = math.cos(re) * -im
	elif (im <= 6.8e+135) or not (im <= 5e+188):
		tmp = (0.5 * (re * (im * re))) - im
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(re * re) * Float64(Float64(im * -2.0) * -0.25))
	t_1 = Float64(Float64(Float64(im * im) - Float64(t_0 * t_0)) / Float64(Float64(-im) - t_0))
	tmp = 0.0
	if (im <= -1.3e+154)
		tmp = t_1;
	elseif (im <= 3.1e+31)
		tmp = Float64(cos(re) * Float64(-im));
	elseif ((im <= 6.8e+135) || !(im <= 5e+188))
		tmp = Float64(Float64(0.5 * Float64(re * Float64(im * re))) - im);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (re * re) * ((im * -2.0) * -0.25);
	t_1 = ((im * im) - (t_0 * t_0)) / (-im - t_0);
	tmp = 0.0;
	if (im <= -1.3e+154)
		tmp = t_1;
	elseif (im <= 3.1e+31)
		tmp = cos(re) * -im;
	elseif ((im <= 6.8e+135) || ~((im <= 5e+188)))
		tmp = (0.5 * (re * (im * re))) - im;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(re * re), $MachinePrecision] * N[(N[(im * -2.0), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(im * im), $MachinePrecision] - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[((-im) - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.3e+154], t$95$1, If[LessEqual[im, 3.1e+31], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[Or[LessEqual[im, 6.8e+135], N[Not[LessEqual[im, 5e+188]], $MachinePrecision]], N[(N[(0.5 * N[(re * N[(im * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(re \cdot re\right) \cdot \left(\left(im \cdot -2\right) \cdot -0.25\right)\\
t_1 := \frac{im \cdot im - t_0 \cdot t_0}{\left(-im\right) - t_0}\\
\mathbf{if}\;im \leq -1.3 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 6.8 \cdot 10^{+135} \lor \neg \left(im \leq 5 \cdot 10^{+188}\right):\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.29999999999999994e154 or 6.80000000000000019e135 < im < 5.0000000000000001e188

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(\left(-2 \cdot im\right) \cdot 0.5\right) \cdot \left(\left(-2 \cdot im\right) \cdot 0.5\right) - \left(\left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(\left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{\left(-2 \cdot im\right) \cdot 0.5 - \left(-2 \cdot im\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)}} \]
    9. Applied egg-rr48.8%

      \[\leadsto \color{blue}{\frac{\left(im \cdot -1\right) \cdot \left(im \cdot -1\right) - \left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot \left(im \cdot -2\right)\right)\right) \cdot \left(\left(re \cdot re\right) \cdot \left(-0.25 \cdot \left(im \cdot -2\right)\right)\right)}{im \cdot -1 - \left(re \cdot re\right) \cdot \left(-0.25 \cdot \left(im \cdot -2\right)\right)}} \]

    if -1.29999999999999994e154 < im < 3.1000000000000002e31

    1. Initial program 27.5%

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

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

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

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

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

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

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

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

    if 3.1000000000000002e31 < im < 6.80000000000000019e135 or 5.0000000000000001e188 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.3 \cdot 10^{+154}:\\ \;\;\;\;\frac{im \cdot im - \left(\left(re \cdot re\right) \cdot \left(\left(im \cdot -2\right) \cdot -0.25\right)\right) \cdot \left(\left(re \cdot re\right) \cdot \left(\left(im \cdot -2\right) \cdot -0.25\right)\right)}{\left(-im\right) - \left(re \cdot re\right) \cdot \left(\left(im \cdot -2\right) \cdot -0.25\right)}\\ \mathbf{elif}\;im \leq 3.1 \cdot 10^{+31}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 6.8 \cdot 10^{+135} \lor \neg \left(im \leq 5 \cdot 10^{+188}\right):\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;\frac{im \cdot im - \left(\left(re \cdot re\right) \cdot \left(\left(im \cdot -2\right) \cdot -0.25\right)\right) \cdot \left(\left(re \cdot re\right) \cdot \left(\left(im \cdot -2\right) \cdot -0.25\right)\right)}{\left(-im\right) - \left(re \cdot re\right) \cdot \left(\left(im \cdot -2\right) \cdot -0.25\right)}\\ \end{array} \]

Alternative 12: 33.7% accurate, 23.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 720000:\\ \;\;\;\;-im\\ \mathbf{elif}\;re \leq 7 \cdot 10^{+185}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right)\\ \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 720000.0)
   (- im)
   (if (<= re 7e+185)
     (* im (* re (* 0.5 re)))
     (* (+ 0.5 (* re (* re -0.25))) -3.0))))
double code(double re, double im) {
	double tmp;
	if (re <= 720000.0) {
		tmp = -im;
	} else if (re <= 7e+185) {
		tmp = im * (re * (0.5 * re));
	} 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 <= 720000.0d0) then
        tmp = -im
    else if (re <= 7d+185) then
        tmp = im * (re * (0.5d0 * re))
    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 <= 720000.0) {
		tmp = -im;
	} else if (re <= 7e+185) {
		tmp = im * (re * (0.5 * re));
	} else {
		tmp = (0.5 + (re * (re * -0.25))) * -3.0;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 720000.0:
		tmp = -im
	elif re <= 7e+185:
		tmp = im * (re * (0.5 * re))
	else:
		tmp = (0.5 + (re * (re * -0.25))) * -3.0
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 720000.0)
		tmp = Float64(-im);
	elseif (re <= 7e+185)
		tmp = Float64(im * Float64(re * Float64(0.5 * re)));
	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 <= 720000.0)
		tmp = -im;
	elseif (re <= 7e+185)
		tmp = im * (re * (0.5 * re));
	else
		tmp = (0.5 + (re * (re * -0.25))) * -3.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 720000.0], (-im), If[LessEqual[re, 7e+185], N[(im * N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]), $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 720000:\\
\;\;\;\;-im\\

\mathbf{elif}\;re \leq 7 \cdot 10^{+185}:\\
\;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right)\\

\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 < 7.2e5

    1. Initial program 54.2%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-im} \]
    9. Simplified35.1%

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

    if 7.2e5 < re < 7.00000000000000046e185

    1. Initial program 60.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right)} \]
    9. Step-by-step derivation
      1. associate-*r*28.9%

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

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

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

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

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

    if 7.00000000000000046e185 < re

    1. Initial program 58.7%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 720000:\\ \;\;\;\;-im\\ \mathbf{elif}\;re \leq 7 \cdot 10^{+185}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\\ \end{array} \]

Alternative 13: 37.8% accurate, 27.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -8500000 \lor \neg \left(im \leq 2.8 \cdot 10^{+31}\right):\\
\;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -8.5e6 or 2.80000000000000017e31 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left({re}^{2} \cdot im\right)} \]
    9. Step-by-step derivation
      1. associate-*r*28.0%

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

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

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

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

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

    if -8.5e6 < im < 2.80000000000000017e31

    1. Initial program 15.7%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-im} \]
    9. Simplified50.1%

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

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

Alternative 14: 36.8% accurate, 27.9× speedup?

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

\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 2 regimes
  2. if re < 7.00000000000000046e185

    1. Initial program 55.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.00000000000000046e185 < re

    1. Initial program 58.7%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 7 \cdot 10^{+185}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\\ \end{array} \]

Alternative 15: 30.8% accurate, 154.5× speedup?

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

\\
-im
\end{array}
Derivation
  1. Initial program 55.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -im \]

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