math.sin on complex, imaginary part

Percentage Accurate: 53.9% → 99.7%
Time: 10.3s
Alternatives: 15
Speedup: 23.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 15 alternatives:

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

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-im} - e^{im}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 4 \cdot 10^{-5}\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(\left(im \cdot \left(im \cdot im\right)\right) \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 (- INFINITY)) (not (<= t_0 4e-5)))
     (* (* 0.5 (cos re)) t_0)
     (*
      (cos re)
      (+
       (+
        (* (pow im 7.0) -0.0001984126984126984)
        (* (pow im 5.0) -0.008333333333333333))
       (- (* (* im (* im im)) -0.16666666666666666) im))))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 4e-5)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * (((pow(im, 7.0) * -0.0001984126984126984) + (pow(im, 5.0) * -0.008333333333333333)) + (((im * (im * im)) * -0.16666666666666666) - im));
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = Math.exp(-im) - Math.exp(im);
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 4e-5)) {
		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)) + (((im * (im * im)) * -0.16666666666666666) - im));
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 4e-5):
		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)) + (((im * (im * im)) * -0.16666666666666666) - im))
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 4e-5))
		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(Float64(im * Float64(im * im)) * -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 <= -Inf) || ~((t_0 <= 4e-5)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = cos(re) * ((((im ^ 7.0) * -0.0001984126984126984) + ((im ^ 5.0) * -0.008333333333333333)) + (((im * (im * im)) * -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, (-Infinity)], N[Not[LessEqual[t$95$0, 4e-5]], $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[(im * N[(im * im), $MachinePrecision]), $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 -\infty \lor \neg \left(t_0 \leq 4 \cdot 10^{-5}\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(\left(im \cdot \left(im \cdot im\right)\right) \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)) < -inf.0 or 4.00000000000000033e-5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im))

    1. Initial program 100.0%

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

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

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

    if -inf.0 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 4.00000000000000033e-5

    1. Initial program 10.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -\infty \lor \neg \left(e^{-im} - e^{im} \leq 4 \cdot 10^{-5}\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(\left(im \cdot \left(im \cdot im\right)\right) \cdot -0.16666666666666666 - im\right)\right)\\ \end{array} \]

Alternative 2: 99.9% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

    if -0.0200000000000000004 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 4.00000000000000033e-5

    1. Initial program 9.4%

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

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

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

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

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

Alternative 3: 99.9% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

    if -0.0050000000000000001 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 4.00000000000000033e-5

    1. Initial program 8.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 97.7% accurate, 1.4× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < -5.29999999999999979e39 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.0001984126984126984 \cdot \left(\cos re \cdot {im}^{7}\right)} \]
    8. Step-by-step derivation
      1. associate-*r*98.3%

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

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

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

    if -5.29999999999999979e39 < im < -0.0550000000000000003

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0550000000000000003 < im < 0.10000000000000001

    1. Initial program 10.1%

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

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

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

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

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

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

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

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

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

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

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

    if 0.10000000000000001 < 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. sub0-neg100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.3 \cdot 10^{+39}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{elif}\;im \leq -0.055:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{elif}\;im \leq 0.1:\\ \;\;\;\;\cos re \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \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}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \end{array} \]

Alternative 5: 95.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -5.8 \cdot 10^{+102} \lor \neg \left(im \leq -0.042 \lor \neg \left(im \leq 0.09\right) \land im \leq 4.4 \cdot 10^{+100}\right):\\ \;\;\;\;\cos re \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im -5.8e+102)
         (not (or (<= im -0.042) (and (not (<= im 0.09)) (<= im 4.4e+100)))))
   (* (cos re) (- (* (* im (* im im)) -0.16666666666666666) im))
   (* 0.5 (- (exp (- im)) (exp im)))))
