math.sin on complex, imaginary part

Percentage Accurate: 53.6% → 99.6%
Time: 17.5s
Alternatives: 18
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 18 alternatives:

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

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

    if -5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1.99999999999999996e-12

    1. Initial program 9.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.6% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

    if -5 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1.99999999999999996e-12

    1. Initial program 9.3%

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

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

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

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

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

Alternative 3: 99.6% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

    if -2e-3 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1.99999999999999996e-12

    1. Initial program 8.7%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 94.8% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -7.5 \cdot 10^{+94} \lor \neg \left(im \leq -130 \lor \neg \left(im \leq 2\right) \land im \leq 5.6 \cdot 10^{+102}\right):\\
\;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -7.49999999999999978e94 or -130 < im < 2 or 5.60000000000000037e102 < im

    1. Initial program 46.3%

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

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

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

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

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

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

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

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

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

    if -7.49999999999999978e94 < im < -130 or 2 < im < 5.60000000000000037e102

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.5 \cdot 10^{+94} \lor \neg \left(im \leq -130 \lor \neg \left(im \leq 2\right) \land im \leq 5.6 \cdot 10^{+102}\right):\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \end{array} \]

Alternative 5: 93.4% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right)\\ t_1 := \cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{if}\;im \leq -5.5 \cdot 10^{+102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -0.072:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 6.5 \lor \neg \left(im \leq 5.6 \cdot 10^{+102}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \frac{t_0 \cdot t_0 - \left(im \cdot -2\right) \cdot \left(im \cdot -2\right)}{t_0 - im \cdot -2}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* im (* -0.3333333333333333 (* im im))))
        (t_1 (* (cos re) (- (* -0.16666666666666666 (pow im 3.0)) im))))
   (if (<= im -5.5e+102)
     t_1
     (if (<= im -0.072)
       (* 0.5 (- (exp (- im)) (exp im)))
       (if (or (<= im 6.5) (not (<= im 5.6e+102)))
         t_1
         (*
          (fma (* re re) -0.25 0.5)
          (/
           (- (* t_0 t_0) (* (* im -2.0) (* im -2.0)))
           (- t_0 (* im -2.0)))))))))
double code(double re, double im) {
	double t_0 = im * (-0.3333333333333333 * (im * im));
	double t_1 = cos(re) * ((-0.16666666666666666 * pow(im, 3.0)) - im);
	double tmp;
	if (im <= -5.5e+102) {
		tmp = t_1;
	} else if (im <= -0.072) {
		tmp = 0.5 * (exp(-im) - exp(im));
	} else if ((im <= 6.5) || !(im <= 5.6e+102)) {
		tmp = t_1;
	} else {
		tmp = fma((re * re), -0.25, 0.5) * (((t_0 * t_0) - ((im * -2.0) * (im * -2.0))) / (t_0 - (im * -2.0)));
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(im * Float64(-0.3333333333333333 * Float64(im * im)))
	t_1 = Float64(cos(re) * Float64(Float64(-0.16666666666666666 * (im ^ 3.0)) - im))
	tmp = 0.0
	if (im <= -5.5e+102)
		tmp = t_1;
	elseif (im <= -0.072)
		tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)));
	elseif ((im <= 6.5) || !(im <= 5.6e+102))
		tmp = t_1;
	else
		tmp = Float64(fma(Float64(re * re), -0.25, 0.5) * Float64(Float64(Float64(t_0 * t_0) - Float64(Float64(im * -2.0) * Float64(im * -2.0))) / Float64(t_0 - Float64(im * -2.0))));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(-0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -5.5e+102], t$95$1, If[LessEqual[im, -0.072], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, 6.5], N[Not[LessEqual[im, 5.6e+102]], $MachinePrecision]], t$95$1, N[(N[(N[(re * re), $MachinePrecision] * -0.25 + 0.5), $MachinePrecision] * N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(N[(im * -2.0), $MachinePrecision] * N[(im * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(im * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 6.5 \lor \neg \left(im \leq 5.6 \cdot 10^{+102}\right):\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \frac{t_0 \cdot t_0 - \left(im \cdot -2\right) \cdot \left(im \cdot -2\right)}{t_0 - im \cdot -2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < -5.49999999999999981e102 or -0.0719999999999999946 < im < 6.5 or 5.60000000000000037e102 < im

    1. Initial program 45.6%

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

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

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

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

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

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

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

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

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

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

    if -5.49999999999999981e102 < im < -0.0719999999999999946

    1. Initial program 100.0%

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

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

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

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

    if 6.5 < im < 5.60000000000000037e102

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({re}^{2}, -0.25, 0.5\right)} \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -2 \cdot im\right) \]
      7. unpow232.9%

        \[\leadsto \mathsf{fma}\left(\color{blue}{re \cdot re}, -0.25, 0.5\right) \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -2 \cdot im\right) \]
      8. unpow332.9%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(-0.3333333333333333 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot im\right)} + -2 \cdot im\right) \]
      9. associate-*r*32.9%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(\color{blue}{\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im} + -2 \cdot im\right) \]
      10. distribute-rgt-out32.9%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \color{blue}{\left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
    9. Simplified32.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
    10. Step-by-step derivation
      1. distribute-rgt-in32.9%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \color{blue}{\left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im + -2 \cdot im\right)} \]
      2. flip-+72.9%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \color{blue}{\frac{\left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im\right) - \left(-2 \cdot im\right) \cdot \left(-2 \cdot im\right)}{\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im - -2 \cdot im}} \]
    11. Applied egg-rr72.9%

      \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \color{blue}{\frac{\left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im\right) - \left(-2 \cdot im\right) \cdot \left(-2 \cdot im\right)}{\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im - -2 \cdot im}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification95.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -5.5 \cdot 10^{+102}:\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{elif}\;im \leq -0.072:\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{elif}\;im \leq 6.5 \lor \neg \left(im \leq 5.6 \cdot 10^{+102}\right):\\ \;\;\;\;\cos re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \frac{\left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right) \cdot \left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right) - \left(im \cdot -2\right) \cdot \left(im \cdot -2\right)}{im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) - im \cdot -2}\\ \end{array} \]

