math.sin on complex, imaginary part

Percentage Accurate: 55.2% → 99.3%
Time: 16.3s
Alternatives: 20
Speedup: 2.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 20 alternatives:

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

Initial Program: 55.2% 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.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+15} \lor \neg \left(t_0 \leq 0\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 -1e+15) (not (<= t_0 0.0)))
     (* (* 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 <= -1e+15) || !(t_0 <= 0.0)) {
		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 <= (-1d+15)) .or. (.not. (t_0 <= 0.0d0))) 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 <= -1e+15) || !(t_0 <= 0.0)) {
		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 <= -1e+15) or not (t_0 <= 0.0):
		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 <= -1e+15) || !(t_0 <= 0.0))
		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 <= -1e+15) || ~((t_0 <= 0.0)))
		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, -1e+15], N[Not[LessEqual[t$95$0, 0.0]], $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 \cdot 10^{+15} \lor \neg \left(t_0 \leq 0\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)) < -1e15 or 0.0 < (-.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 -1e15 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 0.0

    1. Initial program 7.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{\left({im}^{7} \cdot -0.0001984126984126984 + {im}^{5} \cdot -0.008333333333333333\right)} + \left({im}^{3} \cdot -0.16666666666666666 - im\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 \cdot 10^{+15} \lor \neg \left(e^{-im} - e^{im} \leq 0\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.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+15} \lor \neg \left(t_0 \leq 0\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) + {im}^{5} \cdot -0.008333333333333333\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 -1e+15) (not (<= t_0 0.0)))
     (* (* 0.5 (cos re)) t_0)
     (*
      (cos re)
      (+
       (- (* (* im im) (* im -0.16666666666666666)) im)
       (* (pow im 5.0) -0.008333333333333333))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -1e+15) || !(t_0 <= 0.0)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * ((((im * im) * (im * -0.16666666666666666)) - im) + (pow(im, 5.0) * -0.008333333333333333));
	}
	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 <= (-1d+15)) .or. (.not. (t_0 <= 0.0d0))) then
        tmp = (0.5d0 * cos(re)) * t_0
    else
        tmp = cos(re) * ((((im * im) * (im * (-0.16666666666666666d0))) - im) + ((im ** 5.0d0) * (-0.008333333333333333d0)))
    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 <= -1e+15) || !(t_0 <= 0.0)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = Math.cos(re) * ((((im * im) * (im * -0.16666666666666666)) - im) + (Math.pow(im, 5.0) * -0.008333333333333333));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -1e+15) or not (t_0 <= 0.0):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = math.cos(re) * ((((im * im) * (im * -0.16666666666666666)) - im) + (math.pow(im, 5.0) * -0.008333333333333333))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= -1e+15) || !(t_0 <= 0.0))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(cos(re) * Float64(Float64(Float64(Float64(im * im) * Float64(im * -0.16666666666666666)) - im) + Float64((im ^ 5.0) * -0.008333333333333333)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -1e+15) || ~((t_0 <= 0.0)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = cos(re) * ((((im * im) * (im * -0.16666666666666666)) - im) + ((im ^ 5.0) * -0.008333333333333333));
	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, -1e+15], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[(im * im), $MachinePrecision] * N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 7.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos re \cdot \left(\mathsf{fma}\left({im}^{5}, -0.008333333333333333, {im}^{7} \cdot -0.0001984126984126984\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)} \]
    7. Taylor expanded in im around 0 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \left(\left(\left(\color{blue}{\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right)} + 0\right) - im\right) + -0.008333333333333333 \cdot {im}^{5}\right) \]
      5. fma-def99.8%

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

        \[\leadsto \cos re \cdot \left(\left(\mathsf{fma}\left(im \cdot im, \color{blue}{-0.16666666666666666 \cdot im}, 0\right) - im\right) + -0.008333333333333333 \cdot {im}^{5}\right) \]
    11. Applied egg-rr99.8%

      \[\leadsto \cos re \cdot \left(\left(\color{blue}{\mathsf{fma}\left(im \cdot im, -0.16666666666666666 \cdot im, 0\right)} - im\right) + -0.008333333333333333 \cdot {im}^{5}\right) \]
    12. Step-by-step derivation
      1. fma-udef99.8%

        \[\leadsto \cos re \cdot \left(\left(\color{blue}{\left(\left(im \cdot im\right) \cdot \left(-0.16666666666666666 \cdot im\right) + 0\right)} - im\right) + -0.008333333333333333 \cdot {im}^{5}\right) \]
      2. +-rgt-identity99.8%

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

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

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

Alternative 3: 97.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ t_1 := -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \mathbf{if}\;im \leq -1.1 \cdot 10^{+44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.122:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.33:\\ \;\;\;\;\cos re \cdot \left(\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) + {im}^{5} \cdot -0.008333333333333333\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (- (exp (- im)) (exp im)) (+ 0.5 (* -0.25 (* re re)))))
        (t_1 (* -0.0001984126984126984 (* (cos re) (pow im 7.0)))))
   (if (<= im -1.1e+44)
     t_1
     (if (<= im -0.122)
       t_0
       (if (<= im 0.33)
         (*
          (cos re)
          (+
           (- (* (* im im) (* im -0.16666666666666666)) im)
           (* (pow im 5.0) -0.008333333333333333)))
         (if (<= im 1.1e+44) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = (exp(-im) - exp(im)) * (0.5 + (-0.25 * (re * re)));
	double t_1 = -0.0001984126984126984 * (cos(re) * pow(im, 7.0));
	double tmp;
	if (im <= -1.1e+44) {
		tmp = t_1;
	} else if (im <= -0.122) {
		tmp = t_0;
	} else if (im <= 0.33) {
		tmp = cos(re) * ((((im * im) * (im * -0.16666666666666666)) - im) + (pow(im, 5.0) * -0.008333333333333333));
	} else if (im <= 1.1e+44) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (exp(-im) - exp(im)) * (0.5d0 + ((-0.25d0) * (re * re)))
    t_1 = (-0.0001984126984126984d0) * (cos(re) * (im ** 7.0d0))
    if (im <= (-1.1d+44)) then
        tmp = t_1
    else if (im <= (-0.122d0)) then
        tmp = t_0
    else if (im <= 0.33d0) then
        tmp = cos(re) * ((((im * im) * (im * (-0.16666666666666666d0))) - im) + ((im ** 5.0d0) * (-0.008333333333333333d0)))
    else if (im <= 1.1d+44) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (Math.exp(-im) - Math.exp(im)) * (0.5 + (-0.25 * (re * re)));
	double t_1 = -0.0001984126984126984 * (Math.cos(re) * Math.pow(im, 7.0));
	double tmp;
	if (im <= -1.1e+44) {
		tmp = t_1;
	} else if (im <= -0.122) {
		tmp = t_0;
	} else if (im <= 0.33) {
		tmp = Math.cos(re) * ((((im * im) * (im * -0.16666666666666666)) - im) + (Math.pow(im, 5.0) * -0.008333333333333333));
	} else if (im <= 1.1e+44) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.exp(-im) - math.exp(im)) * (0.5 + (-0.25 * (re * re)))
	t_1 = -0.0001984126984126984 * (math.cos(re) * math.pow(im, 7.0))
	tmp = 0
	if im <= -1.1e+44:
		tmp = t_1
	elif im <= -0.122:
		tmp = t_0
	elif im <= 0.33:
		tmp = math.cos(re) * ((((im * im) * (im * -0.16666666666666666)) - im) + (math.pow(im, 5.0) * -0.008333333333333333))
	elif im <= 1.1e+44:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 + Float64(-0.25 * Float64(re * re))))
	t_1 = Float64(-0.0001984126984126984 * Float64(cos(re) * (im ^ 7.0)))
	tmp = 0.0
	if (im <= -1.1e+44)
		tmp = t_1;
	elseif (im <= -0.122)
		tmp = t_0;
	elseif (im <= 0.33)
		tmp = Float64(cos(re) * Float64(Float64(Float64(Float64(im * im) * Float64(im * -0.16666666666666666)) - im) + Float64((im ^ 5.0) * -0.008333333333333333)));
	elseif (im <= 1.1e+44)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (exp(-im) - exp(im)) * (0.5 + (-0.25 * (re * re)));
	t_1 = -0.0001984126984126984 * (cos(re) * (im ^ 7.0));
	tmp = 0.0;
	if (im <= -1.1e+44)
		tmp = t_1;
	elseif (im <= -0.122)
		tmp = t_0;
	elseif (im <= 0.33)
		tmp = cos(re) * ((((im * im) * (im * -0.16666666666666666)) - im) + ((im ^ 5.0) * -0.008333333333333333));
	elseif (im <= 1.1e+44)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.0001984126984126984 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.1e+44], t$95$1, If[LessEqual[im, -0.122], t$95$0, If[LessEqual[im, 0.33], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[(im * im), $MachinePrecision] * N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision] + N[(N[Power[im, 5.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.1e+44], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
t_1 := -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\
\mathbf{if}\;im \leq -1.1 \cdot 10^{+44}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 0.33:\\
\;\;\;\;\cos re \cdot \left(\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) + {im}^{5} \cdot -0.008333333333333333\right)\\

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.09999999999999998e44 or 1.09999999999999998e44 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos re \cdot \left(\mathsf{fma}\left({im}^{5}, -0.008333333333333333, {im}^{7} \cdot -0.0001984126984126984\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)} \]
    7. Taylor expanded in im around inf 100.0%

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

    if -1.09999999999999998e44 < im < -0.122 or 0.330000000000000016 < im < 1.09999999999999998e44

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

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

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

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

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

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

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

    if -0.122 < im < 0.330000000000000016

    1. Initial program 7.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos re \cdot \left(\mathsf{fma}\left({im}^{5}, -0.008333333333333333, {im}^{7} \cdot -0.0001984126984126984\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)} \]
    7. Taylor expanded in im around 0 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \left(\left(\left(\color{blue}{\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right)} + 0\right) - im\right) + -0.008333333333333333 \cdot {im}^{5}\right) \]
      5. fma-def99.8%

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

        \[\leadsto \cos re \cdot \left(\left(\mathsf{fma}\left(im \cdot im, \color{blue}{-0.16666666666666666 \cdot im}, 0\right) - im\right) + -0.008333333333333333 \cdot {im}^{5}\right) \]
    11. Applied egg-rr99.8%

      \[\leadsto \cos re \cdot \left(\left(\color{blue}{\mathsf{fma}\left(im \cdot im, -0.16666666666666666 \cdot im, 0\right)} - im\right) + -0.008333333333333333 \cdot {im}^{5}\right) \]
    12. Step-by-step derivation
      1. fma-udef99.8%

        \[\leadsto \cos re \cdot \left(\left(\color{blue}{\left(\left(im \cdot im\right) \cdot \left(-0.16666666666666666 \cdot im\right) + 0\right)} - im\right) + -0.008333333333333333 \cdot {im}^{5}\right) \]
      2. +-rgt-identity99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.1 \cdot 10^{+44}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq -0.122:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 0.33:\\ \;\;\;\;\cos re \cdot \left(\left(\left(im \cdot im\right) \cdot \left(im \cdot -0.16666666666666666\right) - im\right) + {im}^{5} \cdot -0.008333333333333333\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \end{array} \]

