math.sin on complex, imaginary part

Percentage Accurate: 54.3% → 99.5%
Time: 10.4s
Alternatives: 16
Speedup: 2.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 16 alternatives:

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

Initial Program: 54.3% 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.5% 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 5 \cdot 10^{-5}\right):\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (exp (- im)) (exp im))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e-5)))
     (* (* 0.5 (cos re)) t_0)
     (* (cos re) (- (* (pow im 3.0) -0.16666666666666666) im)))))
double code(double re, double im) {
	double t_0 = exp(-im) - exp(im);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 5e-5)) {
		tmp = (0.5 * cos(re)) * t_0;
	} else {
		tmp = cos(re) * ((pow(im, 3.0) * -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 <= 5e-5)) {
		tmp = (0.5 * Math.cos(re)) * t_0;
	} else {
		tmp = Math.cos(re) * ((Math.pow(im, 3.0) * -0.16666666666666666) - im);
	}
	return tmp;
}
def code(re, im):
	t_0 = math.exp(-im) - math.exp(im)
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 5e-5):
		tmp = (0.5 * math.cos(re)) * t_0
	else:
		tmp = math.cos(re) * ((math.pow(im, 3.0) * -0.16666666666666666) - im)
	return tmp
function code(re, im)
	t_0 = Float64(exp(Float64(-im)) - exp(im))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 5e-5))
		tmp = Float64(Float64(0.5 * cos(re)) * t_0);
	else
		tmp = Float64(cos(re) * Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = exp(-im) - exp(im);
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 5e-5)))
		tmp = (0.5 * cos(re)) * t_0;
	else
		tmp = cos(re) * (((im ^ 3.0) * -0.16666666666666666) - im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 5e-5]], $MachinePrecision]], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 8.9%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 94.3% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -8.6 \cdot 10^{+89} \lor \neg \left(im \leq -2.3 \cdot 10^{+15} \lor \neg \left(im \leq 0.055\right) \land im \leq 5.7 \cdot 10^{+102}\right):\\
\;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -8.6000000000000003e89 or -2.3e15 < im < 0.0550000000000000003 or 5.6999999999999999e102 < im

    1. Initial program 47.6%

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

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

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

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

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

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

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

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

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

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

    if -8.6000000000000003e89 < im < -2.3e15 or 0.0550000000000000003 < im < 5.6999999999999999e102

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -8.6 \cdot 10^{+89} \lor \neg \left(im \leq -2.3 \cdot 10^{+15} \lor \neg \left(im \leq 0.055\right) \land im \leq 5.7 \cdot 10^{+102}\right):\\ \;\;\;\;\cos re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \]

Alternative 3: 93.5% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(e^{-im} - e^{im}\right)\\
t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\
\mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(\color{blue}{9} - im \cdot im\right) \cdot \cos re}{-3 + im} \]
      5. +-commutative100.0%

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

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

    if -1.35000000000000003e154 < im < -1.7e-5 or 2.70000000000000003e-4 < im < 1.31999999999999998e154

    1. Initial program 99.8%

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

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

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

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

    if -1.7e-5 < im < 2.70000000000000003e-4

    1. Initial program 8.2%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \mathbf{elif}\;im \leq -1.7 \cdot 10^{-5}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 0.00027:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \end{array} \]

Alternative 4: 83.5% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\ t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ t_2 := \left(-3 - im\right) \cdot \mathsf{fma}\left(re, 0.5 \cdot re, 1\right)\\ \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -4.8 \cdot 10^{+85}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -1.48 \cdot 10^{+23}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq 515000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+100}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im))
        (t_1 (/ (* (cos re) (- 9.0 (* im im))) (+ im -3.0)))
        (t_2 (* (- -3.0 im) (fma re (* 0.5 re) 1.0))))
   (if (<= im -1.35e+154)
     t_1
     (if (<= im -4.8e+85)
       t_0
       (if (<= im -1.48e+23)
         t_2
         (if (<= im 515000000.0)
           (* (cos re) (- im))
           (if (<= im 4.2e+100) t_2 (if (<= im 1.32e+154) t_0 t_1))))))))