Alternative 6: 85.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -3 \cdot 10^{+234}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\ \mathbf{elif}\;im \leq -2.1 \cdot 10^{+70}:\\ \;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(im \cdot \left(-2 + -0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right)\\ \mathbf{elif}\;im \leq -0.00105 \lor \neg \left(im \leq 2\right):\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -3e+234)
   (* -0.16666666666666666 (pow im 3.0))
   (if (<= im -2.1e+70)
     (*
      (fma (* re re) -0.25 0.5)
      (* im (+ -2.0 (* -0.3333333333333333 (* im im)))))
     (if (or (<= im -0.00105) (not (<= im 2.0)))
       (* 0.5 (- (exp (- im)) (exp im)))
       (* im (- (cos re)))))))
double code(double re, double im) {
	double tmp;
	if (im <= -3e+234) {
		tmp = -0.16666666666666666 * pow(im, 3.0);
	} else if (im <= -2.1e+70) {
		tmp = fma((re * re), -0.25, 0.5) * (im * (-2.0 + (-0.3333333333333333 * (im * im))));
	} else if ((im <= -0.00105) || !(im <= 2.0)) {
		tmp = 0.5 * (exp(-im) - exp(im));
	} else {
		tmp = im * -cos(re);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= -3e+234)
		tmp = Float64(-0.16666666666666666 * (im ^ 3.0));
	elseif (im <= -2.1e+70)
		tmp = Float64(fma(Float64(re * re), -0.25, 0.5) * Float64(im * Float64(-2.0 + Float64(-0.3333333333333333 * Float64(im * im)))));
	elseif ((im <= -0.00105) || !(im <= 2.0))
		tmp = Float64(0.5 * Float64(exp(Float64(-im)) - exp(im)));
	else
		tmp = Float64(im * Float64(-cos(re)));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, -3e+234], N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, -2.1e+70], N[(N[(N[(re * re), $MachinePrecision] * -0.25 + 0.5), $MachinePrecision] * N[(im * N[(-2.0 + N[(-0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, -0.00105], N[Not[LessEqual[im, 2.0]], $MachinePrecision]], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -3 \cdot 10^{+234}:\\
\;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\

\mathbf{elif}\;im \leq -2.1 \cdot 10^{+70}:\\
\;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(im \cdot \left(-2 + -0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right)\\

\mathbf{elif}\;im \leq -0.00105 \lor \neg \left(im \leq 2\right):\\
\;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} \]
    10. Simplified90.0%

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

    if -2.9999999999999999e234 < im < -2.10000000000000008e70

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({re}^{2}, -0.25, 0.5\right)} \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -2 \cdot im\right) \]
      7. unpow276.6%

        \[\leadsto \mathsf{fma}\left(\color{blue}{re \cdot re}, -0.25, 0.5\right) \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -2 \cdot im\right) \]
      8. unpow376.6%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(-0.3333333333333333 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot im\right)} + -2 \cdot im\right) \]
      9. associate-*r*76.6%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(\color{blue}{\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im} + -2 \cdot im\right) \]
      10. distribute-rgt-out76.6%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \color{blue}{\left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
    9. Simplified76.6%

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

    if -2.10000000000000008e70 < im < -0.00104999999999999994 or 2 < im

    1. Initial program 100.0%

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

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

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

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

    if -0.00104999999999999994 < im < 2

    1. Initial program 10.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -3 \cdot 10^{+234}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\ \mathbf{elif}\;im \leq -2.1 \cdot 10^{+70}:\\ \;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(im \cdot \left(-2 + -0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right)\\ \mathbf{elif}\;im \leq -0.00105 \lor \neg \left(im \leq 2\right):\\ \;\;\;\;0.5 \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 7: 80.1% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right)\\ t_1 := -0.16666666666666666 \cdot {im}^{3}\\ t_2 := -0.3333333333333333 \cdot \left(im \cdot im\right)\\ t_3 := im \cdot t_2\\ \mathbf{if}\;im \leq -7.8 \cdot 10^{+233}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq -49000000:\\ \;\;\;\;t_0 \cdot \left(im \cdot \left(-2 + t_2\right)\right)\\ \mathbf{elif}\;im \leq 6.5:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+102}:\\ \;\;\;\;t_0 \cdot \frac{t_3 \cdot t_3 - \left(im \cdot -2\right) \cdot \left(im \cdot -2\right)}{t_3 - im \cdot -2}\\ \mathbf{else}:\\ \;\;\;\;t_1 - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (fma (* re re) -0.25 0.5))
        (t_1 (* -0.16666666666666666 (pow im 3.0)))
        (t_2 (* -0.3333333333333333 (* im im)))
        (t_3 (* im t_2)))
   (if (<= im -7.8e+233)
     t_1
     (if (<= im -49000000.0)
       (* t_0 (* im (+ -2.0 t_2)))
       (if (<= im 6.5)
         (* im (- (cos re)))
         (if (<= im 8.2e+102)
           (*
            t_0
            (/
             (- (* t_3 t_3) (* (* im -2.0) (* im -2.0)))
             (- t_3 (* im -2.0))))
           (- t_1 im)))))))