Alternative 4: 97.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ t_1 := -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \mathbf{if}\;im \leq -1.1 \cdot 10^{+44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.025:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.065:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (- (exp (- im)) (exp im)) (+ 0.5 (* -0.25 (* re re)))))
        (t_1 (* -0.0001984126984126984 (* (cos re) (pow im 7.0)))))
   (if (<= im -1.1e+44)
     t_1
     (if (<= im -0.025)
       t_0
       (if (<= im 0.065)
         (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
         (if (<= im 1.1e+44) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = (exp(-im) - exp(im)) * (0.5 + (-0.25 * (re * re)));
	double t_1 = -0.0001984126984126984 * (cos(re) * pow(im, 7.0));
	double tmp;
	if (im <= -1.1e+44) {
		tmp = t_1;
	} else if (im <= -0.025) {
		tmp = t_0;
	} else if (im <= 0.065) {
		tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 1.1e+44) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (exp(-im) - exp(im)) * (0.5d0 + ((-0.25d0) * (re * re)))
    t_1 = (-0.0001984126984126984d0) * (cos(re) * (im ** 7.0d0))
    if (im <= (-1.1d+44)) then
        tmp = t_1
    else if (im <= (-0.025d0)) then
        tmp = t_0
    else if (im <= 0.065d0) then
        tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    else if (im <= 1.1d+44) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (Math.exp(-im) - Math.exp(im)) * (0.5 + (-0.25 * (re * re)));
	double t_1 = -0.0001984126984126984 * (Math.cos(re) * Math.pow(im, 7.0));
	double tmp;
	if (im <= -1.1e+44) {
		tmp = t_1;
	} else if (im <= -0.025) {
		tmp = t_0;
	} else if (im <= 0.065) {
		tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 1.1e+44) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.exp(-im) - math.exp(im)) * (0.5 + (-0.25 * (re * re)))
	t_1 = -0.0001984126984126984 * (math.cos(re) * math.pow(im, 7.0))
	tmp = 0
	if im <= -1.1e+44:
		tmp = t_1
	elif im <= -0.025:
		tmp = t_0
	elif im <= 0.065:
		tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	elif im <= 1.1e+44:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(Float64(exp(Float64(-im)) - exp(im)) * Float64(0.5 + Float64(-0.25 * Float64(re * re))))
	t_1 = Float64(-0.0001984126984126984 * Float64(cos(re) * (im ^ 7.0)))
	tmp = 0.0
	if (im <= -1.1e+44)
		tmp = t_1;
	elseif (im <= -0.025)
		tmp = t_0;
	elseif (im <= 0.065)
		tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	elseif (im <= 1.1e+44)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (exp(-im) - exp(im)) * (0.5 + (-0.25 * (re * re)));
	t_1 = -0.0001984126984126984 * (cos(re) * (im ^ 7.0));
	tmp = 0.0;
	if (im <= -1.1e+44)
		tmp = t_1;
	elseif (im <= -0.025)
		tmp = t_0;
	elseif (im <= 0.065)
		tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	elseif (im <= 1.1e+44)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.0001984126984126984 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.1e+44], t$95$1, If[LessEqual[im, -0.025], t$95$0, If[LessEqual[im, 0.065], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.1e+44], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\
t_1 := -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\
\mathbf{if}\;im \leq -1.1 \cdot 10^{+44}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -1.09999999999999998e44 or 1.09999999999999998e44 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos re \cdot \left(\mathsf{fma}\left({im}^{5}, -0.008333333333333333, {im}^{7} \cdot -0.0001984126984126984\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)} \]
    7. Taylor expanded in im around inf 100.0%

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

    if -1.09999999999999998e44 < im < -0.025000000000000001 or 0.065000000000000002 < im < 1.09999999999999998e44

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

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

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

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

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

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

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

    if -0.025000000000000001 < im < 0.065000000000000002

    1. Initial program 7.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.1 \cdot 10^{+44}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq -0.025:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 0.065:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \end{array} \]

Alternative 5: 97.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \mathbf{if}\;im \leq -3.8 \cdot 10^{+43}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.0008:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.011:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
        (t_1 (* -0.0001984126984126984 (* (cos re) (pow im 7.0)))))
   (if (<= im -3.8e+43)
     t_1
     (if (<= im -0.0008)
       t_0
       (if (<= im 0.011) (* im (- (cos re))) (if (<= im 1.1e+44) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double t_1 = -0.0001984126984126984 * (cos(re) * pow(im, 7.0));
	double tmp;
	if (im <= -3.8e+43) {
		tmp = t_1;
	} else if (im <= -0.0008) {
		tmp = t_0;
	} else if (im <= 0.011) {
		tmp = im * -cos(re);
	} else if (im <= 1.1e+44) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * (exp(-im) - exp(im))
    t_1 = (-0.0001984126984126984d0) * (cos(re) * (im ** 7.0d0))
    if (im <= (-3.8d+43)) then
        tmp = t_1
    else if (im <= (-0.0008d0)) then
        tmp = t_0
    else if (im <= 0.011d0) then
        tmp = im * -cos(re)
    else if (im <= 1.1d+44) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
	double t_1 = -0.0001984126984126984 * (Math.cos(re) * Math.pow(im, 7.0));
	double tmp;
	if (im <= -3.8e+43) {
		tmp = t_1;
	} else if (im <= -0.0008) {
		tmp = t_0;
	} else if (im <= 0.011) {
		tmp = im * -Math.cos(re);
	} else if (im <= 1.1e+44) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * (math.exp(-im) - math.exp(im))
	t_1 = -0.0001984126984126984 * (math.cos(re) * math.pow(im, 7.0))
	tmp = 0
	if im <= -3.8e+43:
		tmp = t_1
	elif im <= -0.0008:
		tmp = t_0
	elif im <= 0.011:
		tmp = im * -math.cos(re)
	elif im <= 1.1e+44:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	t_1 = Float64(-0.0001984126984126984 * Float64(cos(re) * (im ^ 7.0)))
	tmp = 0.0
	if (im <= -3.8e+43)
		tmp = t_1;
	elseif (im <= -0.0008)
		tmp = t_0;
	elseif (im <= 0.011)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 1.1e+44)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * (exp(-im) - exp(im));
	t_1 = -0.0001984126984126984 * (cos(re) * (im ^ 7.0));
	tmp = 0.0;
	if (im <= -3.8e+43)
		tmp = t_1;
	elseif (im <= -0.0008)
		tmp = t_0;
	elseif (im <= 0.011)
		tmp = im * -cos(re);
	elseif (im <= 1.1e+44)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.0001984126984126984 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3.8e+43], t$95$1, If[LessEqual[im, -0.0008], t$95$0, If[LessEqual[im, 0.011], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 1.1e+44], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\
\mathbf{if}\;im \leq -3.8 \cdot 10^{+43}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -3.80000000000000008e43 or 1.09999999999999998e44 < 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 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos re \cdot \left(\mathsf{fma}\left({im}^{5}, -0.008333333333333333, {im}^{7} \cdot -0.0001984126984126984\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)} \]
    7. Taylor expanded in im around inf 99.2%

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

    if -3.80000000000000008e43 < im < -8.00000000000000038e-4 or 0.010999999999999999 < im < 1.09999999999999998e44

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

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

    if -8.00000000000000038e-4 < im < 0.010999999999999999

    1. Initial program 7.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.8 \cdot 10^{+43}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq -0.0008:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.011:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \end{array} \]

Alternative 6: 97.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\ t_1 := -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \mathbf{if}\;im \leq -3.8 \cdot 10^{+43}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.125:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.082:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (- (exp (- im)) (exp im))))
        (t_1 (* -0.0001984126984126984 (* (cos re) (pow im 7.0)))))
   (if (<= im -3.8e+43)
     t_1
     (if (<= im -0.125)
       t_0
       (if (<= im 0.082)
         (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im))
         (if (<= im 1.1e+44) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = 0.5 * (exp(-im) - exp(im));
	double t_1 = -0.0001984126984126984 * (cos(re) * pow(im, 7.0));
	double tmp;
	if (im <= -3.8e+43) {
		tmp = t_1;
	} else if (im <= -0.125) {
		tmp = t_0;
	} else if (im <= 0.082) {
		tmp = cos(re) * ((pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 1.1e+44) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * (exp(-im) - exp(im))
    t_1 = (-0.0001984126984126984d0) * (cos(re) * (im ** 7.0d0))
    if (im <= (-3.8d+43)) then
        tmp = t_1
    else if (im <= (-0.125d0)) then
        tmp = t_0
    else if (im <= 0.082d0) then
        tmp = cos(re) * (((im ** 3.0d0) * (-0.16666666666666666d0)) - im)
    else if (im <= 1.1d+44) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * (Math.exp(-im) - Math.exp(im));
	double t_1 = -0.0001984126984126984 * (Math.cos(re) * Math.pow(im, 7.0));
	double tmp;
	if (im <= -3.8e+43) {
		tmp = t_1;
	} else if (im <= -0.125) {
		tmp = t_0;
	} else if (im <= 0.082) {
		tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	} else if (im <= 1.1e+44) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * (math.exp(-im) - math.exp(im))
	t_1 = -0.0001984126984126984 * (math.cos(re) * math.pow(im, 7.0))
	tmp = 0
	if im <= -3.8e+43:
		tmp = t_1
	elif im <= -0.125:
		tmp = t_0
	elif im <= 0.082:
		tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	elif im <= 1.1e+44:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)))
	t_1 = Float64(-0.0001984126984126984 * Float64(cos(re) * (im ^ 7.0)))
	tmp = 0.0
	if (im <= -3.8e+43)
		tmp = t_1;
	elseif (im <= -0.125)
		tmp = t_0;
	elseif (im <= 0.082)
		tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	elseif (im <= 1.1e+44)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * (exp(-im) - exp(im));
	t_1 = -0.0001984126984126984 * (cos(re) * (im ^ 7.0));
	tmp = 0.0;
	if (im <= -3.8e+43)
		tmp = t_1;
	elseif (im <= -0.125)
		tmp = t_0;
	elseif (im <= 0.082)
		tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	elseif (im <= 1.1e+44)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.0001984126984126984 * N[(N[Cos[re], $MachinePrecision] * N[Power[im, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3.8e+43], t$95$1, If[LessEqual[im, -0.125], t$95$0, If[LessEqual[im, 0.082], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.1e+44], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := -0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\
\mathbf{if}\;im \leq -3.8 \cdot 10^{+43}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -3.80000000000000008e43 or 1.09999999999999998e44 < 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 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos re \cdot \left(\mathsf{fma}\left({im}^{5}, -0.008333333333333333, {im}^{7} \cdot -0.0001984126984126984\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)} \]
    7. Taylor expanded in im around inf 99.2%

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

    if -3.80000000000000008e43 < im < -0.125 or 0.0820000000000000034 < im < 1.09999999999999998e44

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

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

    if -0.125 < im < 0.0820000000000000034

    1. Initial program 7.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.8 \cdot 10^{+43}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \mathbf{elif}\;im \leq -0.125:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.082:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \end{array} \]

Alternative 7: 92.7% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.1 \lor \neg \left(im \leq 4.2\right):\\
\;\;\;\;-0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -4.0999999999999996 or 4.20000000000000018 < 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 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos re \cdot \left(\mathsf{fma}\left({im}^{5}, -0.008333333333333333, {im}^{7} \cdot -0.0001984126984126984\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)} \]
    7. Taylor expanded in im around inf 85.3%

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

    if -4.0999999999999996 < im < 4.20000000000000018

    1. Initial program 7.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.1 \lor \neg \left(im \leq 4.2\right):\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 8: 89.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -\cos re\\ t_1 := \left(im \cdot im\right) \cdot \frac{t_0}{im}\\ t_2 := \langle \left( \langle \left( im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\ \mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -780:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq 35:\\ \;\;\;\;im \cdot t_0\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (cos re)))
        (t_1 (* (* im im) (/ t_0 im)))
        (t_2
         (cast
          (!
           :precision
           binary32
           (cast (! :precision binary64 (- (* im (* 0.5 (* re re))) im)))))))
   (if (<= im -2.45e+179)
     t_1
     (if (<= im -780.0)
       t_2
       (if (<= im 35.0) (* im t_0) (if (<= im 1.35e+154) t_2 t_1))))))