double code(double re, double im) {
	double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double t_1 = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
	double t_2 = (-3.0 - im) * fma(re, (0.5 * re), 1.0);
	double tmp;
	if (im <= -1.35e+154) {
		tmp = t_1;
	} else if (im <= -4.8e+85) {
		tmp = t_0;
	} else if (im <= -1.48e+23) {
		tmp = t_2;
	} else if (im <= 515000000.0) {
		tmp = cos(re) * -im;
	} else if (im <= 4.2e+100) {
		tmp = t_2;
	} else if (im <= 1.32e+154) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	t_1 = Float64(Float64(cos(re) * Float64(9.0 - Float64(im * im))) / Float64(im + -3.0))
	t_2 = Float64(Float64(-3.0 - im) * fma(re, Float64(0.5 * re), 1.0))
	tmp = 0.0
	if (im <= -1.35e+154)
		tmp = t_1;
	elseif (im <= -4.8e+85)
		tmp = t_0;
	elseif (im <= -1.48e+23)
		tmp = t_2;
	elseif (im <= 515000000.0)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 4.2e+100)
		tmp = t_2;
	elseif (im <= 1.32e+154)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[re], $MachinePrecision] * N[(9.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-3.0 - im), $MachinePrecision] * N[(re * N[(0.5 * re), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -1.35e+154], t$95$1, If[LessEqual[im, -4.8e+85], t$95$0, If[LessEqual[im, -1.48e+23], t$95$2, If[LessEqual[im, 515000000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 4.2e+100], t$95$2, If[LessEqual[im, 1.32e+154], t$95$0, t$95$1]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\
t_2 := \left(-3 - im\right) \cdot \mathsf{fma}\left(re, 0.5 \cdot re, 1\right)\\
\mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -4.8 \cdot 10^{+85}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -1.48 \cdot 10^{+23}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;im \leq 4.2 \cdot 10^{+100}:\\
\;\;\;\;t_2\\

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(\color{blue}{9} - im \cdot im\right) \cdot \cos re}{-3 + im} \]
      5. +-commutative100.0%

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

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

    if -1.35000000000000003e154 < im < -4.79999999999999993e85 or 4.1999999999999997e100 < im < 1.31999999999999998e154

    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 85.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-neg85.4%

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

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

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

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

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

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

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

    if -4.79999999999999993e85 < im < -1.4799999999999999e23 or 5.15e8 < im < 4.1999999999999997e100

    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 5.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-neg5.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(im + 3\right) \cdot \left(\left(-1\right) + \color{blue}{\left(--0.5\right)} \cdot {re}^{2}\right) \]
      6. distribute-lft-neg-in8.5%

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

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

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

        \[\leadsto \left(im + 3\right) \cdot \left(\left(-1\right) + \left(-\color{blue}{re \cdot \left(-0.5 \cdot re\right)}\right)\right) \]
      10. distribute-neg-in8.5%

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

        \[\leadsto \left(im + 3\right) \cdot \left(-\color{blue}{\left(re \cdot \left(-0.5 \cdot re\right) + 1\right)}\right) \]
      12. distribute-neg-in8.5%

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

        \[\leadsto \left(im + 3\right) \cdot \left(\left(-\color{blue}{\left(-0.5 \cdot re\right) \cdot re}\right) + \left(-1\right)\right) \]
      14. distribute-lft-neg-in8.5%

        \[\leadsto \left(im + 3\right) \cdot \left(\color{blue}{\left(--0.5 \cdot re\right) \cdot re} + \left(-1\right)\right) \]
      15. distribute-lft-neg-in8.5%

        \[\leadsto \left(im + 3\right) \cdot \left(\color{blue}{\left(\left(--0.5\right) \cdot re\right)} \cdot re + \left(-1\right)\right) \]
      16. metadata-eval8.5%

        \[\leadsto \left(im + 3\right) \cdot \left(\left(\color{blue}{0.5} \cdot re\right) \cdot re + \left(-1\right)\right) \]
      17. metadata-eval8.5%

        \[\leadsto \left(im + 3\right) \cdot \left(\left(0.5 \cdot re\right) \cdot re + \color{blue}{-1}\right) \]
    10. Simplified8.5%

      \[\leadsto \color{blue}{\left(im + 3\right) \cdot \left(\left(0.5 \cdot re\right) \cdot re + -1\right)} \]
    11. Step-by-step derivation
      1. distribute-rgt-in8.5%

        \[\leadsto \color{blue}{\left(\left(0.5 \cdot re\right) \cdot re\right) \cdot \left(im + 3\right) + -1 \cdot \left(im + 3\right)} \]
      2. add-sqr-sqrt8.5%

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

        \[\leadsto \color{blue}{\sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(\sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(im + 3\right)\right)} + -1 \cdot \left(im + 3\right) \]
      4. *-commutative8.5%

        \[\leadsto \sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(\sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(im + 3\right)\right) + \color{blue}{\left(im + 3\right) \cdot -1} \]
      5. fma-def8.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\left(0.5 \cdot re\right) \cdot re}, \sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(im + 3\right), \left(im + 3\right) \cdot -1\right)} \]
    12. Applied egg-rr0.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re \cdot \sqrt{-0.5}, \left(re \cdot \sqrt{-0.5}\right) \cdot \left(im + 3\right), \mathsf{fma}\left(im, -1, -3\right)\right)} \]
    13. Step-by-step derivation
      1. fma-udef0.0%

        \[\leadsto \color{blue}{\left(re \cdot \sqrt{-0.5}\right) \cdot \left(\left(re \cdot \sqrt{-0.5}\right) \cdot \left(im + 3\right)\right) + \mathsf{fma}\left(im, -1, -3\right)} \]
      2. +-commutative0.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \sqrt{-0.5}\right) \cdot \left(\left(re \cdot \sqrt{-0.5}\right) \cdot \left(im + 3\right)\right)} \]
      3. *-lft-identity0.0%

        \[\leadsto \color{blue}{1 \cdot \mathsf{fma}\left(im, -1, -3\right)} + \left(re \cdot \sqrt{-0.5}\right) \cdot \left(\left(re \cdot \sqrt{-0.5}\right) \cdot \left(im + 3\right)\right) \]
      4. associate-*r*0.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left(re \cdot \sqrt{-0.5}\right) \cdot \left(re \cdot \sqrt{-0.5}\right)\right) \cdot \left(im + 3\right)} \]
      5. swap-sqr0.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left(re \cdot re\right) \cdot \left(\sqrt{-0.5} \cdot \sqrt{-0.5}\right)\right)} \cdot \left(im + 3\right) \]
      6. unpow20.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\color{blue}{{re}^{2}} \cdot \left(\sqrt{-0.5} \cdot \sqrt{-0.5}\right)\right) \cdot \left(im + 3\right) \]
      7. rem-square-sqrt28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left({re}^{2} \cdot \color{blue}{-0.5}\right) \cdot \left(im + 3\right) \]
      8. metadata-eval28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left({re}^{2} \cdot \color{blue}{\left(0.5 \cdot -1\right)}\right) \cdot \left(im + 3\right) \]
      9. associate-*l*28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left({re}^{2} \cdot 0.5\right) \cdot -1\right)} \cdot \left(im + 3\right) \]
      10. unpow228.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) \cdot -1\right) \cdot \left(im + 3\right) \]
      11. associate-*r*28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\color{blue}{\left(re \cdot \left(re \cdot 0.5\right)\right)} \cdot -1\right) \cdot \left(im + 3\right) \]
      12. *-commutative28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\color{blue}{\left(\left(re \cdot 0.5\right) \cdot re\right)} \cdot -1\right) \cdot \left(im + 3\right) \]
      13. associate-*r*28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left(re \cdot 0.5\right) \cdot \left(re \cdot -1\right)\right)} \cdot \left(im + 3\right) \]
      14. *-commutative28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left(re \cdot -1\right) \cdot \left(re \cdot 0.5\right)\right)} \cdot \left(im + 3\right) \]
      15. *-commutative28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\color{blue}{\left(-1 \cdot re\right)} \cdot \left(re \cdot 0.5\right)\right) \cdot \left(im + 3\right) \]
      16. associate-*l*28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(-1 \cdot \left(re \cdot \left(re \cdot 0.5\right)\right)\right)} \cdot \left(im + 3\right) \]
      17. neg-mul-128.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(-re \cdot \left(re \cdot 0.5\right)\right)} \cdot \left(im + 3\right) \]
      18. distribute-lft-neg-in28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(-\left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(im + 3\right)\right)} \]
      19. distribute-rgt-neg-in28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(-\left(im + 3\right)\right)} \]
      20. neg-mul-128.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \color{blue}{\left(-1 \cdot \left(im + 3\right)\right)} \]
      21. distribute-rgt-in28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \color{blue}{\left(im \cdot -1 + 3 \cdot -1\right)} \]
      22. metadata-eval28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(im \cdot -1 + \color{blue}{-3}\right) \]
      23. fma-udef28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \color{blue}{\mathsf{fma}\left(im, -1, -3\right)} \]
    14. Simplified28.8%

      \[\leadsto \color{blue}{\left(-3 - im\right) \cdot \mathsf{fma}\left(re, re \cdot 0.5, 1\right)} \]

    if -1.4799999999999999e23 < im < 5.15e8

    1. Initial program 13.4%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \mathbf{elif}\;im \leq -4.8 \cdot 10^{+85}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq -1.48 \cdot 10^{+23}:\\ \;\;\;\;\left(-3 - im\right) \cdot \mathsf{fma}\left(re, 0.5 \cdot re, 1\right)\\ \mathbf{elif}\;im \leq 515000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+100}:\\ \;\;\;\;\left(-3 - im\right) \cdot \mathsf{fma}\left(re, 0.5 \cdot re, 1\right)\\ \mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \end{array} \]