double code(double re, double im) {
	double t_0 = fma((re * re), -0.25, 0.5);
	double t_1 = -0.16666666666666666 * pow(im, 3.0);
	double t_2 = -0.3333333333333333 * (im * im);
	double t_3 = im * t_2;
	double tmp;
	if (im <= -7.8e+233) {
		tmp = t_1;
	} else if (im <= -49000000.0) {
		tmp = t_0 * (im * (-2.0 + t_2));
	} else if (im <= 6.5) {
		tmp = im * -cos(re);
	} else if (im <= 8.2e+102) {
		tmp = t_0 * (((t_3 * t_3) - ((im * -2.0) * (im * -2.0))) / (t_3 - (im * -2.0)));
	} else {
		tmp = t_1 - im;
	}
	return tmp;
}
function code(re, im)
	t_0 = fma(Float64(re * re), -0.25, 0.5)
	t_1 = Float64(-0.16666666666666666 * (im ^ 3.0))
	t_2 = Float64(-0.3333333333333333 * Float64(im * im))
	t_3 = Float64(im * t_2)
	tmp = 0.0
	if (im <= -7.8e+233)
		tmp = t_1;
	elseif (im <= -49000000.0)
		tmp = Float64(t_0 * Float64(im * Float64(-2.0 + t_2)));
	elseif (im <= 6.5)
		tmp = Float64(im * Float64(-cos(re)));
	elseif (im <= 8.2e+102)
		tmp = Float64(t_0 * Float64(Float64(Float64(t_3 * t_3) - Float64(Float64(im * -2.0) * Float64(im * -2.0))) / Float64(t_3 - Float64(im * -2.0))));
	else
		tmp = Float64(t_1 - im);
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(re * re), $MachinePrecision] * -0.25 + 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(im * t$95$2), $MachinePrecision]}, If[LessEqual[im, -7.8e+233], t$95$1, If[LessEqual[im, -49000000.0], N[(t$95$0 * N[(im * N[(-2.0 + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.5], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im, 8.2e+102], N[(t$95$0 * N[(N[(N[(t$95$3 * t$95$3), $MachinePrecision] - N[(N[(im * -2.0), $MachinePrecision] * N[(im * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$3 - N[(im * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 - im), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right)\\
t_1 := -0.16666666666666666 \cdot {im}^{3}\\
t_2 := -0.3333333333333333 \cdot \left(im \cdot im\right)\\
t_3 := im \cdot t_2\\
\mathbf{if}\;im \leq -7.8 \cdot 10^{+233}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq -49000000:\\
\;\;\;\;t_0 \cdot \left(im \cdot \left(-2 + t_2\right)\right)\\

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

\mathbf{elif}\;im \leq 8.2 \cdot 10^{+102}:\\
\;\;\;\;t_0 \cdot \frac{t_3 \cdot t_3 - \left(im \cdot -2\right) \cdot \left(im \cdot -2\right)}{t_3 - im \cdot -2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < -7.7999999999999998e233

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} \]
    10. Simplified90.0%

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

    if -7.7999999999999998e233 < im < -4.9e7

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({re}^{2}, -0.25, 0.5\right)} \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -2 \cdot im\right) \]
      7. unpow263.0%

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

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(-0.3333333333333333 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot im\right)} + -2 \cdot im\right) \]
      9. associate-*r*63.0%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(\color{blue}{\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im} + -2 \cdot im\right) \]
      10. distribute-rgt-out63.0%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \color{blue}{\left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
    9. Simplified63.0%

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

    if -4.9e7 < im < 6.5

    1. Initial program 13.3%

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

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

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

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

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

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

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

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

    if 6.5 < im < 8.1999999999999999e102

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({re}^{2}, -0.25, 0.5\right)} \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -2 \cdot im\right) \]
      7. unpow232.9%

        \[\leadsto \mathsf{fma}\left(\color{blue}{re \cdot re}, -0.25, 0.5\right) \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -2 \cdot im\right) \]
      8. unpow332.9%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(-0.3333333333333333 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot im\right)} + -2 \cdot im\right) \]
      9. associate-*r*32.9%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(\color{blue}{\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im} + -2 \cdot im\right) \]
      10. distribute-rgt-out32.9%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \color{blue}{\left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
    9. Simplified32.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
    10. Step-by-step derivation
      1. distribute-rgt-in32.9%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \color{blue}{\left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im + -2 \cdot im\right)} \]
      2. flip-+72.9%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \color{blue}{\frac{\left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im\right) - \left(-2 \cdot im\right) \cdot \left(-2 \cdot im\right)}{\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im - -2 \cdot im}} \]
    11. Applied egg-rr72.9%

      \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \color{blue}{\frac{\left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im\right) - \left(-2 \cdot im\right) \cdot \left(-2 \cdot im\right)}{\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im - -2 \cdot im}} \]

    if 8.1999999999999999e102 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -7.8 \cdot 10^{+233}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\ \mathbf{elif}\;im \leq -49000000:\\ \;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(im \cdot \left(-2 + -0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right)\\ \mathbf{elif}\;im \leq 6.5:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+102}:\\ \;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \frac{\left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right) \cdot \left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right) - \left(im \cdot -2\right) \cdot \left(im \cdot -2\right)}{im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) - im \cdot -2}\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3} - im\\ \end{array} \]