double code(double re, double im) {
	double t_0 = -cos(re);
	double t_1 = (im * im) * (t_0 / im);
	double tmp_2 = (im * (0.5 * (re * re))) - im;
	double tmp_1 = (float) tmp_2;
	double t_2 = (double) tmp_1;
	double tmp_3;
	if (im <= -2.45e+179) {
		tmp_3 = t_1;
	} else if (im <= -780.0) {
		tmp_3 = t_2;
	} else if (im <= 35.0) {
		tmp_3 = im * t_0;
	} else if (im <= 1.35e+154) {
		tmp_3 = t_2;
	} else {
		tmp_3 = t_1;
	}
	return tmp_3;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    real(8) :: tmp_1
    real(8) :: tmp_2
    real(8) :: tmp_3
    t_0 = -cos(re)
    t_1 = (im * im) * (t_0 / im)
    tmp_2 = (im * (0.5d0 * (re * re))) - im
    tmp_1 = real(tmp_2, 4)
    t_2 = real(tmp_1, 8)
    if (im <= (-2.45d+179)) then
        tmp_3 = t_1
    else if (im <= (-780.0d0)) then
        tmp_3 = t_2
    else if (im <= 35.0d0) then
        tmp_3 = im * t_0
    else if (im <= 1.35d+154) then
        tmp_3 = t_2
    else
        tmp_3 = t_1
    end if
    code = tmp_3
end function
function code(re, im)
	t_0 = Float64(-cos(re))
	t_1 = Float64(Float64(im * im) * Float64(t_0 / im))
	tmp_2 = Float64(Float64(im * Float64(0.5 * Float64(re * re))) - im)
	tmp_1 = Float32(tmp_2)
	t_2 = Float64(tmp_1)
	tmp_3 = 0.0
	if (im <= -2.45e+179)
		tmp_3 = t_1;
	elseif (im <= -780.0)
		tmp_3 = t_2;
	elseif (im <= 35.0)
		tmp_3 = Float64(im * t_0);
	elseif (im <= 1.35e+154)
		tmp_3 = t_2;
	else
		tmp_3 = t_1;
	end
	return tmp_3
end
function tmp_5 = code(re, im)
	t_0 = -cos(re);
	t_1 = (im * im) * (t_0 / im);
	tmp_3 = (im * (0.5 * (re * re))) - im;
	tmp_2 = single(tmp_3);
	t_2 = double(tmp_2);
	tmp_4 = 0.0;
	if (im <= -2.45e+179)
		tmp_4 = t_1;
	elseif (im <= -780.0)
		tmp_4 = t_2;
	elseif (im <= 35.0)
		tmp_4 = im * t_0;
	elseif (im <= 1.35e+154)
		tmp_4 = t_2;
	else
		tmp_4 = t_1;
	end
	tmp_5 = tmp_4;
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -\cos re\\
t_1 := \left(im \cdot im\right) \cdot \frac{t_0}{im}\\
t_2 := \langle \left( \langle \left( im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\
\mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 35:\\
\;\;\;\;im \cdot t_0\\

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

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \]
    2. Step-by-step derivation
      1. 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 7.3%

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \frac{\color{blue}{0} - im \cdot im}{0 + im} \]
      5. neg-sub0100.0%

        \[\leadsto \cos re \cdot \frac{\color{blue}{-im \cdot im}}{0 + im} \]
      6. +-lft-identity100.0%

        \[\leadsto \cos re \cdot \frac{-im \cdot im}{\color{blue}{im}} \]
      7. associate-*r/100.0%

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

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(-1 \cdot \left(im \cdot im\right)\right)}}{im} \]
      9. associate-*l*100.0%

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

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

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

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(im \cdot \left(-im\right)\right)}{im}} \]
    9. Step-by-step derivation
      1. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{\cos re}{\frac{im}{im \cdot \left(-im\right)}}} \]
      2. associate-/r/100.0%

        \[\leadsto \color{blue}{\frac{\cos re}{im} \cdot \left(im \cdot \left(-im\right)\right)} \]
      3. distribute-rgt-neg-out100.0%

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

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

    if -2.4499999999999999e179 < im < -780 or 35 < im < 1.35000000000000003e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right) - im} \]
    10. Step-by-step derivation
      1. rewrite-binary64/binary32-simplify64.0%

        \[\leadsto \color{blue}{\langle \color{blue}{\left( \color{blue}{\langle \color{blue}{\left( \color{blue}{im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right) - im} \right)_{\text{binary64}}} \rangle_{\text{binary32}}} \right)_{\text{binary32}}} \rangle_{\text{binary64}}} \]
    11. Applied rewrite-once64.0%

      \[\leadsto \color{blue}{\langle \color{blue}{\left( \color{blue}{\langle \color{blue}{\left( \color{blue}{im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right) - im} \right)_{\text{binary64}}} \rangle_{\text{binary32}}} \right)_{\text{binary32}}} \rangle_{\text{binary64}}} \]

    if -780 < im < 35

    1. Initial program 8.3%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-\cos re}{im}\\ \mathbf{elif}\;im \leq -780:\\ \;\;\;\;\langle \left( \langle \left( im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\ \mathbf{elif}\;im \leq 35:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\langle \left( \langle \left( im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-\cos re}{im}\\ \end{array} \]

Alternative 9: 78.2% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\\ t_1 := -\cos re\\ \mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{t_1}{im}\\ \mathbf{elif}\;im \leq -6 \cdot 10^{+36}:\\ \;\;\;\;\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \cdot t_0\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+67}:\\ \;\;\;\;im \cdot t_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (+ (* im -2.0) (* (pow im 3.0) -0.3333333333333333)))
        (t_1 (- (cos re))))
   (if (<= im -2.45e+179)
     (* (* im im) (/ t_1 im))
     (if (<= im -6e+36)
       (* (+ 0.5 (* -0.25 (* re re))) t_0)
       (if (<= im 6.5e+67) (* im t_1) (* 0.5 t_0))))))