Alternative 5: 81.2% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\ t_1 := \left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot t_0\\ \mathbf{if}\;im \leq -1.75 \cdot 10^{+84}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -1.55 \cdot 10^{+23}:\\ \;\;\;\;\left(-3 - im\right) \cdot \mathsf{fma}\left(re, 0.5 \cdot re, 1\right)\\ \mathbf{elif}\;im \leq -1.7 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 9000000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(t_0 \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im))
        (t_1 (* (+ (* -0.5 (* re re)) 1.0) t_0)))
   (if (<= im -1.75e+84)
     t_1
     (if (<= im -1.55e+23)
       (* (- -3.0 im) (fma re (* 0.5 re) 1.0))
       (if (<= im -1.7e-5)
         t_1
         (if (<= im 9000000000.0)
           (* (cos re) (- im))
           (if (<= im 1.32e+154)
             (* re (* t_0 (* 0.5 re)))
             (/ (* (cos re) (- 9.0 (* im im))) (+ im -3.0)))))))))
double code(double re, double im) {
	double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double t_1 = ((-0.5 * (re * re)) + 1.0) * t_0;
	double tmp;
	if (im <= -1.75e+84) {
		tmp = t_1;
	} else if (im <= -1.55e+23) {
		tmp = (-3.0 - im) * fma(re, (0.5 * re), 1.0);
	} else if (im <= -1.7e-5) {
		tmp = t_1;
	} else if (im <= 9000000000.0) {
		tmp = cos(re) * -im;
	} else if (im <= 1.32e+154) {
		tmp = re * (t_0 * (0.5 * re));
	} else {
		tmp = (cos(re) * (9.0 - (im * im))) / (im + -3.0);
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	t_1 = Float64(Float64(Float64(-0.5 * Float64(re * re)) + 1.0) * t_0)
	tmp = 0.0
	if (im <= -1.75e+84)
		tmp = t_1;
	elseif (im <= -1.55e+23)
		tmp = Float64(Float64(-3.0 - im) * fma(re, Float64(0.5 * re), 1.0));
	elseif (im <= -1.7e-5)
		tmp = t_1;
	elseif (im <= 9000000000.0)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 1.32e+154)
		tmp = Float64(re * Float64(t_0 * Float64(0.5 * re)));
	else
		tmp = Float64(Float64(cos(re) * Float64(9.0 - Float64(im * im))) / Float64(im + -3.0));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(-0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[im, -1.75e+84], t$95$1, If[LessEqual[im, -1.55e+23], N[(N[(-3.0 - im), $MachinePrecision] * N[(re * N[(0.5 * re), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -1.7e-5], t$95$1, If[LessEqual[im, 9000000000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 1.32e+154], N[(re * N[(t$95$0 * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[re], $MachinePrecision] * N[(9.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im + -3.0), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
t_1 := \left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot t_0\\
\mathbf{if}\;im \leq -1.75 \cdot 10^{+84}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq -1.7 \cdot 10^{-5}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;re \cdot \left(t_0 \cdot \left(0.5 \cdot re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < -1.7499999999999999e84 or -1.54999999999999985e23 < im < -1.7e-5

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.7499999999999999e84 < im < -1.54999999999999985e23

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(im + 3\right) \cdot \left(\left(-1\right) + \color{blue}{\left(--0.5\right)} \cdot {re}^{2}\right) \]
      6. distribute-lft-neg-in2.5%

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

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

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

        \[\leadsto \left(im + 3\right) \cdot \left(\left(-1\right) + \left(-\color{blue}{re \cdot \left(-0.5 \cdot re\right)}\right)\right) \]
      10. distribute-neg-in2.5%

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

        \[\leadsto \left(im + 3\right) \cdot \left(-\color{blue}{\left(re \cdot \left(-0.5 \cdot re\right) + 1\right)}\right) \]
      12. distribute-neg-in2.5%

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

        \[\leadsto \left(im + 3\right) \cdot \left(\left(-\color{blue}{\left(-0.5 \cdot re\right) \cdot re}\right) + \left(-1\right)\right) \]
      14. distribute-lft-neg-in2.5%

        \[\leadsto \left(im + 3\right) \cdot \left(\color{blue}{\left(--0.5 \cdot re\right) \cdot re} + \left(-1\right)\right) \]
      15. distribute-lft-neg-in2.5%

        \[\leadsto \left(im + 3\right) \cdot \left(\color{blue}{\left(\left(--0.5\right) \cdot re\right)} \cdot re + \left(-1\right)\right) \]
      16. metadata-eval2.5%

        \[\leadsto \left(im + 3\right) \cdot \left(\left(\color{blue}{0.5} \cdot re\right) \cdot re + \left(-1\right)\right) \]
      17. metadata-eval2.5%

        \[\leadsto \left(im + 3\right) \cdot \left(\left(0.5 \cdot re\right) \cdot re + \color{blue}{-1}\right) \]
    10. Simplified2.5%

      \[\leadsto \color{blue}{\left(im + 3\right) \cdot \left(\left(0.5 \cdot re\right) \cdot re + -1\right)} \]
    11. Step-by-step derivation
      1. distribute-rgt-in2.5%

        \[\leadsto \color{blue}{\left(\left(0.5 \cdot re\right) \cdot re\right) \cdot \left(im + 3\right) + -1 \cdot \left(im + 3\right)} \]
      2. add-sqr-sqrt2.5%

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

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

        \[\leadsto \sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(\sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(im + 3\right)\right) + \color{blue}{\left(im + 3\right) \cdot -1} \]
      5. fma-def2.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\left(0.5 \cdot re\right) \cdot re}, \sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(im + 3\right), \left(im + 3\right) \cdot -1\right)} \]
    12. Applied egg-rr0.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re \cdot \sqrt{-0.5}, \left(re \cdot \sqrt{-0.5}\right) \cdot \left(im + 3\right), \mathsf{fma}\left(im, -1, -3\right)\right)} \]
    13. Step-by-step derivation
      1. fma-udef0.0%

        \[\leadsto \color{blue}{\left(re \cdot \sqrt{-0.5}\right) \cdot \left(\left(re \cdot \sqrt{-0.5}\right) \cdot \left(im + 3\right)\right) + \mathsf{fma}\left(im, -1, -3\right)} \]
      2. +-commutative0.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \sqrt{-0.5}\right) \cdot \left(\left(re \cdot \sqrt{-0.5}\right) \cdot \left(im + 3\right)\right)} \]
      3. *-lft-identity0.0%

        \[\leadsto \color{blue}{1 \cdot \mathsf{fma}\left(im, -1, -3\right)} + \left(re \cdot \sqrt{-0.5}\right) \cdot \left(\left(re \cdot \sqrt{-0.5}\right) \cdot \left(im + 3\right)\right) \]
      4. associate-*r*0.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left(re \cdot \sqrt{-0.5}\right) \cdot \left(re \cdot \sqrt{-0.5}\right)\right) \cdot \left(im + 3\right)} \]
      5. swap-sqr0.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left(re \cdot re\right) \cdot \left(\sqrt{-0.5} \cdot \sqrt{-0.5}\right)\right)} \cdot \left(im + 3\right) \]
      6. unpow20.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\color{blue}{{re}^{2}} \cdot \left(\sqrt{-0.5} \cdot \sqrt{-0.5}\right)\right) \cdot \left(im + 3\right) \]
      7. rem-square-sqrt29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left({re}^{2} \cdot \color{blue}{-0.5}\right) \cdot \left(im + 3\right) \]
      8. metadata-eval29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left({re}^{2} \cdot \color{blue}{\left(0.5 \cdot -1\right)}\right) \cdot \left(im + 3\right) \]
      9. associate-*l*29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left({re}^{2} \cdot 0.5\right) \cdot -1\right)} \cdot \left(im + 3\right) \]
      10. unpow229.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) \cdot -1\right) \cdot \left(im + 3\right) \]
      11. associate-*r*29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\color{blue}{\left(re \cdot \left(re \cdot 0.5\right)\right)} \cdot -1\right) \cdot \left(im + 3\right) \]
      12. *-commutative29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\color{blue}{\left(\left(re \cdot 0.5\right) \cdot re\right)} \cdot -1\right) \cdot \left(im + 3\right) \]
      13. associate-*r*29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left(re \cdot 0.5\right) \cdot \left(re \cdot -1\right)\right)} \cdot \left(im + 3\right) \]
      14. *-commutative29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left(re \cdot -1\right) \cdot \left(re \cdot 0.5\right)\right)} \cdot \left(im + 3\right) \]
      15. *-commutative29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\color{blue}{\left(-1 \cdot re\right)} \cdot \left(re \cdot 0.5\right)\right) \cdot \left(im + 3\right) \]
      16. associate-*l*29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(-1 \cdot \left(re \cdot \left(re \cdot 0.5\right)\right)\right)} \cdot \left(im + 3\right) \]
      17. neg-mul-129.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(-re \cdot \left(re \cdot 0.5\right)\right)} \cdot \left(im + 3\right) \]
      18. distribute-lft-neg-in29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(-\left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(im + 3\right)\right)} \]
      19. distribute-rgt-neg-in29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(-\left(im + 3\right)\right)} \]
      20. neg-mul-129.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \color{blue}{\left(-1 \cdot \left(im + 3\right)\right)} \]
      21. distribute-rgt-in29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \color{blue}{\left(im \cdot -1 + 3 \cdot -1\right)} \]
      22. metadata-eval29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(im \cdot -1 + \color{blue}{-3}\right) \]
      23. fma-udef29.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \color{blue}{\mathsf{fma}\left(im, -1, -3\right)} \]
    14. Simplified29.0%

      \[\leadsto \color{blue}{\left(-3 - im\right) \cdot \mathsf{fma}\left(re, re \cdot 0.5, 1\right)} \]

    if -1.7e-5 < im < 9e9

    1. Initial program 10.6%

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

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

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

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

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

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

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

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

    if 9e9 < im < 1.31999999999999998e154

    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 29.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-neg29.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
      3. unpow220.5%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right) \]
      4. fma-neg20.5%

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

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
    13. Step-by-step derivation
      1. sub-neg20.5%

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(0.5 \cdot 0.5\right)} \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right)} \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right) + \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(-im\right) \]
      8. swap-sqr18.3%

        \[\leadsto \sqrt{\color{blue}{\left(0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)}} \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right) + \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(-im\right) \]
      9. associate-*l*18.3%

        \[\leadsto \sqrt{\color{blue}{\left(\left(0.5 \cdot re\right) \cdot re\right)} \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)} \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right) + \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(-im\right) \]
      10. associate-*l*18.3%

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

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

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

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

        \[\leadsto \left(re \cdot \color{blue}{\left(re \cdot 0.5\right)}\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right) + \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(-im\right) \]
    14. Applied egg-rr38.6%

      \[\leadsto \color{blue}{\left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(-im\right)} \]
    15. Step-by-step derivation
      1. distribute-lft-out38.6%

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

        \[\leadsto \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
      3. associate-*l*46.2%

        \[\leadsto \color{blue}{re \cdot \left(\left(re \cdot 0.5\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)\right)} \]
      4. fma-neg46.2%

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

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

    if 1.31999999999999998e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(\color{blue}{9} - im \cdot im\right) \cdot \cos re}{-3 + im} \]
      5. +-commutative100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.75 \cdot 10^{+84}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq -1.55 \cdot 10^{+23}:\\ \;\;\;\;\left(-3 - im\right) \cdot \mathsf{fma}\left(re, 0.5 \cdot re, 1\right)\\ \mathbf{elif}\;im \leq -1.7 \cdot 10^{-5}:\\ \;\;\;\;\left(-0.5 \cdot \left(re \cdot re\right) + 1\right) \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 9000000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \end{array} \]