Alternative 8: 77.8% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq -1.6 \cdot 10^{+233}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\ \mathbf{elif}\;im \leq -110000000 \lor \neg \left(im \leq 6.5\right):\\ \;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(im \cdot \left(-2 + -0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im -1.6e+233)
   (* -0.16666666666666666 (pow im 3.0))
   (if (or (<= im -110000000.0) (not (<= im 6.5)))
     (*
      (fma (* re re) -0.25 0.5)
      (* im (+ -2.0 (* -0.3333333333333333 (* im im)))))
     (* im (- (cos re))))))
double code(double re, double im) {
	double tmp;
	if (im <= -1.6e+233) {
		tmp = -0.16666666666666666 * pow(im, 3.0);
	} else if ((im <= -110000000.0) || !(im <= 6.5)) {
		tmp = fma((re * re), -0.25, 0.5) * (im * (-2.0 + (-0.3333333333333333 * (im * im))));
	} else {
		tmp = im * -cos(re);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= -1.6e+233)
		tmp = Float64(-0.16666666666666666 * (im ^ 3.0));
	elseif ((im <= -110000000.0) || !(im <= 6.5))
		tmp = Float64(fma(Float64(re * re), -0.25, 0.5) * Float64(im * Float64(-2.0 + Float64(-0.3333333333333333 * Float64(im * im)))));
	else
		tmp = Float64(im * Float64(-cos(re)));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, -1.6e+233], N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, -110000000.0], N[Not[LessEqual[im, 6.5]], $MachinePrecision]], N[(N[(N[(re * re), $MachinePrecision] * -0.25 + 0.5), $MachinePrecision] * N[(im * N[(-2.0 + N[(-0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.6 \cdot 10^{+233}:\\
\;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\

\mathbf{elif}\;im \leq -110000000 \lor \neg \left(im \leq 6.5\right):\\
\;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(im \cdot \left(-2 + -0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} \]
    10. Simplified90.0%

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

    if -1.60000000000000009e233 < im < -1.1e8 or 6.5 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(-0.3333333333333333 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot im\right)} + -2 \cdot im\right) \]
      9. associate-*r*60.2%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(\color{blue}{\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im} + -2 \cdot im\right) \]
      10. distribute-rgt-out60.2%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \color{blue}{\left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
    9. Simplified60.2%

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

    if -1.1e8 < im < 6.5

    1. Initial program 13.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -1.6 \cdot 10^{+233}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\ \mathbf{elif}\;im \leq -110000000 \lor \neg \left(im \leq 6.5\right):\\ \;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(im \cdot \left(-2 + -0.3333333333333333 \cdot \left(im \cdot im\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \end{array} \]

Alternative 9: 75.4% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -0.16666666666666666 \cdot {im}^{3}\\ \mathbf{if}\;im \leq -2.8 \cdot 10^{+122}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq -8.5 \cdot 10^{+16}:\\ \;\;\;\;-0.25 \cdot \left(\left(im \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(-0.3333333333333333, im \cdot im, -2\right)\right)\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+50}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 - im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* -0.16666666666666666 (pow im 3.0))))
   (if (<= im -2.8e+122)
     t_0
     (if (<= im -8.5e+16)
       (* -0.25 (* (* im (* re re)) (fma -0.3333333333333333 (* im im) -2.0)))
       (if (<= im 3.3e+50) (* im (- (cos re))) (- t_0 im))))))
double code(double re, double im) {
	double t_0 = -0.16666666666666666 * pow(im, 3.0);
	double tmp;
	if (im <= -2.8e+122) {
		tmp = t_0;
	} else if (im <= -8.5e+16) {
		tmp = -0.25 * ((im * (re * re)) * fma(-0.3333333333333333, (im * im), -2.0));
	} else if (im <= 3.3e+50) {
		tmp = im * -cos(re);
	} else {
		tmp = t_0 - im;
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(-0.16666666666666666 * (im ^ 3.0))
	tmp = 0.0
	if (im <= -2.8e+122)
		tmp = t_0;
	elseif (im <= -8.5e+16)
		tmp = Float64(-0.25 * Float64(Float64(im * Float64(re * re)) * fma(-0.3333333333333333, Float64(im * im), -2.0)));
	elseif (im <= 3.3e+50)
		tmp = Float64(im * Float64(-cos(re)));
	else
		tmp = Float64(t_0 - im);
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(-0.16666666666666666 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.8e+122], t$95$0, If[LessEqual[im, -8.5e+16], N[(-0.25 * N[(N[(im * N[(re * re), $MachinePrecision]), $MachinePrecision] * N[(-0.3333333333333333 * N[(im * im), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.3e+50], N[(im * (-N[Cos[re], $MachinePrecision])), $MachinePrecision], N[(t$95$0 - im), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq -8.5 \cdot 10^{+16}:\\
\;\;\;\;-0.25 \cdot \left(\left(im \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(-0.3333333333333333, im \cdot im, -2\right)\right)\\

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} \]
    10. Simplified77.8%

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

    if -2.8e122 < im < -8.5e16

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({re}^{2}, -0.25, 0.5\right)} \cdot \left(-0.3333333333333333 \cdot {im}^{3} + -2 \cdot im\right) \]
      7. unpow246.0%

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

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(-0.3333333333333333 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot im\right)} + -2 \cdot im\right) \]
      9. associate-*r*46.0%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(\color{blue}{\left(-0.3333333333333333 \cdot \left(im \cdot im\right)\right) \cdot im} + -2 \cdot im\right) \]
      10. distribute-rgt-out46.0%

        \[\leadsto \mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \color{blue}{\left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
    9. Simplified46.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot \left(im \cdot \left(-0.3333333333333333 \cdot \left(im \cdot im\right) + -2\right)\right)} \]
    10. Taylor expanded in re around inf 39.4%

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

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

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

        \[\leadsto -0.25 \cdot \left(\left(im \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \left(-0.3333333333333333 \cdot {im}^{2} - 2\right)\right) \]
      4. fma-neg39.4%

        \[\leadsto -0.25 \cdot \left(\left(im \cdot \left(re \cdot re\right)\right) \cdot \color{blue}{\mathsf{fma}\left(-0.3333333333333333, {im}^{2}, -2\right)}\right) \]
      5. unpow239.4%

        \[\leadsto -0.25 \cdot \left(\left(im \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(-0.3333333333333333, \color{blue}{im \cdot im}, -2\right)\right) \]
      6. metadata-eval39.4%

        \[\leadsto -0.25 \cdot \left(\left(im \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(-0.3333333333333333, im \cdot im, \color{blue}{-2}\right)\right) \]
    12. Simplified39.4%

      \[\leadsto \color{blue}{-0.25 \cdot \left(\left(im \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(-0.3333333333333333, im \cdot im, -2\right)\right)} \]

    if -8.5e16 < im < 3.3e50

    1. Initial program 18.0%

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

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

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

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

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

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

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

    if 3.3e50 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -2.8 \cdot 10^{+122}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\ \mathbf{elif}\;im \leq -8.5 \cdot 10^{+16}:\\ \;\;\;\;-0.25 \cdot \left(\left(im \cdot \left(re \cdot re\right)\right) \cdot \mathsf{fma}\left(-0.3333333333333333, im \cdot im, -2\right)\right)\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+50}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3} - im\\ \end{array} \]

Alternative 10: 75.2% accurate, 2.8× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]
    9. Step-by-step derivation
      1. *-commutative72.4%

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} \]
    10. Simplified72.4%

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

    if -9.6000000000000001e86 < im < 2.25e52

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

    if 2.25e52 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq -9.6 \cdot 10^{+86}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\ \mathbf{elif}\;im \leq 2.25 \cdot 10^{+52}:\\ \;\;\;\;im \cdot \left(-\cos re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {im}^{3} - im\\ \end{array} \]

Alternative 11: 60.2% accurate, 2.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -6.8e16 or 6.5 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.8e16 < im < 6.5

    1. Initial program 14.5%

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

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

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

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

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

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

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

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

Alternative 12: 75.2% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.5 \cdot 10^{+86} \lor \neg \left(im \leq 8.4 \cdot 10^{+43}\right):\\
\;\;\;\;-0.16666666666666666 \cdot {im}^{3}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < -6.49999999999999996e86 or 8.40000000000000007e43 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {im}^{3}} \]
    9. Step-by-step derivation
      1. *-commutative66.7%

        \[\leadsto \color{blue}{{im}^{3} \cdot -0.16666666666666666} \]
    10. Simplified66.7%

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

    if -6.49999999999999996e86 < im < 8.40000000000000007e43

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

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

Alternative 13: 36.2% accurate, 10.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := re \cdot \left(re \cdot -0.25\right)\\ \mathbf{if}\;re \leq 1.05 \cdot 10^{+80}:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \mathbf{elif}\;re \leq 3.1 \cdot 10^{+153}:\\ \;\;\;\;\frac{182.25 - 729 \cdot \left(t_0 \cdot t_0\right)}{13.5 - \left(re \cdot -0.25\right) \cdot \left(re \cdot 27\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 + t_0\right) \cdot -3\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* re (* re -0.25))))
   (if (<= re 1.05e+80)
     (- (* re (* re (* im 0.5))) im)
     (if (<= re 3.1e+153)
       (/
        (- 182.25 (* 729.0 (* t_0 t_0)))
        (- 13.5 (* (* re -0.25) (* re 27.0))))
       (* (+ 0.5 t_0) -3.0)))))