double code(double re, double im) {
	double t_0 = (im * -2.0) + (pow(im, 3.0) * -0.3333333333333333);
	double t_1 = -cos(re);
	double tmp;
	if (im <= -2.45e+179) {
		tmp = (im * im) * (t_1 / im);
	} else if (im <= -6e+36) {
		tmp = (0.5 + (-0.25 * (re * re))) * t_0;
	} else if (im <= 6.5e+67) {
		tmp = im * 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 = (im * (-2.0d0)) + ((im ** 3.0d0) * (-0.3333333333333333d0))
    t_1 = -cos(re)
    if (im <= (-2.45d+179)) then
        tmp = (im * im) * (t_1 / im)
    else if (im <= (-6d+36)) then
        tmp = (0.5d0 + ((-0.25d0) * (re * re))) * t_0
    else if (im <= 6.5d+67) then
        tmp = im * 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 = (im * -2.0) + (Math.pow(im, 3.0) * -0.3333333333333333);
	double t_1 = -Math.cos(re);
	double tmp;
	if (im <= -2.45e+179) {
		tmp = (im * im) * (t_1 / im);
	} else if (im <= -6e+36) {
		tmp = (0.5 + (-0.25 * (re * re))) * t_0;
	} else if (im <= 6.5e+67) {
		tmp = im * t_1;
	} else {
		tmp = 0.5 * t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (im * -2.0) + (math.pow(im, 3.0) * -0.3333333333333333)
	t_1 = -math.cos(re)
	tmp = 0
	if im <= -2.45e+179:
		tmp = (im * im) * (t_1 / im)
	elif im <= -6e+36:
		tmp = (0.5 + (-0.25 * (re * re))) * t_0
	elif im <= 6.5e+67:
		tmp = im * t_1
	else:
		tmp = 0.5 * t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64(im * -2.0) + Float64((im ^ 3.0) * -0.3333333333333333))
	t_1 = Float64(-cos(re))
	tmp = 0.0
	if (im <= -2.45e+179)
		tmp = Float64(Float64(im * im) * Float64(t_1 / im));
	elseif (im <= -6e+36)
		tmp = Float64(Float64(0.5 + Float64(-0.25 * Float64(re * re))) * t_0);
	elseif (im <= 6.5e+67)
		tmp = Float64(im * t_1);
	else
		tmp = Float64(0.5 * t_0);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im * -2.0) + ((im ^ 3.0) * -0.3333333333333333);
	t_1 = -cos(re);
	tmp = 0.0;
	if (im <= -2.45e+179)
		tmp = (im * im) * (t_1 / im);
	elseif (im <= -6e+36)
		tmp = (0.5 + (-0.25 * (re * re))) * t_0;
	elseif (im <= 6.5e+67)
		tmp = im * t_1;
	else
		tmp = 0.5 * t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(im * -2.0), $MachinePrecision] + N[(N[Power[im, 3.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-N[Cos[re], $MachinePrecision])}, If[LessEqual[im, -2.45e+179], N[(N[(im * im), $MachinePrecision] * N[(t$95$1 / im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -6e+36], N[(N[(0.5 + N[(-0.25 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[im, 6.5e+67], N[(im * t$95$1), $MachinePrecision], N[(0.5 * t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\\
t_1 := -\cos re\\
\mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \frac{t_1}{im}\\

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

\mathbf{elif}\;im \leq 6.5 \cdot 10^{+67}:\\
\;\;\;\;im \cdot t_1\\

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


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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \frac{\color{blue}{0} - im \cdot im}{0 + im} \]
      5. neg-sub0100.0%

        \[\leadsto \cos re \cdot \frac{\color{blue}{-im \cdot im}}{0 + im} \]
      6. +-lft-identity100.0%

        \[\leadsto \cos re \cdot \frac{-im \cdot im}{\color{blue}{im}} \]
      7. associate-*r/100.0%

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

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(-1 \cdot \left(im \cdot im\right)\right)}}{im} \]
      9. associate-*l*100.0%

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

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

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

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(im \cdot \left(-im\right)\right)}{im}} \]
    9. Step-by-step derivation
      1. associate-/l*100.0%

        \[\leadsto \color{blue}{\frac{\cos re}{\frac{im}{im \cdot \left(-im\right)}}} \]
      2. associate-/r/100.0%

        \[\leadsto \color{blue}{\frac{\cos re}{im} \cdot \left(im \cdot \left(-im\right)\right)} \]
      3. distribute-rgt-neg-out100.0%

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

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

    if -2.4499999999999999e179 < im < -6e36

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if -6e36 < im < 6.4999999999999995e67

    1. Initial program 20.6%

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

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

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

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

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

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

    if 6.4999999999999995e67 < 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 92.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-\cos re}{im}\\ \mathbf{elif}\;im \leq -6 \cdot 10^{+36}:\\ \;\;\;\;\left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\right)\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+67}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\right)\\ \end{array} \]

Alternative 10: 77.1% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -\cos re\\ \mathbf{if}\;im \leq -3.9 \cdot 10^{+141}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{t_0}{im}\\ \mathbf{elif}\;im \leq -6.4 \cdot 10^{+44} \lor \neg \left(im \leq 2.3 \cdot 10^{+67}\right):\\ \;\;\;\;0.5 \cdot \left(im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (cos re))))
   (if (<= im -3.9e+141)
     (* (* im im) (/ t_0 im))
     (if (or (<= im -6.4e+44) (not (<= im 2.3e+67)))
       (* 0.5 (+ (* im -2.0) (* (pow im 3.0) -0.3333333333333333)))
       (* im t_0)))))