Alternative 6: 84.4% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := re \cdot \left(\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(0.5 \cdot re\right)\right)\\
t_1 := \frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\
\mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -1.48 \cdot 10^{+23}:\\
\;\;\;\;t_0\\

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(\color{blue}{9} - im \cdot im\right) \cdot \cos re}{-3 + im} \]
      5. +-commutative100.0%

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

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

    if -1.35000000000000003e154 < im < -1.4799999999999999e23 or 9.5e9 < im < 1.31999999999999998e154

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
      3. unpow219.7%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right) \]
      4. fma-neg19.7%

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right) + \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(-im\right)} \]
      3. add-sqr-sqrt0.3%

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

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

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

        \[\leadsto \sqrt{\color{blue}{0.25} \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right)} \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right) + \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(-im\right) \]
      7. metadata-eval13.2%

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

        \[\leadsto \sqrt{\color{blue}{\left(0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)}} \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right) + \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(-im\right) \]
      9. associate-*l*13.2%

        \[\leadsto \sqrt{\color{blue}{\left(\left(0.5 \cdot re\right) \cdot re\right)} \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)} \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right) + \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(-im\right) \]
      10. associate-*l*13.2%

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

        \[\leadsto \color{blue}{\left(\sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \sqrt{\left(0.5 \cdot re\right) \cdot re}\right)} \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right) + \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(-im\right) \]
      12. add-sqr-sqrt13.5%

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

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

        \[\leadsto \left(re \cdot \color{blue}{\left(re \cdot 0.5\right)}\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right) + \left(-0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(-im\right) \]
    14. Applied egg-rr34.0%

      \[\leadsto \color{blue}{\left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(-0.16666666666666666 \cdot {im}^{3}\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(-im\right)} \]
    15. Step-by-step derivation
      1. distribute-lft-out34.0%

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

        \[\leadsto \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
      3. associate-*l*42.3%

        \[\leadsto \color{blue}{re \cdot \left(\left(re \cdot 0.5\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)\right)} \]
      4. fma-neg42.3%

        \[\leadsto re \cdot \left(\left(re \cdot 0.5\right) \cdot \color{blue}{\left(-0.16666666666666666 \cdot {im}^{3} - im\right)}\right) \]
    16. Simplified42.3%

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

    if -1.4799999999999999e23 < im < 9.5e9

    1. Initial program 14.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \mathbf{elif}\;im \leq -1.48 \cdot 10^{+23}:\\ \;\;\;\;re \cdot \left(\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 9500000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(\left({im}^{3} \cdot -0.16666666666666666 - im\right) \cdot \left(0.5 \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos re \cdot \left(9 - im \cdot im\right)}{im + -3}\\ \end{array} \]

Alternative 7: 77.4% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\ t_1 := \left(re \cdot re\right) \cdot \left({im}^{3} \cdot 0.08333333333333333\right)\\ \mathbf{if}\;im \leq -7.2 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -600:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -1.4 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 2.6 \cdot 10^{+28}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 5.3 \cdot 10^{+88}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im))
        (t_1 (* (* re re) (* (pow im 3.0) 0.08333333333333333))))
   (if (<= im -7.2e+102)
     t_0
     (if (<= im -600.0)
       t_1
       (if (<= im -1.4e-5)
         t_0
         (if (<= im 2.6e+28)
           (* (cos re) (- im))
           (if (<= im 5.3e+88) t_1 t_0)))))))