double code(double re, double im) {
	double tmp;
	if ((im <= -5.8e+102) || !((im <= -0.042) || (!(im <= 0.09) && (im <= 4.4e+100)))) {
		tmp = cos(re) * (((im * (im * im)) * -0.16666666666666666) - im);
	} else {
		tmp = 0.5 * (exp(-im) - exp(im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= (-5.8d+102)) .or. (.not. (im <= (-0.042d0)) .or. (.not. (im <= 0.09d0)) .and. (im <= 4.4d+100))) then
        tmp = cos(re) * (((im * (im * im)) * (-0.16666666666666666d0)) - im)
    else
        tmp = 0.5d0 * (exp(-im) - exp(im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= -5.8e+102) || !((im <= -0.042) || (!(im <= 0.09) && (im <= 4.4e+100)))) {
		tmp = Math.cos(re) * (((im * (im * im)) * -0.16666666666666666) - im);
	} else {
		tmp = 0.5 * (Math.exp(-im) - Math.exp(im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= -5.8e+102) or not ((im <= -0.042) or (not (im <= 0.09) and (im <= 4.4e+100))):
		tmp = math.cos(re) * (((im * (im * im)) * -0.16666666666666666) - im)
	else:
		tmp = 0.5 * (math.exp(-im) - math.exp(im))
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= -5.8e+102) || !((im <= -0.042) || (!(im <= 0.09) && (im <= 4.4e+100))))
		tmp = Float64(cos(re) * Float64(Float64(Float64(im * Float64(im * im)) * -0.16666666666666666) - im));
	else
		tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= -5.8e+102) || ~(((im <= -0.042) || (~((im <= 0.09)) && (im <= 4.4e+100)))))
		tmp = cos(re) * (((im * (im * im)) * -0.16666666666666666) - im);
	else
		tmp = 0.5 * (exp(-im) - exp(im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, -5.8e+102], N[Not[Or[LessEqual[im, -0.042], And[N[Not[LessEqual[im, 0.09]], $MachinePrecision], LessEqual[im, 4.4e+100]]]], $MachinePrecision]], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(im * N[(im * im), $MachinePrecision]), $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -5.8 \cdot 10^{+102} \lor \neg \left(im \leq -0.042 \lor \neg \left(im \leq 0.09\right) \land im \leq 4.4 \cdot 10^{+100}\right):\\
\;\;\;\;\cos re \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot -0.16666666666666666 - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -5.8000000000000005e102 or -0.0420000000000000026 < im < 0.089999999999999997 or 4.4000000000000001e100 < im

    1. Initial program 44.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.8000000000000005e102 < im < -0.0420000000000000026 or 0.089999999999999997 < im < 4.4000000000000001e100

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.8 \cdot 10^{+102} \lor \neg \left(im \leq -0.042 \lor \neg \left(im \leq 0.09\right) \land im \leq 4.4 \cdot 10^{+100}\right):\\ \;\;\;\;\cos re \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \]