double code(double re, double im) {
	double t_0 = re * (re * -0.25);
	double tmp;
	if (re <= 1.05e+80) {
		tmp = (re * (re * (im * 0.5))) - im;
	} else if (re <= 3.1e+153) {
		tmp = (182.25 - (729.0 * (t_0 * t_0))) / (13.5 - ((re * -0.25) * (re * 27.0)));
	} else {
		tmp = (0.5 + t_0) * -3.0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = re * (re * (-0.25d0))
    if (re <= 1.05d+80) then
        tmp = (re * (re * (im * 0.5d0))) - im
    else if (re <= 3.1d+153) then
        tmp = (182.25d0 - (729.0d0 * (t_0 * t_0))) / (13.5d0 - ((re * (-0.25d0)) * (re * 27.0d0)))
    else
        tmp = (0.5d0 + t_0) * (-3.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = re * (re * -0.25);
	double tmp;
	if (re <= 1.05e+80) {
		tmp = (re * (re * (im * 0.5))) - im;
	} else if (re <= 3.1e+153) {
		tmp = (182.25 - (729.0 * (t_0 * t_0))) / (13.5 - ((re * -0.25) * (re * 27.0)));
	} else {
		tmp = (0.5 + t_0) * -3.0;
	}
	return tmp;
}
def code(re, im):
	t_0 = re * (re * -0.25)
	tmp = 0
	if re <= 1.05e+80:
		tmp = (re * (re * (im * 0.5))) - im
	elif re <= 3.1e+153:
		tmp = (182.25 - (729.0 * (t_0 * t_0))) / (13.5 - ((re * -0.25) * (re * 27.0)))
	else:
		tmp = (0.5 + t_0) * -3.0
	return tmp
function code(re, im)
	t_0 = Float64(re * Float64(re * -0.25))
	tmp = 0.0
	if (re <= 1.05e+80)
		tmp = Float64(Float64(re * Float64(re * Float64(im * 0.5))) - im);
	elseif (re <= 3.1e+153)
		tmp = Float64(Float64(182.25 - Float64(729.0 * Float64(t_0 * t_0))) / Float64(13.5 - Float64(Float64(re * -0.25) * Float64(re * 27.0))));
	else
		tmp = Float64(Float64(0.5 + t_0) * -3.0);
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = re * (re * -0.25);
	tmp = 0.0;
	if (re <= 1.05e+80)
		tmp = (re * (re * (im * 0.5))) - im;
	elseif (re <= 3.1e+153)
		tmp = (182.25 - (729.0 * (t_0 * t_0))) / (13.5 - ((re * -0.25) * (re * 27.0)));
	else
		tmp = (0.5 + t_0) * -3.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, 1.05e+80], N[(N[(re * N[(re * N[(im * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], If[LessEqual[re, 3.1e+153], N[(N[(182.25 - N[(729.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(13.5 - N[(N[(re * -0.25), $MachinePrecision] * N[(re * 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 + t$95$0), $MachinePrecision] * -3.0), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := re \cdot \left(re \cdot -0.25\right)\\
\mathbf{if}\;re \leq 1.05 \cdot 10^{+80}:\\
\;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\

\mathbf{elif}\;re \leq 3.1 \cdot 10^{+153}:\\
\;\;\;\;\frac{182.25 - 729 \cdot \left(t_0 \cdot t_0\right)}{13.5 - \left(re \cdot -0.25\right) \cdot \left(re \cdot 27\right)}\\

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


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

    1. Initial program 54.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.05000000000000001e80 < re < 3.1e153

    1. Initial program 39.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(27 \cdot 0.5\right) \cdot \left(27 \cdot 0.5\right) - \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{27 \cdot 0.5 - 27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)}} \]
      3. metadata-eval21.4%

        \[\leadsto \frac{\color{blue}{13.5} \cdot \left(27 \cdot 0.5\right) - \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{27 \cdot 0.5 - 27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      4. metadata-eval21.4%

        \[\leadsto \frac{13.5 \cdot \color{blue}{13.5} - \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{27 \cdot 0.5 - 27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      5. metadata-eval21.4%

        \[\leadsto \frac{\color{blue}{182.25} - \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{27 \cdot 0.5 - 27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      6. metadata-eval21.4%

        \[\leadsto \frac{182.25 - \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{\color{blue}{13.5} - 27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
    9. Applied egg-rr21.4%

      \[\leadsto \color{blue}{\frac{182.25 - \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{13.5 - 27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)}} \]
    10. Step-by-step derivation
      1. *-commutative21.4%

        \[\leadsto \frac{182.25 - \color{blue}{\left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\right)} \cdot \left(27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{13.5 - 27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      2. *-commutative21.4%

        \[\leadsto \frac{182.25 - \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\right) \cdot \color{blue}{\left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\right)}}{13.5 - 27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)} \]
      3. *-commutative21.4%

        \[\leadsto \frac{182.25 - \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\right) \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot 27\right)}{13.5 - \color{blue}{\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot 27}} \]
      4. swap-sqr21.4%

        \[\leadsto \frac{182.25 - \color{blue}{\left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(27 \cdot 27\right)}}{13.5 - \left(re \cdot \left(re \cdot -0.25\right)\right) \cdot 27} \]
      5. *-commutative21.4%

        \[\leadsto \frac{182.25 - \color{blue}{\left(27 \cdot 27\right) \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}}{13.5 - \left(re \cdot \left(re \cdot -0.25\right)\right) \cdot 27} \]
      6. metadata-eval21.4%

        \[\leadsto \frac{182.25 - \color{blue}{729} \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{13.5 - \left(re \cdot \left(re \cdot -0.25\right)\right) \cdot 27} \]
      7. *-commutative21.4%

        \[\leadsto \frac{182.25 - 729 \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{13.5 - \color{blue}{27 \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)}} \]
      8. associate-*r*21.4%

        \[\leadsto \frac{182.25 - 729 \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{13.5 - \color{blue}{\left(27 \cdot re\right) \cdot \left(re \cdot -0.25\right)}} \]
    11. Simplified21.4%

      \[\leadsto \color{blue}{\frac{182.25 - 729 \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{13.5 - \left(27 \cdot re\right) \cdot \left(re \cdot -0.25\right)}} \]

    if 3.1e153 < re

    1. Initial program 53.1%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.05 \cdot 10^{+80}:\\ \;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\ \mathbf{elif}\;re \leq 3.1 \cdot 10^{+153}:\\ \;\;\;\;\frac{182.25 - 729 \cdot \left(\left(re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(re \cdot \left(re \cdot -0.25\right)\right)\right)}{13.5 - \left(re \cdot -0.25\right) \cdot \left(re \cdot 27\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot -3\\ \end{array} \]

Alternative 14: 32.0% accurate, 27.9× speedup?

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

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

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


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

    1. Initial program 53.4%

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

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

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

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

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

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

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

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

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

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

    if 5.49999999999999966e162 < re

    1. Initial program 51.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 35.8% accurate, 27.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.9 \cdot 10^{+158}:\\
\;\;\;\;re \cdot \left(re \cdot \left(im \cdot 0.5\right)\right) - im\\

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


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

    1. Initial program 53.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.9e158 < re

    1. Initial program 51.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 32.4% accurate, 43.8× speedup?

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

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

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


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

    1. Initial program 53.3%

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

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

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

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

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

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

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

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

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

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

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

    if 2.8000000000000002e152 < re

    1. Initial program 53.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot -6.75} \]
      2. unpow212.1%

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

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

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

        \[\leadsto \color{blue}{{re}^{2} \cdot -6.75} \]
      2. unpow212.1%

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

        \[\leadsto \color{blue}{re \cdot \left(re \cdot -6.75\right)} \]
    13. Simplified12.1%

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

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

Alternative 17: 30.2% accurate, 154.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -im \]

Alternative 18: 2.9% accurate, 309.0× speedup?

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

\\
13.5
\end{array}
Derivation
  1. Initial program 53.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 13.5 \]

Developer target: 99.8% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

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