double code(double re, double im) {
	double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double t_1 = (re * re) * (pow(im, 3.0) * 0.08333333333333333);
	double tmp;
	if (im <= -7.2e+102) {
		tmp = t_0;
	} else if (im <= -600.0) {
		tmp = t_1;
	} else if (im <= -1.4e-5) {
		tmp = t_0;
	} else if (im <= 2.6e+28) {
		tmp = cos(re) * -im;
	} else if (im <= 5.3e+88) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ((im ** 3.0d0) * (-0.16666666666666666d0)) - im
    t_1 = (re * re) * ((im ** 3.0d0) * 0.08333333333333333d0)
    if (im <= (-7.2d+102)) then
        tmp = t_0
    else if (im <= (-600.0d0)) then
        tmp = t_1
    else if (im <= (-1.4d-5)) then
        tmp = t_0
    else if (im <= 2.6d+28) then
        tmp = cos(re) * -im
    else if (im <= 5.3d+88) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (Math.pow(im, 3.0) * -0.16666666666666666) - im;
	double t_1 = (re * re) * (Math.pow(im, 3.0) * 0.08333333333333333);
	double tmp;
	if (im <= -7.2e+102) {
		tmp = t_0;
	} else if (im <= -600.0) {
		tmp = t_1;
	} else if (im <= -1.4e-5) {
		tmp = t_0;
	} else if (im <= 2.6e+28) {
		tmp = Math.cos(re) * -im;
	} else if (im <= 5.3e+88) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (math.pow(im, 3.0) * -0.16666666666666666) - im
	t_1 = (re * re) * (math.pow(im, 3.0) * 0.08333333333333333)
	tmp = 0
	if im <= -7.2e+102:
		tmp = t_0
	elif im <= -600.0:
		tmp = t_1
	elif im <= -1.4e-5:
		tmp = t_0
	elif im <= 2.6e+28:
		tmp = math.cos(re) * -im
	elif im <= 5.3e+88:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	t_1 = Float64(Float64(re * re) * Float64((im ^ 3.0) * 0.08333333333333333))
	tmp = 0.0
	if (im <= -7.2e+102)
		tmp = t_0;
	elseif (im <= -600.0)
		tmp = t_1;
	elseif (im <= -1.4e-5)
		tmp = t_0;
	elseif (im <= 2.6e+28)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 5.3e+88)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = ((im ^ 3.0) * -0.16666666666666666) - im;
	t_1 = (re * re) * ((im ^ 3.0) * 0.08333333333333333);
	tmp = 0.0;
	if (im <= -7.2e+102)
		tmp = t_0;
	elseif (im <= -600.0)
		tmp = t_1;
	elseif (im <= -1.4e-5)
		tmp = t_0;
	elseif (im <= 2.6e+28)
		tmp = cos(re) * -im;
	elseif (im <= 5.3e+88)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$1 = N[(N[(re * re), $MachinePrecision] * N[(N[Power[im, 3.0], $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -7.2e+102], t$95$0, If[LessEqual[im, -600.0], t$95$1, If[LessEqual[im, -1.4e-5], t$95$0, If[LessEqual[im, 2.6e+28], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 5.3e+88], t$95$1, t$95$0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
t_1 := \left(re \cdot re\right) \cdot \left({im}^{3} \cdot 0.08333333333333333\right)\\
\mathbf{if}\;im \leq -7.2 \cdot 10^{+102}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -600:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;im \leq 5.3 \cdot 10^{+88}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -7.2000000000000003e102 or -600 < im < -1.39999999999999998e-5 or 5.29999999999999987e88 < im

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

    if -7.2000000000000003e102 < im < -600 or 2.6000000000000002e28 < im < 5.29999999999999987e88

    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 7.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-neg7.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
      3. unpow223.1%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right) \]
      4. fma-neg23.1%

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

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

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

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

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

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

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

    if -1.39999999999999998e-5 < im < 2.6000000000000002e28

    1. Initial program 13.5%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.2 \cdot 10^{+102}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq -600:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left({im}^{3} \cdot 0.08333333333333333\right)\\ \mathbf{elif}\;im \leq -1.4 \cdot 10^{-5}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 2.6 \cdot 10^{+28}:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 5.3 \cdot 10^{+88}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left({im}^{3} \cdot 0.08333333333333333\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 8: 77.0% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\ t_1 := \left(-3 - im\right) \cdot \mathsf{fma}\left(re, 0.5 \cdot re, 1\right)\\ \mathbf{if}\;im \leq -4.8 \cdot 10^{+85}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -1.65 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 510000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (- (* (pow im 3.0) -0.16666666666666666) im))
        (t_1 (* (- -3.0 im) (fma re (* 0.5 re) 1.0))))
   (if (<= im -4.8e+85)
     t_0
     (if (<= im -1.65e+23)
       t_1
       (if (<= im 510000000.0)
         (* (cos re) (- im))
         (if (<= im 4.2e+100) t_1 t_0))))))
double code(double re, double im) {
	double t_0 = (pow(im, 3.0) * -0.16666666666666666) - im;
	double t_1 = (-3.0 - im) * fma(re, (0.5 * re), 1.0);
	double tmp;
	if (im <= -4.8e+85) {
		tmp = t_0;
	} else if (im <= -1.65e+23) {
		tmp = t_1;
	} else if (im <= 510000000.0) {
		tmp = cos(re) * -im;
	} else if (im <= 4.2e+100) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(Float64((im ^ 3.0) * -0.16666666666666666) - im)
	t_1 = Float64(Float64(-3.0 - im) * fma(re, Float64(0.5 * re), 1.0))
	tmp = 0.0
	if (im <= -4.8e+85)
		tmp = t_0;
	elseif (im <= -1.65e+23)
		tmp = t_1;
	elseif (im <= 510000000.0)
		tmp = Float64(cos(re) * Float64(-im));
	elseif (im <= 4.2e+100)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-3.0 - im), $MachinePrecision] * N[(re * N[(0.5 * re), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -4.8e+85], t$95$0, If[LessEqual[im, -1.65e+23], t$95$1, If[LessEqual[im, 510000000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 4.2e+100], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {im}^{3} \cdot -0.16666666666666666 - im\\
t_1 := \left(-3 - im\right) \cdot \mathsf{fma}\left(re, 0.5 \cdot re, 1\right)\\
\mathbf{if}\;im \leq -4.8 \cdot 10^{+85}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq -1.65 \cdot 10^{+23}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;im \leq 4.2 \cdot 10^{+100}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -4.79999999999999993e85 or 4.1999999999999997e100 < 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 95.8%

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

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

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

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

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

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

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

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

    if -4.79999999999999993e85 < im < -1.65000000000000015e23 or 5.1e8 < im < 4.1999999999999997e100

    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 5.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-neg5.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(im + 3\right) \cdot \left(\left(-1\right) + \color{blue}{\left(--0.5\right)} \cdot {re}^{2}\right) \]
      6. distribute-lft-neg-in8.5%

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

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

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

        \[\leadsto \left(im + 3\right) \cdot \left(\left(-1\right) + \left(-\color{blue}{re \cdot \left(-0.5 \cdot re\right)}\right)\right) \]
      10. distribute-neg-in8.5%

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

        \[\leadsto \left(im + 3\right) \cdot \left(-\color{blue}{\left(re \cdot \left(-0.5 \cdot re\right) + 1\right)}\right) \]
      12. distribute-neg-in8.5%

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

        \[\leadsto \left(im + 3\right) \cdot \left(\left(-\color{blue}{\left(-0.5 \cdot re\right) \cdot re}\right) + \left(-1\right)\right) \]
      14. distribute-lft-neg-in8.5%

        \[\leadsto \left(im + 3\right) \cdot \left(\color{blue}{\left(--0.5 \cdot re\right) \cdot re} + \left(-1\right)\right) \]
      15. distribute-lft-neg-in8.5%

        \[\leadsto \left(im + 3\right) \cdot \left(\color{blue}{\left(\left(--0.5\right) \cdot re\right)} \cdot re + \left(-1\right)\right) \]
      16. metadata-eval8.5%

        \[\leadsto \left(im + 3\right) \cdot \left(\left(\color{blue}{0.5} \cdot re\right) \cdot re + \left(-1\right)\right) \]
      17. metadata-eval8.5%

        \[\leadsto \left(im + 3\right) \cdot \left(\left(0.5 \cdot re\right) \cdot re + \color{blue}{-1}\right) \]
    10. Simplified8.5%

      \[\leadsto \color{blue}{\left(im + 3\right) \cdot \left(\left(0.5 \cdot re\right) \cdot re + -1\right)} \]
    11. Step-by-step derivation
      1. distribute-rgt-in8.5%

        \[\leadsto \color{blue}{\left(\left(0.5 \cdot re\right) \cdot re\right) \cdot \left(im + 3\right) + -1 \cdot \left(im + 3\right)} \]
      2. add-sqr-sqrt8.5%

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

        \[\leadsto \color{blue}{\sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(\sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(im + 3\right)\right)} + -1 \cdot \left(im + 3\right) \]
      4. *-commutative8.5%

        \[\leadsto \sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(\sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(im + 3\right)\right) + \color{blue}{\left(im + 3\right) \cdot -1} \]
      5. fma-def8.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\left(0.5 \cdot re\right) \cdot re}, \sqrt{\left(0.5 \cdot re\right) \cdot re} \cdot \left(im + 3\right), \left(im + 3\right) \cdot -1\right)} \]
    12. Applied egg-rr0.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re \cdot \sqrt{-0.5}, \left(re \cdot \sqrt{-0.5}\right) \cdot \left(im + 3\right), \mathsf{fma}\left(im, -1, -3\right)\right)} \]
    13. Step-by-step derivation
      1. fma-udef0.0%

        \[\leadsto \color{blue}{\left(re \cdot \sqrt{-0.5}\right) \cdot \left(\left(re \cdot \sqrt{-0.5}\right) \cdot \left(im + 3\right)\right) + \mathsf{fma}\left(im, -1, -3\right)} \]
      2. +-commutative0.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \sqrt{-0.5}\right) \cdot \left(\left(re \cdot \sqrt{-0.5}\right) \cdot \left(im + 3\right)\right)} \]
      3. *-lft-identity0.0%

        \[\leadsto \color{blue}{1 \cdot \mathsf{fma}\left(im, -1, -3\right)} + \left(re \cdot \sqrt{-0.5}\right) \cdot \left(\left(re \cdot \sqrt{-0.5}\right) \cdot \left(im + 3\right)\right) \]
      4. associate-*r*0.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left(re \cdot \sqrt{-0.5}\right) \cdot \left(re \cdot \sqrt{-0.5}\right)\right) \cdot \left(im + 3\right)} \]
      5. swap-sqr0.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left(re \cdot re\right) \cdot \left(\sqrt{-0.5} \cdot \sqrt{-0.5}\right)\right)} \cdot \left(im + 3\right) \]
      6. unpow20.0%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\color{blue}{{re}^{2}} \cdot \left(\sqrt{-0.5} \cdot \sqrt{-0.5}\right)\right) \cdot \left(im + 3\right) \]
      7. rem-square-sqrt28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left({re}^{2} \cdot \color{blue}{-0.5}\right) \cdot \left(im + 3\right) \]
      8. metadata-eval28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left({re}^{2} \cdot \color{blue}{\left(0.5 \cdot -1\right)}\right) \cdot \left(im + 3\right) \]
      9. associate-*l*28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left({re}^{2} \cdot 0.5\right) \cdot -1\right)} \cdot \left(im + 3\right) \]
      10. unpow228.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) \cdot -1\right) \cdot \left(im + 3\right) \]
      11. associate-*r*28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\color{blue}{\left(re \cdot \left(re \cdot 0.5\right)\right)} \cdot -1\right) \cdot \left(im + 3\right) \]
      12. *-commutative28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\color{blue}{\left(\left(re \cdot 0.5\right) \cdot re\right)} \cdot -1\right) \cdot \left(im + 3\right) \]
      13. associate-*r*28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left(re \cdot 0.5\right) \cdot \left(re \cdot -1\right)\right)} \cdot \left(im + 3\right) \]
      14. *-commutative28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(\left(re \cdot -1\right) \cdot \left(re \cdot 0.5\right)\right)} \cdot \left(im + 3\right) \]
      15. *-commutative28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(\color{blue}{\left(-1 \cdot re\right)} \cdot \left(re \cdot 0.5\right)\right) \cdot \left(im + 3\right) \]
      16. associate-*l*28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(-1 \cdot \left(re \cdot \left(re \cdot 0.5\right)\right)\right)} \cdot \left(im + 3\right) \]
      17. neg-mul-128.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(-re \cdot \left(re \cdot 0.5\right)\right)} \cdot \left(im + 3\right) \]
      18. distribute-lft-neg-in28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(-\left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(im + 3\right)\right)} \]
      19. distribute-rgt-neg-in28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \color{blue}{\left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(-\left(im + 3\right)\right)} \]
      20. neg-mul-128.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \color{blue}{\left(-1 \cdot \left(im + 3\right)\right)} \]
      21. distribute-rgt-in28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \color{blue}{\left(im \cdot -1 + 3 \cdot -1\right)} \]
      22. metadata-eval28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(im \cdot -1 + \color{blue}{-3}\right) \]
      23. fma-udef28.8%

        \[\leadsto 1 \cdot \mathsf{fma}\left(im, -1, -3\right) + \left(re \cdot \left(re \cdot 0.5\right)\right) \cdot \color{blue}{\mathsf{fma}\left(im, -1, -3\right)} \]
    14. Simplified28.8%

      \[\leadsto \color{blue}{\left(-3 - im\right) \cdot \mathsf{fma}\left(re, re \cdot 0.5, 1\right)} \]

    if -1.65000000000000015e23 < im < 5.1e8

    1. Initial program 13.4%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -4.8 \cdot 10^{+85}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq -1.65 \cdot 10^{+23}:\\ \;\;\;\;\left(-3 - im\right) \cdot \mathsf{fma}\left(re, 0.5 \cdot re, 1\right)\\ \mathbf{elif}\;im \leq 510000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+100}:\\ \;\;\;\;\left(-3 - im\right) \cdot \mathsf{fma}\left(re, 0.5 \cdot re, 1\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 9: 76.1% accurate, 2.8× speedup?

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

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

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

\mathbf{elif}\;im \leq 1.65 \cdot 10^{+100}:\\
\;\;\;\;27 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

    if -1.7e-5 < im < 3e10

    1. Initial program 10.6%

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

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

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

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

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

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

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

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

    if 3e10 < im < 1.6500000000000001e100

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.7 \cdot 10^{-5}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \mathbf{elif}\;im \leq 30000000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 1.65 \cdot 10^{+100}:\\ \;\;\;\;27 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{3} \cdot -0.16666666666666666 - im\\ \end{array} \]