double code(double re, double im) {
	double t_0 = -cos(re);
	double tmp;
	if (im <= -3.9e+141) {
		tmp = (im * im) * (t_0 / im);
	} else if ((im <= -6.4e+44) || !(im <= 2.3e+67)) {
		tmp = 0.5 * ((im * -2.0) + (pow(im, 3.0) * -0.3333333333333333));
	} else {
		tmp = im * 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 = -cos(re)
    if (im <= (-3.9d+141)) then
        tmp = (im * im) * (t_0 / im)
    else if ((im <= (-6.4d+44)) .or. (.not. (im <= 2.3d+67))) then
        tmp = 0.5d0 * ((im * (-2.0d0)) + ((im ** 3.0d0) * (-0.3333333333333333d0)))
    else
        tmp = im * t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = -Math.cos(re);
	double tmp;
	if (im <= -3.9e+141) {
		tmp = (im * im) * (t_0 / im);
	} else if ((im <= -6.4e+44) || !(im <= 2.3e+67)) {
		tmp = 0.5 * ((im * -2.0) + (Math.pow(im, 3.0) * -0.3333333333333333));
	} else {
		tmp = im * t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = -math.cos(re)
	tmp = 0
	if im <= -3.9e+141:
		tmp = (im * im) * (t_0 / im)
	elif (im <= -6.4e+44) or not (im <= 2.3e+67):
		tmp = 0.5 * ((im * -2.0) + (math.pow(im, 3.0) * -0.3333333333333333))
	else:
		tmp = im * t_0
	return tmp
function code(re, im)
	t_0 = Float64(-cos(re))
	tmp = 0.0
	if (im <= -3.9e+141)
		tmp = Float64(Float64(im * im) * Float64(t_0 / im));
	elseif ((im <= -6.4e+44) || !(im <= 2.3e+67))
		tmp = Float64(0.5 * Float64(Float64(im * -2.0) + Float64((im ^ 3.0) * -0.3333333333333333)));
	else
		tmp = Float64(im * t_0);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = -cos(re);
	tmp = 0.0;
	if (im <= -3.9e+141)
		tmp = (im * im) * (t_0 / im);
	elseif ((im <= -6.4e+44) || ~((im <= 2.3e+67)))
		tmp = 0.5 * ((im * -2.0) + ((im ^ 3.0) * -0.3333333333333333));
	else
		tmp = im * t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = (-N[Cos[re], $MachinePrecision])}, If[LessEqual[im, -3.9e+141], N[(N[(im * im), $MachinePrecision] * N[(t$95$0 / im), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, -6.4e+44], N[Not[LessEqual[im, 2.3e+67]], $MachinePrecision]], N[(0.5 * N[(N[(im * -2.0), $MachinePrecision] + N[(N[Power[im, 3.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * t$95$0), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -\cos re\\
\mathbf{if}\;im \leq -3.9 \cdot 10^{+141}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \frac{t_0}{im}\\

\mathbf{elif}\;im \leq -6.4 \cdot 10^{+44} \lor \neg \left(im \leq 2.3 \cdot 10^{+67}\right):\\
\;\;\;\;0.5 \cdot \left(im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\right)\\

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


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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. metadata-eval97.4%

        \[\leadsto \cos re \cdot \frac{\color{blue}{0} - im \cdot im}{0 + im} \]
      5. neg-sub097.4%

        \[\leadsto \cos re \cdot \frac{\color{blue}{-im \cdot im}}{0 + im} \]
      6. +-lft-identity97.4%

        \[\leadsto \cos re \cdot \frac{-im \cdot im}{\color{blue}{im}} \]
      7. associate-*r/97.4%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(-im \cdot im\right)}{im}} \]
      8. neg-mul-197.4%

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(-1 \cdot \left(im \cdot im\right)\right)}}{im} \]
      9. associate-*l*97.4%

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

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{\left(-im\right)} \cdot im\right)}{im} \]
      11. *-commutative97.4%

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

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(im \cdot \left(-im\right)\right)}{im}} \]
    9. Step-by-step derivation
      1. associate-/l*97.4%

        \[\leadsto \color{blue}{\frac{\cos re}{\frac{im}{im \cdot \left(-im\right)}}} \]
      2. associate-/r/97.4%

        \[\leadsto \color{blue}{\frac{\cos re}{im} \cdot \left(im \cdot \left(-im\right)\right)} \]
      3. distribute-rgt-neg-out97.4%

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

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

    if -3.89999999999999991e141 < im < -6.40000000000000009e44 or 2.2999999999999999e67 < 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 89.9%

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

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

    if -6.40000000000000009e44 < im < 2.2999999999999999e67

    1. Initial program 21.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3.9 \cdot 10^{+141}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-\cos re}{im}\\ \mathbf{elif}\;im \leq -6.4 \cdot 10^{+44} \lor \neg \left(im \leq 2.3 \cdot 10^{+67}\right):\\ \;\;\;\;0.5 \cdot \left(im \cdot -2 + {im}^{3} \cdot -0.3333333333333333\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 11: 74.9% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -\cos re\\ \mathbf{if}\;im \leq -2 \cdot 10^{+141} \lor \neg \left(im \leq 1.1 \cdot 10^{-6}\right):\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{t_0}{im}\\ \mathbf{else}:\\ \;\;\;\;im \cdot t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (cos re))))
   (if (or (<= im -2e+141) (not (<= im 1.1e-6)))
     (* (* im im) (/ t_0 im))
     (* im t_0))))