Alternative 6: 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 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{if}\;im \leq -7.5 \cdot 10^{+51}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.0215:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 0.118:\\ \;\;\;\;\cos re \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \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 (* (pow im 7.0) (* (cos re) -0.0001984126984126984))))
   (if (<= im -7.5e+51)
     t_1
     (if (<= im -0.0215)
       t_0
       (if (<= im 0.118)
         (* (cos re) (- (* (* im (* im im)) -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 = pow(im, 7.0) * (cos(re) * -0.0001984126984126984);
	double tmp;
	if (im <= -7.5e+51) {
		tmp = t_1;
	} else if (im <= -0.0215) {
		tmp = t_0;
	} else if (im <= 0.118) {
		tmp = cos(re) * (((im * (im * im)) * -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 = (im ** 7.0d0) * (cos(re) * (-0.0001984126984126984d0))
    if (im <= (-7.5d+51)) then
        tmp = t_1
    else if (im <= (-0.0215d0)) then
        tmp = t_0
    else if (im <= 0.118d0) then
        tmp = cos(re) * (((im * (im * im)) * (-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 = Math.pow(im, 7.0) * (Math.cos(re) * -0.0001984126984126984);
	double tmp;
	if (im <= -7.5e+51) {
		tmp = t_1;
	} else if (im <= -0.0215) {
		tmp = t_0;
	} else if (im <= 0.118) {
		tmp = Math.cos(re) * (((im * (im * im)) * -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 = math.pow(im, 7.0) * (math.cos(re) * -0.0001984126984126984)
	tmp = 0
	if im <= -7.5e+51:
		tmp = t_1
	elif im <= -0.0215:
		tmp = t_0
	elif im <= 0.118:
		tmp = math.cos(re) * (((im * (im * im)) * -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((im ^ 7.0) * Float64(cos(re) * -0.0001984126984126984))
	tmp = 0.0
	if (im <= -7.5e+51)
		tmp = t_1;
	elseif (im <= -0.0215)
		tmp = t_0;
	elseif (im <= 0.118)
		tmp = Float64(cos(re) * Float64(Float64(Float64(im * Float64(im * im)) * -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 = (im ^ 7.0) * (cos(re) * -0.0001984126984126984);
	tmp = 0.0;
	if (im <= -7.5e+51)
		tmp = t_1;
	elseif (im <= -0.0215)
		tmp = t_0;
	elseif (im <= 0.118)
		tmp = cos(re) * (((im * (im * im)) * -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[(N[Power[im, 7.0], $MachinePrecision] * N[(N[Cos[re], $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.5e+51], t$95$1, If[LessEqual[im, -0.0215], t$95$0, If[LessEqual[im, 0.118], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(im * N[(im * im), $MachinePrecision]), $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 := {im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\
\mathbf{if}\;im \leq -7.5 \cdot 10^{+51}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 0.118:\\
\;\;\;\;\cos re \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \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 < -7.4999999999999999e51 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.4999999999999999e51 < im < -0.021499999999999998 or 0.11799999999999999 < im < 1.09999999999999998e44

    1. Initial program 99.9%

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

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

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

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

    if -0.021499999999999998 < im < 0.11799999999999999

    1. Initial program 10.1%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.5 \cdot 10^{+51}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \mathbf{elif}\;im \leq -0.0215:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.118:\\ \;\;\;\;\cos re \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \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}:\\ \;\;\;\;{im}^{7} \cdot \left(\cos re \cdot -0.0001984126984126984\right)\\ \end{array} \]

Alternative 7: 84.8% accurate, 2.8× speedup?

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

\\
\cos re \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot -0.16666666666666666 - im\right)
\end{array}
Derivation
  1. Initial program 56.1%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \cos re \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot -0.16666666666666666 - im\right) \]

Alternative 8: 75.2% accurate, 2.8× speedup?

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

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

\mathbf{elif}\;im \leq -850:\\
\;\;\;\;\left(im \cdot \left(re \cdot re\right)\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -9.99999999999999921e133 or 1.79999999999999999e56 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Step-by-step derivation
      1. unpow3100.0%

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

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

    if -9.99999999999999921e133 < im < -850

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -850 < im < 1.79999999999999999e56

    1. Initial program 19.7%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1 \cdot 10^{+134}:\\ \;\;\;\;\left(im \cdot \left(im \cdot im\right)\right) \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq -850:\\ \;\;\;\;\left(im \cdot \left(re \cdot re\right)\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+56}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot \left(im \cdot im\right)\right) \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 9: 53.8% accurate, 18.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.2 \cdot 10^{+134} \lor \neg \left(im \leq -520\right):\\
\;\;\;\;\left(im \cdot \left(im \cdot im\right)\right) \cdot -0.16666666666666666 - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -6.19999999999999963e134 or -520 < im

    1. Initial program 50.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Step-by-step derivation
      1. unpow395.3%

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

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

    if -6.19999999999999963e134 < im < -520

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -6.2 \cdot 10^{+134} \lor \neg \left(im \leq -520\right):\\ \;\;\;\;\left(im \cdot \left(im \cdot im\right)\right) \cdot -0.16666666666666666 - im\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot \left(re \cdot re\right)\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\\ \end{array} \]

Alternative 10: 54.5% accurate, 23.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.6 \cdot 10^{+109} \lor \neg \left(im \leq -650\right):\\
\;\;\;\;\left(im \cdot \left(im \cdot im\right)\right) \cdot -0.16666666666666666 - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -3.6e109 or -650 < im

    1. Initial program 50.7%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Step-by-step derivation
      1. unpow395.3%

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

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

    if -3.6e109 < im < -650

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \cdot \left(e^{-im} - e^{im}\right) \]
    9. Simplified32.1%

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

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

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

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

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

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

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

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

Alternative 11: 54.6% accurate, 23.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.6 \cdot 10^{+109} \lor \neg \left(im \leq -360\right):\\
\;\;\;\;\left(im \cdot \left(im \cdot im\right)\right) \cdot -0.16666666666666666 - im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -3.6e109 or -360 < im

    1. Initial program 50.7%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3} - im} \]
    8. Step-by-step derivation
      1. unpow395.3%

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

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

    if -3.6e109 < im < -360

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 33.3% accurate, 27.8× speedup?

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

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

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

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


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

    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. sub0-neg53.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.8%

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

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

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

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

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

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

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

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

    if 3.9999999999999997e23 < re < 3.09999999999999984e175

    1. Initial program 67.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \cdot \left(e^{-im} - e^{im}\right) \]
    9. Simplified32.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.09999999999999984e175 < re

    1. Initial program 62.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(re \cdot re\right)} \cdot -0.25\right) \cdot \left(e^{-im} - e^{im}\right) \]
    9. Simplified20.1%

      \[\leadsto \color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    10. Applied egg-rr37.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 4 \cdot 10^{+23}:\\ \;\;\;\;-im\\ \mathbf{elif}\;re \leq 3.1 \cdot 10^{+175}:\\ \;\;\;\;re \cdot \left(im \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-0.25 \cdot \left(re \cdot re\right)\right) \cdot 27\\ \end{array} \]

Alternative 13: 33.8% accurate, 34.1× speedup?

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

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

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


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

    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. sub0-neg53.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.8%

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

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

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

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

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

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

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

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

    if 3.9999999999999997e23 < re

    1. Initial program 64.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 33.8% accurate, 34.1× speedup?

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

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

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


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

    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. sub0-neg53.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.8%

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

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

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

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

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

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

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

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

    if 3.9999999999999997e23 < re

    1. Initial program 64.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -im \]

Developer target: 99.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|im\right| < 1:\\ \;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (< (fabs im) 1.0)
   (-
    (*
     (cos re)
     (+
      (+ im (* (* (* 0.16666666666666666 im) im) im))
      (* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
   (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
double code(double re, double im) {
	double tmp;
	if (fabs(im) < 1.0) {
		tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
	} else {
		tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (abs(im) < 1.0d0) then
        tmp = -(cos(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
    else
        tmp = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (Math.abs(im) < 1.0) {
		tmp = -(Math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
	} else {
		tmp = (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if math.fabs(im) < 1.0:
		tmp = -(math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)))
	else:
		tmp = (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (abs(im) < 1.0)
		tmp = Float64(-Float64(cos(re) * Float64(Float64(im + Float64(Float64(Float64(0.16666666666666666 * im) * im) * im)) + Float64(Float64(Float64(Float64(Float64(0.008333333333333333 * im) * im) * im) * im) * im))));
	else
		tmp = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (abs(im) < 1.0)
		tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
	else
		tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Cos[re], $MachinePrecision] * N[(N[(im + N[(N[(N[(0.16666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023200 
(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))))