Alternative 10: 59.3% accurate, 2.9× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -430 or 4.49999999999999991e231 < 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 5.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -430 < im < 1.06e13

    1. Initial program 11.2%

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

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

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

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

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

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

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

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

    if 1.06e13 < im < 4.49999999999999991e231

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -430:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \mathbf{elif}\;im \leq 10600000000000:\\ \;\;\;\;\cos re \cdot \left(-im\right)\\ \mathbf{elif}\;im \leq 4.5 \cdot 10^{+231}:\\ \;\;\;\;27 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right) - im\\ \end{array} \]

Alternative 11: 36.7% accurate, 20.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\ \mathbf{if}\;im \leq -410:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 12500000000:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 2.6 \cdot 10^{+255}:\\ \;\;\;\;27 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* re re) (* im 0.5))))
   (if (<= im -410.0)
     t_0
     (if (<= im 12500000000.0)
       (- im)
       (if (<= im 2.6e+255) (* 27.0 (+ 0.5 (* re (* re -0.25)))) t_0)))))
double code(double re, double im) {
	double t_0 = (re * re) * (im * 0.5);
	double tmp;
	if (im <= -410.0) {
		tmp = t_0;
	} else if (im <= 12500000000.0) {
		tmp = -im;
	} else if (im <= 2.6e+255) {
		tmp = 27.0 * (0.5 + (re * (re * -0.25)));
	} 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 = (re * re) * (im * 0.5d0)
    if (im <= (-410.0d0)) then
        tmp = t_0
    else if (im <= 12500000000.0d0) then
        tmp = -im
    else if (im <= 2.6d+255) then
        tmp = 27.0d0 * (0.5d0 + (re * (re * (-0.25d0))))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (re * re) * (im * 0.5);
	double tmp;
	if (im <= -410.0) {
		tmp = t_0;
	} else if (im <= 12500000000.0) {
		tmp = -im;
	} else if (im <= 2.6e+255) {
		tmp = 27.0 * (0.5 + (re * (re * -0.25)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(re, im):
	t_0 = (re * re) * (im * 0.5)
	tmp = 0
	if im <= -410.0:
		tmp = t_0
	elif im <= 12500000000.0:
		tmp = -im
	elif im <= 2.6e+255:
		tmp = 27.0 * (0.5 + (re * (re * -0.25)))
	else:
		tmp = t_0
	return tmp
function code(re, im)
	t_0 = Float64(Float64(re * re) * Float64(im * 0.5))
	tmp = 0.0
	if (im <= -410.0)
		tmp = t_0;
	elseif (im <= 12500000000.0)
		tmp = Float64(-im);
	elseif (im <= 2.6e+255)
		tmp = Float64(27.0 * Float64(0.5 + Float64(re * Float64(re * -0.25))));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (re * re) * (im * 0.5);
	tmp = 0.0;
	if (im <= -410.0)
		tmp = t_0;
	elseif (im <= 12500000000.0)
		tmp = -im;
	elseif (im <= 2.6e+255)
		tmp = 27.0 * (0.5 + (re * (re * -0.25)));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(re * re), $MachinePrecision] * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -410.0], t$95$0, If[LessEqual[im, 12500000000.0], (-im), If[LessEqual[im, 2.6e+255], N[(27.0 * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 12500000000:\\
\;\;\;\;-im\\

\mathbf{elif}\;im \leq 2.6 \cdot 10^{+255}:\\
\;\;\;\;27 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -410 or 2.6000000000000001e255 < 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 69.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-neg69.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
      3. unpow228.3%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right) \]
      4. fma-neg28.3%

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

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

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

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

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

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

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

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

    if -410 < im < 1.25e10

    1. Initial program 11.2%

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

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

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

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

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

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

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

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

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

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

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

    if 1.25e10 < im < 2.6000000000000001e255

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -410:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\ \mathbf{elif}\;im \leq 12500000000:\\ \;\;\;\;-im\\ \mathbf{elif}\;im \leq 2.6 \cdot 10^{+255}:\\ \;\;\;\;27 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(im \cdot 0.5\right)\\ \end{array} \]

Alternative 12: 37.4% accurate, 27.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -900 or 1.3500000000000001e28 < 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 63.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-neg63.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot {re}^{2}\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right)} \]
      3. unpow224.1%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \mathsf{fma}\left(-0.16666666666666666, {im}^{3}, -im\right) \]
      4. fma-neg24.1%

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

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

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

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

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

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

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

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

    if -900 < im < 1.3500000000000001e28

    1. Initial program 14.1%

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 36.5% accurate, 27.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -2.5 \cdot 10^{+167}:\\
\;\;\;\;27 \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\

\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 re < -2.4999999999999998e167

    1. Initial program 50.1%

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

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

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

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

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

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

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

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

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

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

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

    if -2.4999999999999998e167 < re

    1. Initial program 60.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) - im \]
    9. Simplified33.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 simplification33.0%

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

Alternative 14: 32.1% accurate, 43.8× speedup?

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

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

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


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

    1. Initial program 58.0%

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

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

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

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

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

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

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

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

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

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

    if 8e153 < re

    1. Initial program 68.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot 0.75} \]
      2. unpow233.9%

        \[\leadsto \color{blue}{\left(re \cdot re\right)} \cdot 0.75 \]
      3. associate-*l*33.9%

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

      \[\leadsto \color{blue}{re \cdot \left(re \cdot 0.75\right)} \]
    11. Taylor expanded in re around 0 33.9%

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

        \[\leadsto 0.75 \cdot \color{blue}{\left(re \cdot re\right)} \]
    13. Simplified33.9%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-im} \]
  10. Final simplification24.3%

    \[\leadsto -im \]

Alternative 16: 2.9% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -1.5 \]

Developer target: 99.8% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

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