double code(double re, double im) {
	double t_0 = -cos(re);
	double tmp;
	if ((im <= -2e+141) || !(im <= 1.1e-6)) {
		tmp = (im * im) * (t_0 / im);
	} else {
		tmp = im * 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 = -cos(re)
    if ((im <= (-2d+141)) .or. (.not. (im <= 1.1d-6))) then
        tmp = (im * im) * (t_0 / im)
    else
        tmp = im * t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = -Math.cos(re);
	double tmp;
	if ((im <= -2e+141) || !(im <= 1.1e-6)) {
		tmp = (im * im) * (t_0 / im);
	} else {
		tmp = im * t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = -math.cos(re)
	tmp = 0
	if (im <= -2e+141) or not (im <= 1.1e-6):
		tmp = (im * im) * (t_0 / im)
	else:
		tmp = im * t_0
	return tmp
function code(re, im)
	t_0 = Float64(-cos(re))
	tmp = 0.0
	if ((im <= -2e+141) || !(im <= 1.1e-6))
		tmp = Float64(Float64(im * im) * Float64(t_0 / im));
	else
		tmp = Float64(im * t_0);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = -cos(re);
	tmp = 0.0;
	if ((im <= -2e+141) || ~((im <= 1.1e-6)))
		tmp = (im * im) * (t_0 / im);
	else
		tmp = im * t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = (-N[Cos[re], $MachinePrecision])}, If[Or[LessEqual[im, -2e+141], N[Not[LessEqual[im, 1.1e-6]], $MachinePrecision]], N[(N[(im * im), $MachinePrecision] * N[(t$95$0 / im), $MachinePrecision]), $MachinePrecision], N[(im * t$95$0), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -2.00000000000000003e141 or 1.1000000000000001e-6 < 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)} \]
    4. Taylor expanded in im around 0 6.7%

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. metadata-eval75.2%

        \[\leadsto \cos re \cdot \frac{\color{blue}{0} - im \cdot im}{0 + im} \]
      5. neg-sub075.2%

        \[\leadsto \cos re \cdot \frac{\color{blue}{-im \cdot im}}{0 + im} \]
      6. +-lft-identity75.2%

        \[\leadsto \cos re \cdot \frac{-im \cdot im}{\color{blue}{im}} \]
      7. associate-*r/75.2%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(-im \cdot im\right)}{im}} \]
      8. neg-mul-175.2%

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(-1 \cdot \left(im \cdot im\right)\right)}}{im} \]
      9. associate-*l*75.2%

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

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{\left(-im\right)} \cdot im\right)}{im} \]
      11. *-commutative75.2%

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(im \cdot \left(-im\right)\right)}}{im} \]
    8. Applied egg-rr75.2%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(im \cdot \left(-im\right)\right)}{im}} \]
    9. Step-by-step derivation
      1. associate-/l*75.2%

        \[\leadsto \color{blue}{\frac{\cos re}{\frac{im}{im \cdot \left(-im\right)}}} \]
      2. associate-/r/75.2%

        \[\leadsto \color{blue}{\frac{\cos re}{im} \cdot \left(im \cdot \left(-im\right)\right)} \]
      3. distribute-rgt-neg-out75.2%

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

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

    if -2.00000000000000003e141 < im < 1.1000000000000001e-6

    1. Initial program 24.7%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2 \cdot 10^{+141} \lor \neg \left(im \leq 1.1 \cdot 10^{-6}\right):\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-\cos re}{im}\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 12: 74.9% accurate, 2.8× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. metadata-eval97.4%

        \[\leadsto \cos re \cdot \frac{\color{blue}{0} - im \cdot im}{0 + im} \]
      5. neg-sub097.4%

        \[\leadsto \cos re \cdot \frac{\color{blue}{-im \cdot im}}{0 + im} \]
      6. +-lft-identity97.4%

        \[\leadsto \cos re \cdot \frac{-im \cdot im}{\color{blue}{im}} \]
      7. associate-*r/97.4%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(-im \cdot im\right)}{im}} \]
      8. neg-mul-197.4%

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(-1 \cdot \left(im \cdot im\right)\right)}}{im} \]
      9. associate-*l*97.4%

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

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{\left(-im\right)} \cdot im\right)}{im} \]
      11. *-commutative97.4%

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

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(im \cdot \left(-im\right)\right)}{im}} \]
    9. Step-by-step derivation
      1. associate-/l*97.4%

        \[\leadsto \color{blue}{\frac{\cos re}{\frac{im}{im \cdot \left(-im\right)}}} \]
      2. associate-/r/97.4%

        \[\leadsto \color{blue}{\frac{\cos re}{im} \cdot \left(im \cdot \left(-im\right)\right)} \]
      3. distribute-rgt-neg-out97.4%

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

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

    if -2.00000000000000003e141 < im < 3e-10

    1. Initial program 24.2%

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

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

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

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

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

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

    if 3e-10 < im

    1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. metadata-eval63.2%

        \[\leadsto \cos re \cdot \frac{\color{blue}{0} - im \cdot im}{0 + im} \]
      5. neg-sub063.2%

        \[\leadsto \cos re \cdot \frac{\color{blue}{-im \cdot im}}{0 + im} \]
      6. +-lft-identity63.2%

        \[\leadsto \cos re \cdot \frac{-im \cdot im}{\color{blue}{im}} \]
      7. associate-*r/63.2%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(-im \cdot im\right)}{im}} \]
      8. neg-mul-163.2%

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(-1 \cdot \left(im \cdot im\right)\right)}}{im} \]
      9. associate-*l*63.2%

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

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{\left(-im\right)} \cdot im\right)}{im} \]
      11. *-commutative63.2%

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(im \cdot \left(-im\right)\right)}}{im} \]
    8. Applied egg-rr63.2%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(im \cdot \left(-im\right)\right)}{im}} \]
    9. Step-by-step derivation
      1. associate-/l*63.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2 \cdot 10^{+141}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-\cos re}{im}\\ \mathbf{elif}\;im \leq 3 \cdot 10^{-10}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re}{\frac{im}{im \cdot \left(-im\right)}}\\ \end{array} \]

Alternative 13: 68.9% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
t_0 := \left(im \cdot im\right) \cdot \frac{-1}{im}\\
\mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\
\;\;\;\;t_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.4499999999999999e179 or 2.09999999999999993e132 < 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 7.2%

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. metadata-eval94.6%

        \[\leadsto \cos re \cdot \frac{\color{blue}{0} - im \cdot im}{0 + im} \]
      5. neg-sub094.6%

        \[\leadsto \cos re \cdot \frac{\color{blue}{-im \cdot im}}{0 + im} \]
      6. +-lft-identity94.6%

        \[\leadsto \cos re \cdot \frac{-im \cdot im}{\color{blue}{im}} \]
      7. associate-*r/94.6%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(-im \cdot im\right)}{im}} \]
      8. neg-mul-194.6%

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(-1 \cdot \left(im \cdot im\right)\right)}}{im} \]
      9. associate-*l*94.6%

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

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

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

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(im \cdot \left(-im\right)\right)}{im}} \]
    9. Step-by-step derivation
      1. associate-/l*94.6%

        \[\leadsto \color{blue}{\frac{\cos re}{\frac{im}{im \cdot \left(-im\right)}}} \]
      2. associate-/r/94.6%

        \[\leadsto \color{blue}{\frac{\cos re}{im} \cdot \left(im \cdot \left(-im\right)\right)} \]
      3. distribute-rgt-neg-out94.6%

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

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

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

    if -2.4499999999999999e179 < im < -5.50000000000000001e35

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right) - im} \]
    10. Step-by-step derivation
      1. sub-neg30.3%

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

        \[\leadsto \color{blue}{\left(\left(re \cdot re\right) \cdot 0.5\right) \cdot im} + \left(-im\right) \]
      3. neg-mul-130.3%

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

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

        \[\leadsto im \cdot \left(\color{blue}{re \cdot \left(re \cdot 0.5\right)} + -1\right) \]
    11. Applied egg-rr30.3%

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

    if -5.50000000000000001e35 < im < 2.09999999999999993e132

    1. Initial program 26.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-1}{im}\\ \mathbf{elif}\;im \leq -5.5 \cdot 10^{+35}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right) + -1\right)\\ \mathbf{elif}\;im \leq 2.1 \cdot 10^{+132}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-1}{im}\\ \end{array} \]

Alternative 14: 49.4% accurate, 17.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(im \cdot im\right) \cdot \frac{-1}{im}\\ t_1 := im \cdot \left(re \cdot \left(0.5 \cdot re\right) + -1\right)\\ \mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -3 \cdot 10^{-21}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 8 \cdot 10^{-32}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 1.95 \cdot 10^{+130}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* im im) (/ -1.0 im)))
        (t_1 (* im (+ (* re (* 0.5 re)) -1.0))))
   (if (<= im -2.45e+179)
     t_0
     (if (<= im -3e-21)
       t_1
       (if (<= im 8e-32) (- im) (if (<= im 1.95e+130) t_1 t_0))))))
double code(double re, double im) {
	double t_0 = (im * im) * (-1.0 / im);
	double t_1 = im * ((re * (0.5 * re)) + -1.0);
	double tmp;
	if (im <= -2.45e+179) {
		tmp = t_0;
	} else if (im <= -3e-21) {
		tmp = t_1;
	} else if (im <= 8e-32) {
		tmp = -im;
	} else if (im <= 1.95e+130) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (im * im) * ((-1.0d0) / im)
    t_1 = im * ((re * (0.5d0 * re)) + (-1.0d0))
    if (im <= (-2.45d+179)) then
        tmp = t_0
    else if (im <= (-3d-21)) then
        tmp = t_1
    else if (im <= 8d-32) then
        tmp = -im
    else if (im <= 1.95d+130) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (im * im) * (-1.0 / im);
	double t_1 = im * ((re * (0.5 * re)) + -1.0);
	double tmp;
	if (im <= -2.45e+179) {
		tmp = t_0;
	} else if (im <= -3e-21) {
		tmp = t_1;
	} else if (im <= 8e-32) {
		tmp = -im;
	} else if (im <= 1.95e+130) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (im * im) * (-1.0 / im)
	t_1 = im * ((re * (0.5 * re)) + -1.0)
	tmp = 0
	if im <= -2.45e+179:
		tmp = t_0
	elif im <= -3e-21:
		tmp = t_1
	elif im <= 8e-32:
		tmp = -im
	elif im <= 1.95e+130:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64(im * im) * Float64(-1.0 / im))
	t_1 = Float64(im * Float64(Float64(re * Float64(0.5 * re)) + -1.0))
	tmp = 0.0
	if (im <= -2.45e+179)
		tmp = t_0;
	elseif (im <= -3e-21)
		tmp = t_1;
	elseif (im <= 8e-32)
		tmp = Float64(-im);
	elseif (im <= 1.95e+130)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im * im) * (-1.0 / im);
	t_1 = im * ((re * (0.5 * re)) + -1.0);
	tmp = 0.0;
	if (im <= -2.45e+179)
		tmp = t_0;
	elseif (im <= -3e-21)
		tmp = t_1;
	elseif (im <= 8e-32)
		tmp = -im;
	elseif (im <= 1.95e+130)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(im * im), $MachinePrecision] * N[(-1.0 / im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(im * N[(N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.45e+179], t$95$0, If[LessEqual[im, -3e-21], t$95$1, If[LessEqual[im, 8e-32], (-im), If[LessEqual[im, 1.95e+130], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(im \cdot im\right) \cdot \frac{-1}{im}\\
t_1 := im \cdot \left(re \cdot \left(0.5 \cdot re\right) + -1\right)\\
\mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -3 \cdot 10^{-21}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 1.95 \cdot 10^{+130}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.4499999999999999e179 or 1.9500000000000001e130 < 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 7.2%

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. metadata-eval94.6%

        \[\leadsto \cos re \cdot \frac{\color{blue}{0} - im \cdot im}{0 + im} \]
      5. neg-sub094.6%

        \[\leadsto \cos re \cdot \frac{\color{blue}{-im \cdot im}}{0 + im} \]
      6. +-lft-identity94.6%

        \[\leadsto \cos re \cdot \frac{-im \cdot im}{\color{blue}{im}} \]
      7. associate-*r/94.6%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(-im \cdot im\right)}{im}} \]
      8. neg-mul-194.6%

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(-1 \cdot \left(im \cdot im\right)\right)}}{im} \]
      9. associate-*l*94.6%

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

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

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

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(im \cdot \left(-im\right)\right)}{im}} \]
    9. Step-by-step derivation
      1. associate-/l*94.6%

        \[\leadsto \color{blue}{\frac{\cos re}{\frac{im}{im \cdot \left(-im\right)}}} \]
      2. associate-/r/94.6%

        \[\leadsto \color{blue}{\frac{\cos re}{im} \cdot \left(im \cdot \left(-im\right)\right)} \]
      3. distribute-rgt-neg-out94.6%

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

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

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

    if -2.4499999999999999e179 < im < -2.99999999999999991e-21 or 8.00000000000000045e-32 < im < 1.9500000000000001e130

    1. Initial program 92.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right) - im} \]
    10. Step-by-step derivation
      1. sub-neg22.7%

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

        \[\leadsto \color{blue}{\left(\left(re \cdot re\right) \cdot 0.5\right) \cdot im} + \left(-im\right) \]
      3. neg-mul-122.7%

        \[\leadsto \left(\left(re \cdot re\right) \cdot 0.5\right) \cdot im + \color{blue}{-1 \cdot im} \]
      4. distribute-rgt-out22.7%

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

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

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

    if -2.99999999999999991e-21 < im < 8.00000000000000045e-32

    1. Initial program 5.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-1}{im}\\ \mathbf{elif}\;im \leq -3 \cdot 10^{-21}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right) + -1\right)\\ \mathbf{elif}\;im \leq 8 \cdot 10^{-32}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 1.95 \cdot 10^{+130}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right) + -1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-1}{im}\\ \end{array} \]

Alternative 15: 49.3% accurate, 17.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(im \cdot im\right) \cdot \frac{-1}{im}\\ \mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -3 \cdot 10^{-21}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right) + -1\right)\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{-32}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 7 \cdot 10^{+126}:\\ \;\;\;\;re \cdot \left(0.5 \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* im im) (/ -1.0 im))))
   (if (<= im -2.45e+179)
     t_0
     (if (<= im -3e-21)
       (* im (+ (* re (* 0.5 re)) -1.0))
       (if (<= im 8.2e-32)
         (- im)
         (if (<= im 7e+126) (- (* re (* 0.5 (* im re))) im) t_0))))))
double code(double re, double im) {
	double t_0 = (im * im) * (-1.0 / im);
	double tmp;
	if (im <= -2.45e+179) {
		tmp = t_0;
	} else if (im <= -3e-21) {
		tmp = im * ((re * (0.5 * re)) + -1.0);
	} else if (im <= 8.2e-32) {
		tmp = -im;
	} else if (im <= 7e+126) {
		tmp = (re * (0.5 * (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 * im) * ((-1.0d0) / im)
    if (im <= (-2.45d+179)) then
        tmp = t_0
    else if (im <= (-3d-21)) then
        tmp = im * ((re * (0.5d0 * re)) + (-1.0d0))
    else if (im <= 8.2d-32) then
        tmp = -im
    else if (im <= 7d+126) then
        tmp = (re * (0.5d0 * (im * re))) - im
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (im * im) * (-1.0 / im);
	double tmp;
	if (im <= -2.45e+179) {
		tmp = t_0;
	} else if (im <= -3e-21) {
		tmp = im * ((re * (0.5 * re)) + -1.0);
	} else if (im <= 8.2e-32) {
		tmp = -im;
	} else if (im <= 7e+126) {
		tmp = (re * (0.5 * (im * re))) - im;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (im * im) * (-1.0 / im)
	tmp = 0
	if im <= -2.45e+179:
		tmp = t_0
	elif im <= -3e-21:
		tmp = im * ((re * (0.5 * re)) + -1.0)
	elif im <= 8.2e-32:
		tmp = -im
	elif im <= 7e+126:
		tmp = (re * (0.5 * (im * re))) - im
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64(im * im) * Float64(-1.0 / im))
	tmp = 0.0
	if (im <= -2.45e+179)
		tmp = t_0;
	elseif (im <= -3e-21)
		tmp = Float64(im * Float64(Float64(re * Float64(0.5 * re)) + -1.0));
	elseif (im <= 8.2e-32)
		tmp = Float64(-im);
	elseif (im <= 7e+126)
		tmp = Float64(Float64(re * Float64(0.5 * Float64(im * re))) - im);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im * im) * (-1.0 / im);
	tmp = 0.0;
	if (im <= -2.45e+179)
		tmp = t_0;
	elseif (im <= -3e-21)
		tmp = im * ((re * (0.5 * re)) + -1.0);
	elseif (im <= 8.2e-32)
		tmp = -im;
	elseif (im <= 7e+126)
		tmp = (re * (0.5 * (im * re))) - im;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(im * im), $MachinePrecision] * N[(-1.0 / im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.45e+179], t$95$0, If[LessEqual[im, -3e-21], N[(im * N[(N[(re * N[(0.5 * re), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 8.2e-32], (-im), If[LessEqual[im, 7e+126], N[(N[(re * N[(0.5 * N[(im * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(im \cdot im\right) \cdot \frac{-1}{im}\\
\mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\
\;\;\;\;t_0\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -2.4499999999999999e179 or 7.0000000000000005e126 < 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 7.2%

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. metadata-eval94.6%

        \[\leadsto \cos re \cdot \frac{\color{blue}{0} - im \cdot im}{0 + im} \]
      5. neg-sub094.6%

        \[\leadsto \cos re \cdot \frac{\color{blue}{-im \cdot im}}{0 + im} \]
      6. +-lft-identity94.6%

        \[\leadsto \cos re \cdot \frac{-im \cdot im}{\color{blue}{im}} \]
      7. associate-*r/94.6%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(-im \cdot im\right)}{im}} \]
      8. neg-mul-194.6%

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(-1 \cdot \left(im \cdot im\right)\right)}}{im} \]
      9. associate-*l*94.6%

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

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

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

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(im \cdot \left(-im\right)\right)}{im}} \]
    9. Step-by-step derivation
      1. associate-/l*94.6%

        \[\leadsto \color{blue}{\frac{\cos re}{\frac{im}{im \cdot \left(-im\right)}}} \]
      2. associate-/r/94.6%

        \[\leadsto \color{blue}{\frac{\cos re}{im} \cdot \left(im \cdot \left(-im\right)\right)} \]
      3. distribute-rgt-neg-out94.6%

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

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

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

    if -2.4499999999999999e179 < im < -2.99999999999999991e-21

    1. Initial program 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right) - im} \]
    10. Step-by-step derivation
      1. sub-neg20.6%

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

        \[\leadsto \color{blue}{\left(\left(re \cdot re\right) \cdot 0.5\right) \cdot im} + \left(-im\right) \]
      3. neg-mul-120.6%

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

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

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

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

    if -2.99999999999999991e-21 < im < 8.1999999999999995e-32

    1. Initial program 5.5%

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

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

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

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

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

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

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

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

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

    if 8.1999999999999995e-32 < im < 7.0000000000000005e126

    1. Initial program 88.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-1}{im}\\ \mathbf{elif}\;im \leq -3 \cdot 10^{-21}:\\ \;\;\;\;im \cdot \left(re \cdot \left(0.5 \cdot re\right) + -1\right)\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{-32}:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 7 \cdot 10^{+126}:\\ \;\;\;\;re \cdot \left(0.5 \cdot \left(im \cdot re\right)\right) - im\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-1}{im}\\ \end{array} \]

Alternative 16: 47.4% accurate, 23.4× speedup?

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

\\
\begin{array}{l}
t_0 := \left(im \cdot im\right) \cdot \frac{-1}{im}\\
\mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\
\;\;\;\;t_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -2.4499999999999999e179 or 2e-8 < 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)} \]
    4. Taylor expanded in im around 0 6.9%

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

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

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

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

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

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

        \[\leadsto \cos re \cdot \color{blue}{\frac{0 \cdot 0 - im \cdot im}{0 + im}} \]
      4. metadata-eval74.4%

        \[\leadsto \cos re \cdot \frac{\color{blue}{0} - im \cdot im}{0 + im} \]
      5. neg-sub074.4%

        \[\leadsto \cos re \cdot \frac{\color{blue}{-im \cdot im}}{0 + im} \]
      6. +-lft-identity74.4%

        \[\leadsto \cos re \cdot \frac{-im \cdot im}{\color{blue}{im}} \]
      7. associate-*r/74.4%

        \[\leadsto \color{blue}{\frac{\cos re \cdot \left(-im \cdot im\right)}{im}} \]
      8. neg-mul-174.4%

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(-1 \cdot \left(im \cdot im\right)\right)}}{im} \]
      9. associate-*l*74.4%

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

        \[\leadsto \frac{\cos re \cdot \left(\color{blue}{\left(-im\right)} \cdot im\right)}{im} \]
      11. *-commutative74.4%

        \[\leadsto \frac{\cos re \cdot \color{blue}{\left(im \cdot \left(-im\right)\right)}}{im} \]
    8. Applied egg-rr74.4%

      \[\leadsto \color{blue}{\frac{\cos re \cdot \left(im \cdot \left(-im\right)\right)}{im}} \]
    9. Step-by-step derivation
      1. associate-/l*74.4%

        \[\leadsto \color{blue}{\frac{\cos re}{\frac{im}{im \cdot \left(-im\right)}}} \]
      2. associate-/r/74.4%

        \[\leadsto \color{blue}{\frac{\cos re}{im} \cdot \left(im \cdot \left(-im\right)\right)} \]
      3. distribute-rgt-neg-out74.4%

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

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

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

    if -2.4499999999999999e179 < im < -6.19999999999999973e35

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right) - im} \]
    10. Step-by-step derivation
      1. sub-neg30.3%

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

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

        \[\leadsto \color{blue}{\frac{\left(-im\right) \cdot \left(-im\right) - \left(im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\right) \cdot \left(im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\right)}{\left(-im\right) - im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)}} \]
      4. sqr-neg13.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{im \cdot im - {\left(\left(re \cdot 0.5\right) \cdot \left(re \cdot im\right)\right)}^{2}}{\left(-im\right) - \left(re \cdot 0.5\right) \cdot \color{blue}{\left(re \cdot im\right)}} \]
    11. Applied egg-rr13.5%

      \[\leadsto \color{blue}{\frac{im \cdot im - {\left(\left(re \cdot 0.5\right) \cdot \left(re \cdot im\right)\right)}^{2}}{\left(-im\right) - \left(re \cdot 0.5\right) \cdot \left(re \cdot im\right)}} \]
    12. Taylor expanded in re around inf 29.0%

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

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

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

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

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

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

    if -6.19999999999999973e35 < im < 2e-8

    1. Initial program 14.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.45 \cdot 10^{+179}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-1}{im}\\ \mathbf{elif}\;im \leq -6.2 \cdot 10^{+35}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\ \mathbf{elif}\;im \leq 2 \cdot 10^{-8}:\\ \;\;\;\;-im\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \frac{-1}{im}\\ \end{array} \]

Alternative 17: 32.1% accurate, 27.8× speedup?

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

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

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

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


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

    1. Initial program 53.9%

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

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

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

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

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

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

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

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

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

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

    if 6.8000000000000002e117 < re < 8.4999999999999994e231

    1. Initial program 46.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right) - im} \]
    10. Step-by-step derivation
      1. sub-neg32.6%

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

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

        \[\leadsto \color{blue}{\frac{\left(-im\right) \cdot \left(-im\right) - \left(im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\right) \cdot \left(im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\right)}{\left(-im\right) - im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)}} \]
      4. sqr-neg0.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{im \cdot im - {\left(\left(re \cdot 0.5\right) \cdot \left(re \cdot im\right)\right)}^{2}}{\left(-im\right) - \left(re \cdot 0.5\right) \cdot \color{blue}{\left(re \cdot im\right)}} \]
    11. Applied egg-rr1.0%

      \[\leadsto \color{blue}{\frac{im \cdot im - {\left(\left(re \cdot 0.5\right) \cdot \left(re \cdot im\right)\right)}^{2}}{\left(-im\right) - \left(re \cdot 0.5\right) \cdot \left(re \cdot im\right)}} \]
    12. Taylor expanded in re around inf 32.6%

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

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

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

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

        \[\leadsto \left(re \cdot re\right) \cdot \color{blue}{\left(im \cdot 0.5\right)} \]
    14. Simplified32.6%

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

    if 8.4999999999999994e231 < re

    1. Initial program 58.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow232.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 6.8 \cdot 10^{+117}:\\ \;\;\;\;-im\\ \mathbf{elif}\;re \leq 8.5 \cdot 10^{+231}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot 0.75\right)\\ \end{array} \]

Alternative 18: 31.4% accurate, 43.8× speedup?

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

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

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


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

    1. Initial program 53.5%

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

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

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

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

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

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

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

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

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

    if 4.2000000000000003e171 < re

    1. Initial program 56.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow225.8%

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

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

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

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

Alternative 19: 29.3% accurate, 154.5× speedup?

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(-1 \cdot im\right) \cdot \cos re} \]
    2. neg-mul-152.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 28.9%

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

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

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

    \[\leadsto -im \]

Alternative 20: 2.8% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -1.5 \]

Developer target: 99.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|im\right| < 1:\\ \;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (< (fabs im) 1.0)
   (-
    (*
     (cos re)
     (+
      (+ im (* (* (* 0.16666666666666666 im) im) im))
      (* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
   (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
double code(double re, double im) {
	double tmp;
	if (fabs(im) < 1.0) {
		tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
	} else {
		tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (abs(im) < 1.0d0) then
        tmp = -(cos(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
    else
        tmp = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (Math.abs(im) < 1.0) {
		tmp = -(Math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
	} else {
		tmp = (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if math.fabs(im) < 1.0:
		tmp = -(math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)))
	else:
		tmp = (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (abs(im) < 1.0)
		tmp = Float64(-Float64(cos(re) * Float64(Float64(im + Float64(Float64(Float64(0.16666666666666666 * im) * im) * im)) + Float64(Float64(Float64(Float64(Float64(0.008333333333333333 * im) * im) * im) * im) * im))));
	else
		tmp = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (abs(im) < 1.0)
		tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
	else
		tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Cos[re], $MachinePrecision] * N[(N[(im + N[(N[(N[(0.16666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023297 
(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))))