math.cos on complex, imaginary part

Percentage Accurate: 65.1% → 99.1%
Time: 18.9s
Alternatives: 27
Speedup: 2.2×

Specification

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

\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-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 27 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: 65.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.1% accurate, 1.0× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im\_m} - e^{im\_m}\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 2.6e-15)
    (* (- im_m) (sin re))
    (* (* (sin re) 0.5) (- (exp (- im_m)) (exp im_m))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * sin(re);
	} else {
		tmp = (sin(re) * 0.5) * (exp(-im_m) - exp(im_m));
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 2.6d-15) then
        tmp = -im_m * sin(re)
    else
        tmp = (sin(re) * 0.5d0) * (exp(-im_m) - exp(im_m))
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * Math.sin(re);
	} else {
		tmp = (Math.sin(re) * 0.5) * (Math.exp(-im_m) - Math.exp(im_m));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 2.6e-15:
		tmp = -im_m * math.sin(re)
	else:
		tmp = (math.sin(re) * 0.5) * (math.exp(-im_m) - math.exp(im_m))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 2.6e-15)
		tmp = Float64(Float64(-im_m) * sin(re));
	else
		tmp = Float64(Float64(sin(re) * 0.5) * Float64(exp(Float64(-im_m)) - exp(im_m)));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 2.6e-15)
		tmp = -im_m * sin(re);
	else
		tmp = (sin(re) * 0.5) * (exp(-im_m) - exp(im_m));
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 2.6e-15], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 2.60000000000000004e-15

    1. Initial program 57.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 61.5%

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

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

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

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

    if 2.60000000000000004e-15 < im

    1. Initial program 98.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification71.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{else}:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} - e^{im}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 72.1% accurate, 1.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 2.7 \cdot 10^{+208}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im\_m \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;\sqrt{{im\_m}^{2} \cdot 0.027777777777777776}\\ \mathbf{elif}\;im\_m \leq 7.2 \cdot 10^{+239}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot -0.004629629629629629\right)\right)\\ \mathbf{elif}\;im\_m \leq 6.5 \cdot 10^{+252} \lor \neg \left(im\_m \leq 6.6 \cdot 10^{+273}\right):\\ \;\;\;\;\left(-im\_m\right) \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im\_m}^{3}\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 2.6e-15)
    (* (- im_m) (sin re))
    (if (<= im_m 2.7e+208)
      (log1p (expm1 (* im_m -0.16666666666666666)))
      (if (<= im_m 1.58e+227)
        (sqrt (* (pow im_m 2.0) 0.027777777777777776))
        (if (<= im_m 7.2e+239)
          (log1p (expm1 (* im_m -0.004629629629629629)))
          (if (or (<= im_m 6.5e+252) (not (<= im_m 6.6e+273)))
            (* (- im_m) (+ re (* -0.16666666666666666 (pow re 3.0))))
            (* -0.16666666666666666 (* re (pow im_m 3.0))))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 2.7e+208) {
		tmp = log1p(expm1((im_m * -0.16666666666666666)));
	} else if (im_m <= 1.58e+227) {
		tmp = sqrt((pow(im_m, 2.0) * 0.027777777777777776));
	} else if (im_m <= 7.2e+239) {
		tmp = log1p(expm1((im_m * -0.004629629629629629)));
	} else if ((im_m <= 6.5e+252) || !(im_m <= 6.6e+273)) {
		tmp = -im_m * (re + (-0.16666666666666666 * pow(re, 3.0)));
	} else {
		tmp = -0.16666666666666666 * (re * pow(im_m, 3.0));
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 2.7e+208) {
		tmp = Math.log1p(Math.expm1((im_m * -0.16666666666666666)));
	} else if (im_m <= 1.58e+227) {
		tmp = Math.sqrt((Math.pow(im_m, 2.0) * 0.027777777777777776));
	} else if (im_m <= 7.2e+239) {
		tmp = Math.log1p(Math.expm1((im_m * -0.004629629629629629)));
	} else if ((im_m <= 6.5e+252) || !(im_m <= 6.6e+273)) {
		tmp = -im_m * (re + (-0.16666666666666666 * Math.pow(re, 3.0)));
	} else {
		tmp = -0.16666666666666666 * (re * Math.pow(im_m, 3.0));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 2.6e-15:
		tmp = -im_m * math.sin(re)
	elif im_m <= 2.7e+208:
		tmp = math.log1p(math.expm1((im_m * -0.16666666666666666)))
	elif im_m <= 1.58e+227:
		tmp = math.sqrt((math.pow(im_m, 2.0) * 0.027777777777777776))
	elif im_m <= 7.2e+239:
		tmp = math.log1p(math.expm1((im_m * -0.004629629629629629)))
	elif (im_m <= 6.5e+252) or not (im_m <= 6.6e+273):
		tmp = -im_m * (re + (-0.16666666666666666 * math.pow(re, 3.0)))
	else:
		tmp = -0.16666666666666666 * (re * math.pow(im_m, 3.0))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 2.6e-15)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 2.7e+208)
		tmp = log1p(expm1(Float64(im_m * -0.16666666666666666)));
	elseif (im_m <= 1.58e+227)
		tmp = sqrt(Float64((im_m ^ 2.0) * 0.027777777777777776));
	elseif (im_m <= 7.2e+239)
		tmp = log1p(expm1(Float64(im_m * -0.004629629629629629)));
	elseif ((im_m <= 6.5e+252) || !(im_m <= 6.6e+273))
		tmp = Float64(Float64(-im_m) * Float64(re + Float64(-0.16666666666666666 * (re ^ 3.0))));
	else
		tmp = Float64(-0.16666666666666666 * Float64(re * (im_m ^ 3.0)));
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 2.6e-15], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 2.7e+208], N[Log[1 + N[(Exp[N[(im$95$m * -0.16666666666666666), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im$95$m, 1.58e+227], N[Sqrt[N[(N[Power[im$95$m, 2.0], $MachinePrecision] * 0.027777777777777776), $MachinePrecision]], $MachinePrecision], If[LessEqual[im$95$m, 7.2e+239], N[Log[1 + N[(Exp[N[(im$95$m * -0.004629629629629629), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[im$95$m, 6.5e+252], N[Not[LessEqual[im$95$m, 6.6e+273]], $MachinePrecision]], N[((-im$95$m) * N[(re + N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.16666666666666666 * N[(re * N[Power[im$95$m, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\

\mathbf{elif}\;im\_m \leq 2.7 \cdot 10^{+208}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot -0.16666666666666666\right)\right)\\

\mathbf{elif}\;im\_m \leq 1.58 \cdot 10^{+227}:\\
\;\;\;\;\sqrt{{im\_m}^{2} \cdot 0.027777777777777776}\\

\mathbf{elif}\;im\_m \leq 7.2 \cdot 10^{+239}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot -0.004629629629629629\right)\right)\\

\mathbf{elif}\;im\_m \leq 6.5 \cdot 10^{+252} \lor \neg \left(im\_m \leq 6.6 \cdot 10^{+273}\right):\\
\;\;\;\;\left(-im\_m\right) \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if im < 2.60000000000000004e-15

    1. Initial program 57.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 61.5%

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

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

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

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

    if 2.60000000000000004e-15 < im < 2.7e208

    1. Initial program 98.3%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 72.5%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in72.5%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+72.5%

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

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative72.5%

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + -1 \cdot \sin re\right)}\right) \]
    5. Simplified76.6%

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr2.5%

      \[\leadsto im \cdot \color{blue}{-0.16666666666666666} \]
    7. Step-by-step derivation
      1. log1p-expm1-u51.2%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -0.16666666666666666\right)\right)} \]
    8. Applied egg-rr51.2%

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

    if 2.7e208 < im < 1.57999999999999994e227

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+100.0%

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

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr3.6%

      \[\leadsto im \cdot \color{blue}{-0.16666666666666666} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \color{blue}{\sqrt{im \cdot -0.16666666666666666} \cdot \sqrt{im \cdot -0.16666666666666666}} \]
      2. sqrt-unprod40.0%

        \[\leadsto \color{blue}{\sqrt{\left(im \cdot -0.16666666666666666\right) \cdot \left(im \cdot -0.16666666666666666\right)}} \]
      3. swap-sqr40.0%

        \[\leadsto \sqrt{\color{blue}{\left(im \cdot im\right) \cdot \left(-0.16666666666666666 \cdot -0.16666666666666666\right)}} \]
      4. unpow240.0%

        \[\leadsto \sqrt{\color{blue}{{im}^{2}} \cdot \left(-0.16666666666666666 \cdot -0.16666666666666666\right)} \]
      5. metadata-eval40.0%

        \[\leadsto \sqrt{{im}^{2} \cdot \color{blue}{0.027777777777777776}} \]
    8. Applied egg-rr40.0%

      \[\leadsto \color{blue}{\sqrt{{im}^{2} \cdot 0.027777777777777776}} \]

    if 1.57999999999999994e227 < im < 7.2e239

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+100.0%

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

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr4.7%

      \[\leadsto im \cdot \color{blue}{-0.004629629629629629} \]
    7. Step-by-step derivation
      1. log1p-expm1-u75.0%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -0.004629629629629629\right)\right)} \]
    8. Applied egg-rr75.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -0.004629629629629629\right)\right)} \]

    if 7.2e239 < im < 6.5e252 or 6.59999999999999971e273 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 8.7%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    5. Simplified8.7%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr8.7%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin re\right)\right)} \]
    7. Taylor expanded in re around 0 86.5%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(re \cdot \left(1 + -0.16666666666666666 \cdot {re}^{2}\right)\right)} \]
    8. Step-by-step derivation
      1. distribute-rgt-in86.5%

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

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

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

        \[\leadsto \left(-im\right) \cdot \left(re + -0.16666666666666666 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot re\right)\right) \]
      5. unpow386.5%

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

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

    if 6.5e252 < im < 6.59999999999999971e273

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + -0.16666666666666666 \cdot \left({im}^{2} \cdot \sin re\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative100.0%

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

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left(\sin re \cdot {im}^{2}\right)} - \sin re\right) \]
      5. associate-*r*100.0%

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

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left({im}^{2} \cdot \sin re\right)}\right) - im \cdot \sin re \]
      9. associate-*r*100.0%

        \[\leadsto im \cdot \color{blue}{\left(\left(-0.16666666666666666 \cdot {im}^{2}\right) \cdot \sin re\right)} - im \cdot \sin re \]
      10. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(im \cdot \left(-0.16666666666666666 \cdot {im}^{2}\right)\right) \cdot \sin re} - im \cdot \sin re \]
      11. distribute-rgt-out--100.0%

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

        \[\leadsto \sin re \cdot \left(im \cdot \color{blue}{\left({im}^{2} \cdot -0.16666666666666666\right)} - im\right) \]
      13. associate-*r*100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(im \cdot {im}^{2}\right) \cdot -0.16666666666666666} - im\right) \]
      14. unpow2100.0%

        \[\leadsto \sin re \cdot \left(\left(im \cdot \color{blue}{\left(im \cdot im\right)}\right) \cdot -0.16666666666666666 - im\right) \]
      15. cube-unmult100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+208}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;\sqrt{{im}^{2} \cdot 0.027777777777777776}\\ \mathbf{elif}\;im \leq 7.2 \cdot 10^{+239}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -0.004629629629629629\right)\right)\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+252} \lor \neg \left(im \leq 6.6 \cdot 10^{+273}\right):\\ \;\;\;\;\left(-im\right) \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 97.1% accurate, 1.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 8.2 \cdot 10^{-8}:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 10^{+39}:\\ \;\;\;\;\left(e^{-im\_m} - e^{im\_m}\right) \cdot \left(re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im\_m}^{7}\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 8.2e-8)
    (* (- im_m) (sin re))
    (if (<= im_m 1e+39)
      (* (- (exp (- im_m)) (exp im_m)) (* re 0.5))
      (* -0.0001984126984126984 (* (sin re) (pow im_m 7.0)))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 8.2e-8) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 1e+39) {
		tmp = (exp(-im_m) - exp(im_m)) * (re * 0.5);
	} else {
		tmp = -0.0001984126984126984 * (sin(re) * pow(im_m, 7.0));
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 8.2d-8) then
        tmp = -im_m * sin(re)
    else if (im_m <= 1d+39) then
        tmp = (exp(-im_m) - exp(im_m)) * (re * 0.5d0)
    else
        tmp = (-0.0001984126984126984d0) * (sin(re) * (im_m ** 7.0d0))
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 8.2e-8) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 1e+39) {
		tmp = (Math.exp(-im_m) - Math.exp(im_m)) * (re * 0.5);
	} else {
		tmp = -0.0001984126984126984 * (Math.sin(re) * Math.pow(im_m, 7.0));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 8.2e-8:
		tmp = -im_m * math.sin(re)
	elif im_m <= 1e+39:
		tmp = (math.exp(-im_m) - math.exp(im_m)) * (re * 0.5)
	else:
		tmp = -0.0001984126984126984 * (math.sin(re) * math.pow(im_m, 7.0))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 8.2e-8)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 1e+39)
		tmp = Float64(Float64(exp(Float64(-im_m)) - exp(im_m)) * Float64(re * 0.5));
	else
		tmp = Float64(-0.0001984126984126984 * Float64(sin(re) * (im_m ^ 7.0)));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 8.2e-8)
		tmp = -im_m * sin(re);
	elseif (im_m <= 1e+39)
		tmp = (exp(-im_m) - exp(im_m)) * (re * 0.5);
	else
		tmp = -0.0001984126984126984 * (sin(re) * (im_m ^ 7.0));
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 8.2e-8], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 1e+39], N[(N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision], N[(-0.0001984126984126984 * N[(N[Sin[re], $MachinePrecision] * N[Power[im$95$m, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 8.2 \cdot 10^{-8}:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\

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

\mathbf{else}:\\
\;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im\_m}^{7}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 8.20000000000000063e-8

    1. Initial program 57.8%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 61.7%

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

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

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

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

    if 8.20000000000000063e-8 < im < 9.9999999999999994e38

    1. Initial program 99.5%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 67.4%

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

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

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

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

    if 9.9999999999999994e38 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 91.8%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in91.8%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+91.8%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative91.8%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative91.8%

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Taylor expanded in im around inf 96.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 8.2 \cdot 10^{-8}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 10^{+39}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(re \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 95.0% accurate, 1.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 0.2:\\ \;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\ \mathbf{elif}\;im\_m \leq 2.4 \cdot 10^{+29}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im\_m}^{7}\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 0.2)
    (* (sin re) (- (* (pow im_m 3.0) -0.16666666666666666) im_m))
    (if (<= im_m 2.4e+29)
      (log1p (expm1 (* im_m -0.16666666666666666)))
      (* -0.0001984126984126984 (* (sin re) (pow im_m 7.0)))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 0.2) {
		tmp = sin(re) * ((pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	} else if (im_m <= 2.4e+29) {
		tmp = log1p(expm1((im_m * -0.16666666666666666)));
	} else {
		tmp = -0.0001984126984126984 * (sin(re) * pow(im_m, 7.0));
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 0.2) {
		tmp = Math.sin(re) * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	} else if (im_m <= 2.4e+29) {
		tmp = Math.log1p(Math.expm1((im_m * -0.16666666666666666)));
	} else {
		tmp = -0.0001984126984126984 * (Math.sin(re) * Math.pow(im_m, 7.0));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 0.2:
		tmp = math.sin(re) * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m)
	elif im_m <= 2.4e+29:
		tmp = math.log1p(math.expm1((im_m * -0.16666666666666666)))
	else:
		tmp = -0.0001984126984126984 * (math.sin(re) * math.pow(im_m, 7.0))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 0.2)
		tmp = Float64(sin(re) * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - im_m));
	elseif (im_m <= 2.4e+29)
		tmp = log1p(expm1(Float64(im_m * -0.16666666666666666)));
	else
		tmp = Float64(-0.0001984126984126984 * Float64(sin(re) * (im_m ^ 7.0)));
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 0.2], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 2.4e+29], N[Log[1 + N[(Exp[N[(im$95$m * -0.16666666666666666), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], N[(-0.0001984126984126984 * N[(N[Sin[re], $MachinePrecision] * N[Power[im$95$m, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 0.2:\\
\;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\

\mathbf{elif}\;im\_m \leq 2.4 \cdot 10^{+29}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot -0.16666666666666666\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im\_m}^{7}\right)\\


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

    1. Initial program 58.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 89.4%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + -0.16666666666666666 \cdot \left({im}^{2} \cdot \sin re\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative89.4%

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

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left(\sin re \cdot {im}^{2}\right)} - \sin re\right) \]
      5. associate-*r*89.4%

        \[\leadsto im \cdot \left(\color{blue}{\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}} - \sin re\right) \]
      6. distribute-lft-out--89.4%

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left({im}^{2} \cdot \sin re\right)}\right) - im \cdot \sin re \]
      9. associate-*r*89.4%

        \[\leadsto im \cdot \color{blue}{\left(\left(-0.16666666666666666 \cdot {im}^{2}\right) \cdot \sin re\right)} - im \cdot \sin re \]
      10. associate-*r*92.8%

        \[\leadsto \color{blue}{\left(im \cdot \left(-0.16666666666666666 \cdot {im}^{2}\right)\right) \cdot \sin re} - im \cdot \sin re \]
      11. distribute-rgt-out--92.8%

        \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(-0.16666666666666666 \cdot {im}^{2}\right) - im\right)} \]
      12. *-commutative92.8%

        \[\leadsto \sin re \cdot \left(im \cdot \color{blue}{\left({im}^{2} \cdot -0.16666666666666666\right)} - im\right) \]
      13. associate-*r*92.8%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(im \cdot {im}^{2}\right) \cdot -0.16666666666666666} - im\right) \]
      14. unpow292.8%

        \[\leadsto \sin re \cdot \left(\left(im \cdot \color{blue}{\left(im \cdot im\right)}\right) \cdot -0.16666666666666666 - im\right) \]
      15. cube-unmult92.8%

        \[\leadsto \sin re \cdot \left(\color{blue}{{im}^{3}} \cdot -0.16666666666666666 - im\right) \]
    5. Simplified92.8%

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

    if 0.20000000000000001 < im < 2.4000000000000001e29

    1. Initial program 99.8%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 3.6%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in3.6%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+3.6%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative3.6%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative3.6%

        \[\leadsto im \cdot \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right)\right)} \]
      5. +-commutative3.6%

        \[\leadsto im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + -1 \cdot \sin re\right)}\right) \]
    5. Simplified3.6%

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr2.2%

      \[\leadsto im \cdot \color{blue}{-0.16666666666666666} \]
    7. Step-by-step derivation
      1. log1p-expm1-u57.2%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -0.16666666666666666\right)\right)} \]
    8. Applied egg-rr57.2%

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

    if 2.4000000000000001e29 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 90.3%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in90.3%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+90.3%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative90.3%

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Taylor expanded in im around inf 95.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.2:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 2.4 \cdot 10^{+29}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 95.5% accurate, 1.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 0.00078:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 10^{+39}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im\_m}^{7}\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 0.00078)
    (* (- im_m) (sin re))
    (if (<= im_m 1e+39)
      (log1p (expm1 (* im_m -0.16666666666666666)))
      (* -0.0001984126984126984 (* (sin re) (pow im_m 7.0)))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 0.00078) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 1e+39) {
		tmp = log1p(expm1((im_m * -0.16666666666666666)));
	} else {
		tmp = -0.0001984126984126984 * (sin(re) * pow(im_m, 7.0));
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 0.00078) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 1e+39) {
		tmp = Math.log1p(Math.expm1((im_m * -0.16666666666666666)));
	} else {
		tmp = -0.0001984126984126984 * (Math.sin(re) * Math.pow(im_m, 7.0));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 0.00078:
		tmp = -im_m * math.sin(re)
	elif im_m <= 1e+39:
		tmp = math.log1p(math.expm1((im_m * -0.16666666666666666)))
	else:
		tmp = -0.0001984126984126984 * (math.sin(re) * math.pow(im_m, 7.0))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 0.00078)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 1e+39)
		tmp = log1p(expm1(Float64(im_m * -0.16666666666666666)));
	else
		tmp = Float64(-0.0001984126984126984 * Float64(sin(re) * (im_m ^ 7.0)));
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 0.00078], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 1e+39], N[Log[1 + N[(Exp[N[(im$95$m * -0.16666666666666666), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], N[(-0.0001984126984126984 * N[(N[Sin[re], $MachinePrecision] * N[Power[im$95$m, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 0.00078:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\

\mathbf{elif}\;im\_m \leq 10^{+39}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot -0.16666666666666666\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im\_m}^{7}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 7.79999999999999986e-4

    1. Initial program 57.8%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 61.7%

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

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

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

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

    if 7.79999999999999986e-4 < im < 9.9999999999999994e38

    1. Initial program 99.5%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 14.0%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in14.0%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+14.0%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative14.0%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative14.0%

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr2.2%

      \[\leadsto im \cdot \color{blue}{-0.16666666666666666} \]
    7. Step-by-step derivation
      1. log1p-expm1-u55.8%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -0.16666666666666666\right)\right)} \]
    8. Applied egg-rr55.8%

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

    if 9.9999999999999994e38 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 91.8%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in91.8%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+91.8%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative91.8%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative91.8%

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Taylor expanded in im around inf 96.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.00078:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 10^{+39}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im}^{7}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 71.8% accurate, 1.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 7.2 \cdot 10^{+239}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im\_m \leq 2.5 \cdot 10^{+253} \lor \neg \left(im\_m \leq 6.6 \cdot 10^{+273}\right):\\ \;\;\;\;\left(-im\_m\right) \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im\_m}^{3}\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 2.6e-15)
    (* (- im_m) (sin re))
    (if (<= im_m 7.2e+239)
      (log1p (expm1 (* im_m -0.16666666666666666)))
      (if (or (<= im_m 2.5e+253) (not (<= im_m 6.6e+273)))
        (* (- im_m) (+ re (* -0.16666666666666666 (pow re 3.0))))
        (* -0.16666666666666666 (* re (pow im_m 3.0))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 7.2e+239) {
		tmp = log1p(expm1((im_m * -0.16666666666666666)));
	} else if ((im_m <= 2.5e+253) || !(im_m <= 6.6e+273)) {
		tmp = -im_m * (re + (-0.16666666666666666 * pow(re, 3.0)));
	} else {
		tmp = -0.16666666666666666 * (re * pow(im_m, 3.0));
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 7.2e+239) {
		tmp = Math.log1p(Math.expm1((im_m * -0.16666666666666666)));
	} else if ((im_m <= 2.5e+253) || !(im_m <= 6.6e+273)) {
		tmp = -im_m * (re + (-0.16666666666666666 * Math.pow(re, 3.0)));
	} else {
		tmp = -0.16666666666666666 * (re * Math.pow(im_m, 3.0));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 2.6e-15:
		tmp = -im_m * math.sin(re)
	elif im_m <= 7.2e+239:
		tmp = math.log1p(math.expm1((im_m * -0.16666666666666666)))
	elif (im_m <= 2.5e+253) or not (im_m <= 6.6e+273):
		tmp = -im_m * (re + (-0.16666666666666666 * math.pow(re, 3.0)))
	else:
		tmp = -0.16666666666666666 * (re * math.pow(im_m, 3.0))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 2.6e-15)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 7.2e+239)
		tmp = log1p(expm1(Float64(im_m * -0.16666666666666666)));
	elseif ((im_m <= 2.5e+253) || !(im_m <= 6.6e+273))
		tmp = Float64(Float64(-im_m) * Float64(re + Float64(-0.16666666666666666 * (re ^ 3.0))));
	else
		tmp = Float64(-0.16666666666666666 * Float64(re * (im_m ^ 3.0)));
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 2.6e-15], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 7.2e+239], N[Log[1 + N[(Exp[N[(im$95$m * -0.16666666666666666), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[im$95$m, 2.5e+253], N[Not[LessEqual[im$95$m, 6.6e+273]], $MachinePrecision]], N[((-im$95$m) * N[(re + N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.16666666666666666 * N[(re * N[Power[im$95$m, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\

\mathbf{elif}\;im\_m \leq 7.2 \cdot 10^{+239}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot -0.16666666666666666\right)\right)\\

\mathbf{elif}\;im\_m \leq 2.5 \cdot 10^{+253} \lor \neg \left(im\_m \leq 6.6 \cdot 10^{+273}\right):\\
\;\;\;\;\left(-im\_m\right) \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < 2.60000000000000004e-15

    1. Initial program 57.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 61.5%

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

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

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

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

    if 2.60000000000000004e-15 < im < 7.2e239

    1. Initial program 98.6%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 77.1%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in77.1%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+77.1%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative77.1%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative77.1%

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr2.8%

      \[\leadsto im \cdot \color{blue}{-0.16666666666666666} \]
    7. Step-by-step derivation
      1. log1p-expm1-u53.8%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -0.16666666666666666\right)\right)} \]
    8. Applied egg-rr53.8%

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

    if 7.2e239 < im < 2.4999999999999998e253 or 6.59999999999999971e273 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 8.7%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    5. Simplified8.7%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr8.7%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin re\right)\right)} \]
    7. Taylor expanded in re around 0 86.5%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(re \cdot \left(1 + -0.16666666666666666 \cdot {re}^{2}\right)\right)} \]
    8. Step-by-step derivation
      1. distribute-rgt-in86.5%

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

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

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

        \[\leadsto \left(-im\right) \cdot \left(re + -0.16666666666666666 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot re\right)\right) \]
      5. unpow386.5%

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

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

    if 2.4999999999999998e253 < im < 6.59999999999999971e273

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + -0.16666666666666666 \cdot \left({im}^{2} \cdot \sin re\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative100.0%

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

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left(\sin re \cdot {im}^{2}\right)} - \sin re\right) \]
      5. associate-*r*100.0%

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

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left({im}^{2} \cdot \sin re\right)}\right) - im \cdot \sin re \]
      9. associate-*r*100.0%

        \[\leadsto im \cdot \color{blue}{\left(\left(-0.16666666666666666 \cdot {im}^{2}\right) \cdot \sin re\right)} - im \cdot \sin re \]
      10. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(im \cdot \left(-0.16666666666666666 \cdot {im}^{2}\right)\right) \cdot \sin re} - im \cdot \sin re \]
      11. distribute-rgt-out--100.0%

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

        \[\leadsto \sin re \cdot \left(im \cdot \color{blue}{\left({im}^{2} \cdot -0.16666666666666666\right)} - im\right) \]
      13. associate-*r*100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(im \cdot {im}^{2}\right) \cdot -0.16666666666666666} - im\right) \]
      14. unpow2100.0%

        \[\leadsto \sin re \cdot \left(\left(im \cdot \color{blue}{\left(im \cdot im\right)}\right) \cdot -0.16666666666666666 - im\right) \]
      15. cube-unmult100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 7.2 \cdot 10^{+239}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 2.5 \cdot 10^{+253} \lor \neg \left(im \leq 6.6 \cdot 10^{+273}\right):\\ \;\;\;\;\left(-im\right) \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 75.8% accurate, 2.1× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := -0.008333333333333333 \cdot \left(re \cdot {im\_m}^{5}\right)\\ t_1 := \left(-im\_m\right) \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 8.2 \cdot 10^{+26}:\\ \;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im\_m \leq 2.5 \cdot 10^{+208}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;im\_m \leq 6.5 \cdot 10^{+239}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 7.5 \cdot 10^{+252} \lor \neg \left(im\_m \leq 6.6 \cdot 10^{+273}\right):\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im\_m}^{3}\right)\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* -0.008333333333333333 (* re (pow im_m 5.0))))
        (t_1 (* (- im_m) (+ re (* -0.16666666666666666 (pow re 3.0))))))
   (*
    im_s
    (if (<= im_m 2.6e-15)
      (* (- im_m) (sin re))
      (if (<= im_m 8.2e+26)
        (* im_m (- (expm1 re)))
        (if (<= im_m 2.5e+208)
          t_0
          (if (<= im_m 1.58e+227)
            t_1
            (if (<= im_m 6.5e+239)
              t_0
              (if (or (<= im_m 7.5e+252) (not (<= im_m 6.6e+273)))
                t_1
                (* -0.16666666666666666 (* re (pow im_m 3.0))))))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = -0.008333333333333333 * (re * pow(im_m, 5.0));
	double t_1 = -im_m * (re + (-0.16666666666666666 * pow(re, 3.0)));
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 8.2e+26) {
		tmp = im_m * -expm1(re);
	} else if (im_m <= 2.5e+208) {
		tmp = t_0;
	} else if (im_m <= 1.58e+227) {
		tmp = t_1;
	} else if (im_m <= 6.5e+239) {
		tmp = t_0;
	} else if ((im_m <= 7.5e+252) || !(im_m <= 6.6e+273)) {
		tmp = t_1;
	} else {
		tmp = -0.16666666666666666 * (re * pow(im_m, 3.0));
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = -0.008333333333333333 * (re * Math.pow(im_m, 5.0));
	double t_1 = -im_m * (re + (-0.16666666666666666 * Math.pow(re, 3.0)));
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 8.2e+26) {
		tmp = im_m * -Math.expm1(re);
	} else if (im_m <= 2.5e+208) {
		tmp = t_0;
	} else if (im_m <= 1.58e+227) {
		tmp = t_1;
	} else if (im_m <= 6.5e+239) {
		tmp = t_0;
	} else if ((im_m <= 7.5e+252) || !(im_m <= 6.6e+273)) {
		tmp = t_1;
	} else {
		tmp = -0.16666666666666666 * (re * Math.pow(im_m, 3.0));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = -0.008333333333333333 * (re * math.pow(im_m, 5.0))
	t_1 = -im_m * (re + (-0.16666666666666666 * math.pow(re, 3.0)))
	tmp = 0
	if im_m <= 2.6e-15:
		tmp = -im_m * math.sin(re)
	elif im_m <= 8.2e+26:
		tmp = im_m * -math.expm1(re)
	elif im_m <= 2.5e+208:
		tmp = t_0
	elif im_m <= 1.58e+227:
		tmp = t_1
	elif im_m <= 6.5e+239:
		tmp = t_0
	elif (im_m <= 7.5e+252) or not (im_m <= 6.6e+273):
		tmp = t_1
	else:
		tmp = -0.16666666666666666 * (re * math.pow(im_m, 3.0))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(-0.008333333333333333 * Float64(re * (im_m ^ 5.0)))
	t_1 = Float64(Float64(-im_m) * Float64(re + Float64(-0.16666666666666666 * (re ^ 3.0))))
	tmp = 0.0
	if (im_m <= 2.6e-15)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 8.2e+26)
		tmp = Float64(im_m * Float64(-expm1(re)));
	elseif (im_m <= 2.5e+208)
		tmp = t_0;
	elseif (im_m <= 1.58e+227)
		tmp = t_1;
	elseif (im_m <= 6.5e+239)
		tmp = t_0;
	elseif ((im_m <= 7.5e+252) || !(im_m <= 6.6e+273))
		tmp = t_1;
	else
		tmp = Float64(-0.16666666666666666 * Float64(re * (im_m ^ 3.0)));
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(-0.008333333333333333 * N[(re * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-im$95$m) * N[(re + N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 2.6e-15], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 8.2e+26], N[(im$95$m * (-N[(Exp[re] - 1), $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 2.5e+208], t$95$0, If[LessEqual[im$95$m, 1.58e+227], t$95$1, If[LessEqual[im$95$m, 6.5e+239], t$95$0, If[Or[LessEqual[im$95$m, 7.5e+252], N[Not[LessEqual[im$95$m, 6.6e+273]], $MachinePrecision]], t$95$1, N[(-0.16666666666666666 * N[(re * N[Power[im$95$m, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]), $MachinePrecision]]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := -0.008333333333333333 \cdot \left(re \cdot {im\_m}^{5}\right)\\
t_1 := \left(-im\_m\right) \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\

\mathbf{elif}\;im\_m \leq 8.2 \cdot 10^{+26}:\\
\;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\

\mathbf{elif}\;im\_m \leq 2.5 \cdot 10^{+208}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;im\_m \leq 1.58 \cdot 10^{+227}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;im\_m \leq 6.5 \cdot 10^{+239}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;im\_m \leq 7.5 \cdot 10^{+252} \lor \neg \left(im\_m \leq 6.6 \cdot 10^{+273}\right):\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < 2.60000000000000004e-15

    1. Initial program 57.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 61.5%

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

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

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

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

    if 2.60000000000000004e-15 < im < 8.19999999999999967e26

    1. Initial program 89.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 21.3%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr21.3%

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

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

    if 8.19999999999999967e26 < im < 2.5000000000000002e208 or 1.57999999999999994e227 < im < 6.5e239

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 66.7%

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left(-0.16666666666666666 \cdot re + \color{blue}{\left(-0.008333333333333333 \cdot {im}^{2}\right) \cdot re}\right) - re\right) \]
      5. distribute-rgt-out50.9%

        \[\leadsto im \cdot \left({im}^{2} \cdot \color{blue}{\left(re \cdot \left(-0.16666666666666666 + -0.008333333333333333 \cdot {im}^{2}\right)\right)} - re\right) \]
      6. *-commutative50.9%

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

      \[\leadsto \color{blue}{im \cdot \left({im}^{2} \cdot \left(re \cdot \left(-0.16666666666666666 + {im}^{2} \cdot -0.008333333333333333\right)\right) - re\right)} \]
    9. Taylor expanded in im around inf 55.3%

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

    if 2.5000000000000002e208 < im < 1.57999999999999994e227 or 6.5e239 < im < 7.4999999999999995e252 or 6.59999999999999971e273 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 7.1%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    5. Simplified7.1%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr7.1%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin re\right)\right)} \]
    7. Taylor expanded in re around 0 76.1%

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

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

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

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

        \[\leadsto \left(-im\right) \cdot \left(re + -0.16666666666666666 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot re\right)\right) \]
      5. unpow376.1%

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

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

    if 7.4999999999999995e252 < im < 6.59999999999999971e273

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + -0.16666666666666666 \cdot \left({im}^{2} \cdot \sin re\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative100.0%

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

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left(\sin re \cdot {im}^{2}\right)} - \sin re\right) \]
      5. associate-*r*100.0%

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

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left({im}^{2} \cdot \sin re\right)}\right) - im \cdot \sin re \]
      9. associate-*r*100.0%

        \[\leadsto im \cdot \color{blue}{\left(\left(-0.16666666666666666 \cdot {im}^{2}\right) \cdot \sin re\right)} - im \cdot \sin re \]
      10. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(im \cdot \left(-0.16666666666666666 \cdot {im}^{2}\right)\right) \cdot \sin re} - im \cdot \sin re \]
      11. distribute-rgt-out--100.0%

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

        \[\leadsto \sin re \cdot \left(im \cdot \color{blue}{\left({im}^{2} \cdot -0.16666666666666666\right)} - im\right) \]
      13. associate-*r*100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(im \cdot {im}^{2}\right) \cdot -0.16666666666666666} - im\right) \]
      14. unpow2100.0%

        \[\leadsto \sin re \cdot \left(\left(im \cdot \color{blue}{\left(im \cdot im\right)}\right) \cdot -0.16666666666666666 - im\right) \]
      15. cube-unmult100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+26}:\\ \;\;\;\;im \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 2.5 \cdot 10^{+208}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;\left(-im\right) \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+239}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq 7.5 \cdot 10^{+252} \lor \neg \left(im \leq 6.6 \cdot 10^{+273}\right):\\ \;\;\;\;\left(-im\right) \cdot \left(re + -0.16666666666666666 \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 75.5% accurate, 2.2× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := -0.008333333333333333 \cdot \left(re \cdot {im\_m}^{5}\right)\\ t_1 := im\_m \cdot \left({re}^{3} \cdot 0.16666666666666666\right)\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 2.7 \cdot 10^{+26}:\\ \;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im\_m \leq 2 \cdot 10^{+208}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 1.65 \cdot 10^{+227}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;im\_m \leq 7.2 \cdot 10^{+239}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 9.6 \cdot 10^{+253} \lor \neg \left(im\_m \leq 6.6 \cdot 10^{+273}\right):\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im\_m}^{3}\right)\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* -0.008333333333333333 (* re (pow im_m 5.0))))
        (t_1 (* im_m (* (pow re 3.0) 0.16666666666666666))))
   (*
    im_s
    (if (<= im_m 2.6e-15)
      (* (- im_m) (sin re))
      (if (<= im_m 2.7e+26)
        (* im_m (- (expm1 re)))
        (if (<= im_m 2e+208)
          t_0
          (if (<= im_m 1.65e+227)
            t_1
            (if (<= im_m 7.2e+239)
              t_0
              (if (or (<= im_m 9.6e+253) (not (<= im_m 6.6e+273)))
                t_1
                (* -0.16666666666666666 (* re (pow im_m 3.0))))))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = -0.008333333333333333 * (re * pow(im_m, 5.0));
	double t_1 = im_m * (pow(re, 3.0) * 0.16666666666666666);
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 2.7e+26) {
		tmp = im_m * -expm1(re);
	} else if (im_m <= 2e+208) {
		tmp = t_0;
	} else if (im_m <= 1.65e+227) {
		tmp = t_1;
	} else if (im_m <= 7.2e+239) {
		tmp = t_0;
	} else if ((im_m <= 9.6e+253) || !(im_m <= 6.6e+273)) {
		tmp = t_1;
	} else {
		tmp = -0.16666666666666666 * (re * pow(im_m, 3.0));
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = -0.008333333333333333 * (re * Math.pow(im_m, 5.0));
	double t_1 = im_m * (Math.pow(re, 3.0) * 0.16666666666666666);
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 2.7e+26) {
		tmp = im_m * -Math.expm1(re);
	} else if (im_m <= 2e+208) {
		tmp = t_0;
	} else if (im_m <= 1.65e+227) {
		tmp = t_1;
	} else if (im_m <= 7.2e+239) {
		tmp = t_0;
	} else if ((im_m <= 9.6e+253) || !(im_m <= 6.6e+273)) {
		tmp = t_1;
	} else {
		tmp = -0.16666666666666666 * (re * Math.pow(im_m, 3.0));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = -0.008333333333333333 * (re * math.pow(im_m, 5.0))
	t_1 = im_m * (math.pow(re, 3.0) * 0.16666666666666666)
	tmp = 0
	if im_m <= 2.6e-15:
		tmp = -im_m * math.sin(re)
	elif im_m <= 2.7e+26:
		tmp = im_m * -math.expm1(re)
	elif im_m <= 2e+208:
		tmp = t_0
	elif im_m <= 1.65e+227:
		tmp = t_1
	elif im_m <= 7.2e+239:
		tmp = t_0
	elif (im_m <= 9.6e+253) or not (im_m <= 6.6e+273):
		tmp = t_1
	else:
		tmp = -0.16666666666666666 * (re * math.pow(im_m, 3.0))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(-0.008333333333333333 * Float64(re * (im_m ^ 5.0)))
	t_1 = Float64(im_m * Float64((re ^ 3.0) * 0.16666666666666666))
	tmp = 0.0
	if (im_m <= 2.6e-15)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 2.7e+26)
		tmp = Float64(im_m * Float64(-expm1(re)));
	elseif (im_m <= 2e+208)
		tmp = t_0;
	elseif (im_m <= 1.65e+227)
		tmp = t_1;
	elseif (im_m <= 7.2e+239)
		tmp = t_0;
	elseif ((im_m <= 9.6e+253) || !(im_m <= 6.6e+273))
		tmp = t_1;
	else
		tmp = Float64(-0.16666666666666666 * Float64(re * (im_m ^ 3.0)));
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(-0.008333333333333333 * N[(re * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(im$95$m * N[(N[Power[re, 3.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 2.6e-15], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 2.7e+26], N[(im$95$m * (-N[(Exp[re] - 1), $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 2e+208], t$95$0, If[LessEqual[im$95$m, 1.65e+227], t$95$1, If[LessEqual[im$95$m, 7.2e+239], t$95$0, If[Or[LessEqual[im$95$m, 9.6e+253], N[Not[LessEqual[im$95$m, 6.6e+273]], $MachinePrecision]], t$95$1, N[(-0.16666666666666666 * N[(re * N[Power[im$95$m, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]), $MachinePrecision]]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := -0.008333333333333333 \cdot \left(re \cdot {im\_m}^{5}\right)\\
t_1 := im\_m \cdot \left({re}^{3} \cdot 0.16666666666666666\right)\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\

\mathbf{elif}\;im\_m \leq 2.7 \cdot 10^{+26}:\\
\;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\

\mathbf{elif}\;im\_m \leq 2 \cdot 10^{+208}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;im\_m \leq 1.65 \cdot 10^{+227}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;im\_m \leq 7.2 \cdot 10^{+239}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;im\_m \leq 9.6 \cdot 10^{+253} \lor \neg \left(im\_m \leq 6.6 \cdot 10^{+273}\right):\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < 2.60000000000000004e-15

    1. Initial program 57.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 61.5%

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

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

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

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

    if 2.60000000000000004e-15 < im < 2.7e26

    1. Initial program 89.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 21.3%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr21.3%

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

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

    if 2.7e26 < im < 2e208 or 1.6499999999999999e227 < im < 7.2e239

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 66.7%

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left(-0.16666666666666666 \cdot re + \color{blue}{\left(-0.008333333333333333 \cdot {im}^{2}\right) \cdot re}\right) - re\right) \]
      5. distribute-rgt-out50.9%

        \[\leadsto im \cdot \left({im}^{2} \cdot \color{blue}{\left(re \cdot \left(-0.16666666666666666 + -0.008333333333333333 \cdot {im}^{2}\right)\right)} - re\right) \]
      6. *-commutative50.9%

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

      \[\leadsto \color{blue}{im \cdot \left({im}^{2} \cdot \left(re \cdot \left(-0.16666666666666666 + {im}^{2} \cdot -0.008333333333333333\right)\right) - re\right)} \]
    9. Taylor expanded in im around inf 55.3%

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

    if 2e208 < im < 1.6499999999999999e227 or 7.2e239 < im < 9.59999999999999965e253 or 6.59999999999999971e273 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 7.1%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    5. Simplified7.1%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr7.1%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin re\right)\right)} \]
    7. Taylor expanded in re around 0 76.1%

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

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

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

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

        \[\leadsto \left(-im\right) \cdot \left(re + -0.16666666666666666 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot re\right)\right) \]
      5. unpow376.1%

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

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

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

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

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

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

    if 9.59999999999999965e253 < im < 6.59999999999999971e273

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + -0.16666666666666666 \cdot \left({im}^{2} \cdot \sin re\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative100.0%

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

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left(\sin re \cdot {im}^{2}\right)} - \sin re\right) \]
      5. associate-*r*100.0%

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

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left({im}^{2} \cdot \sin re\right)}\right) - im \cdot \sin re \]
      9. associate-*r*100.0%

        \[\leadsto im \cdot \color{blue}{\left(\left(-0.16666666666666666 \cdot {im}^{2}\right) \cdot \sin re\right)} - im \cdot \sin re \]
      10. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(im \cdot \left(-0.16666666666666666 \cdot {im}^{2}\right)\right) \cdot \sin re} - im \cdot \sin re \]
      11. distribute-rgt-out--100.0%

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

        \[\leadsto \sin re \cdot \left(im \cdot \color{blue}{\left({im}^{2} \cdot -0.16666666666666666\right)} - im\right) \]
      13. associate-*r*100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(im \cdot {im}^{2}\right) \cdot -0.16666666666666666} - im\right) \]
      14. unpow2100.0%

        \[\leadsto \sin re \cdot \left(\left(im \cdot \color{blue}{\left(im \cdot im\right)}\right) \cdot -0.16666666666666666 - im\right) \]
      15. cube-unmult100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+26}:\\ \;\;\;\;im \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+208}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq 1.65 \cdot 10^{+227}:\\ \;\;\;\;im \cdot \left({re}^{3} \cdot 0.16666666666666666\right)\\ \mathbf{elif}\;im \leq 7.2 \cdot 10^{+239}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq 9.6 \cdot 10^{+253} \lor \neg \left(im \leq 6.6 \cdot 10^{+273}\right):\\ \;\;\;\;im \cdot \left({re}^{3} \cdot 0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 75.7% accurate, 2.2× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := -0.008333333333333333 \cdot \left(re \cdot {im\_m}^{5}\right)\\ t_1 := \left|im\_m \cdot \left(-4 - re\right)\right|\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 8.5 \cdot 10^{+25}:\\ \;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im\_m \leq 2.7 \cdot 10^{+208}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;im\_m \leq 7.2 \cdot 10^{+239}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 6.5 \cdot 10^{+252} \lor \neg \left(im\_m \leq 6.6 \cdot 10^{+273}\right):\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im\_m}^{3}\right)\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* -0.008333333333333333 (* re (pow im_m 5.0))))
        (t_1 (fabs (* im_m (- -4.0 re)))))
   (*
    im_s
    (if (<= im_m 2.6e-15)
      (* (- im_m) (sin re))
      (if (<= im_m 8.5e+25)
        (* im_m (- (expm1 re)))
        (if (<= im_m 2.7e+208)
          t_0
          (if (<= im_m 1.58e+227)
            t_1
            (if (<= im_m 7.2e+239)
              t_0
              (if (or (<= im_m 6.5e+252) (not (<= im_m 6.6e+273)))
                t_1
                (* -0.16666666666666666 (* re (pow im_m 3.0))))))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = -0.008333333333333333 * (re * pow(im_m, 5.0));
	double t_1 = fabs((im_m * (-4.0 - re)));
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 8.5e+25) {
		tmp = im_m * -expm1(re);
	} else if (im_m <= 2.7e+208) {
		tmp = t_0;
	} else if (im_m <= 1.58e+227) {
		tmp = t_1;
	} else if (im_m <= 7.2e+239) {
		tmp = t_0;
	} else if ((im_m <= 6.5e+252) || !(im_m <= 6.6e+273)) {
		tmp = t_1;
	} else {
		tmp = -0.16666666666666666 * (re * pow(im_m, 3.0));
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = -0.008333333333333333 * (re * Math.pow(im_m, 5.0));
	double t_1 = Math.abs((im_m * (-4.0 - re)));
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 8.5e+25) {
		tmp = im_m * -Math.expm1(re);
	} else if (im_m <= 2.7e+208) {
		tmp = t_0;
	} else if (im_m <= 1.58e+227) {
		tmp = t_1;
	} else if (im_m <= 7.2e+239) {
		tmp = t_0;
	} else if ((im_m <= 6.5e+252) || !(im_m <= 6.6e+273)) {
		tmp = t_1;
	} else {
		tmp = -0.16666666666666666 * (re * Math.pow(im_m, 3.0));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = -0.008333333333333333 * (re * math.pow(im_m, 5.0))
	t_1 = math.fabs((im_m * (-4.0 - re)))
	tmp = 0
	if im_m <= 2.6e-15:
		tmp = -im_m * math.sin(re)
	elif im_m <= 8.5e+25:
		tmp = im_m * -math.expm1(re)
	elif im_m <= 2.7e+208:
		tmp = t_0
	elif im_m <= 1.58e+227:
		tmp = t_1
	elif im_m <= 7.2e+239:
		tmp = t_0
	elif (im_m <= 6.5e+252) or not (im_m <= 6.6e+273):
		tmp = t_1
	else:
		tmp = -0.16666666666666666 * (re * math.pow(im_m, 3.0))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(-0.008333333333333333 * Float64(re * (im_m ^ 5.0)))
	t_1 = abs(Float64(im_m * Float64(-4.0 - re)))
	tmp = 0.0
	if (im_m <= 2.6e-15)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 8.5e+25)
		tmp = Float64(im_m * Float64(-expm1(re)));
	elseif (im_m <= 2.7e+208)
		tmp = t_0;
	elseif (im_m <= 1.58e+227)
		tmp = t_1;
	elseif (im_m <= 7.2e+239)
		tmp = t_0;
	elseif ((im_m <= 6.5e+252) || !(im_m <= 6.6e+273))
		tmp = t_1;
	else
		tmp = Float64(-0.16666666666666666 * Float64(re * (im_m ^ 3.0)));
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(-0.008333333333333333 * N[(re * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(im$95$m * N[(-4.0 - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 2.6e-15], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 8.5e+25], N[(im$95$m * (-N[(Exp[re] - 1), $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 2.7e+208], t$95$0, If[LessEqual[im$95$m, 1.58e+227], t$95$1, If[LessEqual[im$95$m, 7.2e+239], t$95$0, If[Or[LessEqual[im$95$m, 6.5e+252], N[Not[LessEqual[im$95$m, 6.6e+273]], $MachinePrecision]], t$95$1, N[(-0.16666666666666666 * N[(re * N[Power[im$95$m, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]), $MachinePrecision]]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := -0.008333333333333333 \cdot \left(re \cdot {im\_m}^{5}\right)\\
t_1 := \left|im\_m \cdot \left(-4 - re\right)\right|\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\

\mathbf{elif}\;im\_m \leq 8.5 \cdot 10^{+25}:\\
\;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\

\mathbf{elif}\;im\_m \leq 2.7 \cdot 10^{+208}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;im\_m \leq 1.58 \cdot 10^{+227}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;im\_m \leq 7.2 \cdot 10^{+239}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;im\_m \leq 6.5 \cdot 10^{+252} \lor \neg \left(im\_m \leq 6.6 \cdot 10^{+273}\right):\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < 2.60000000000000004e-15

    1. Initial program 57.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 61.5%

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

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

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

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

    if 2.60000000000000004e-15 < im < 8.5000000000000007e25

    1. Initial program 89.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 21.3%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr21.3%

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

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

    if 8.5000000000000007e25 < im < 2.7e208 or 1.57999999999999994e227 < im < 7.2e239

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 66.7%

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left(-0.16666666666666666 \cdot re + \color{blue}{\left(-0.008333333333333333 \cdot {im}^{2}\right) \cdot re}\right) - re\right) \]
      5. distribute-rgt-out50.9%

        \[\leadsto im \cdot \left({im}^{2} \cdot \color{blue}{\left(re \cdot \left(-0.16666666666666666 + -0.008333333333333333 \cdot {im}^{2}\right)\right)} - re\right) \]
      6. *-commutative50.9%

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

      \[\leadsto \color{blue}{im \cdot \left({im}^{2} \cdot \left(re \cdot \left(-0.16666666666666666 + {im}^{2} \cdot -0.008333333333333333\right)\right) - re\right)} \]
    9. Taylor expanded in im around inf 55.3%

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

    if 2.7e208 < im < 1.57999999999999994e227 or 7.2e239 < im < 6.5e252 or 6.59999999999999971e273 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 7.1%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    5. Simplified7.1%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr4.7%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sin re\right)} - -3\right)} \]
    7. Step-by-step derivation
      1. log1p-undefine4.7%

        \[\leadsto \left(-im\right) \cdot \left(e^{\color{blue}{\log \left(1 + \sin re\right)}} - -3\right) \]
      2. rem-exp-log4.7%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(1 + \sin re\right)} - -3\right) \]
      3. +-commutative4.7%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(\sin re + 1\right)} - -3\right) \]
      4. associate--l+4.7%

        \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + \left(1 - -3\right)\right)} \]
      5. metadata-eval4.7%

        \[\leadsto \left(-im\right) \cdot \left(\sin re + \color{blue}{4}\right) \]
    8. Simplified4.7%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + 4\right)} \]
    9. Taylor expanded in re around 0 1.1%

      \[\leadsto \color{blue}{-4 \cdot im + -1 \cdot \left(im \cdot re\right)} \]
    10. Step-by-step derivation
      1. *-commutative1.1%

        \[\leadsto \color{blue}{im \cdot -4} + -1 \cdot \left(im \cdot re\right) \]
      2. mul-1-neg1.1%

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

        \[\leadsto im \cdot -4 + \color{blue}{im \cdot \left(-re\right)} \]
      4. distribute-lft-out1.1%

        \[\leadsto \color{blue}{im \cdot \left(-4 + \left(-re\right)\right)} \]
      5. unsub-neg1.1%

        \[\leadsto im \cdot \color{blue}{\left(-4 - re\right)} \]
    11. Simplified1.1%

      \[\leadsto \color{blue}{im \cdot \left(-4 - re\right)} \]
    12. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \color{blue}{\sqrt{im \cdot \left(-4 - re\right)} \cdot \sqrt{im \cdot \left(-4 - re\right)}} \]
      2. sqrt-unprod41.7%

        \[\leadsto \color{blue}{\sqrt{\left(im \cdot \left(-4 - re\right)\right) \cdot \left(im \cdot \left(-4 - re\right)\right)}} \]
      3. pow241.7%

        \[\leadsto \sqrt{\color{blue}{{\left(im \cdot \left(-4 - re\right)\right)}^{2}}} \]
    13. Applied egg-rr41.7%

      \[\leadsto \color{blue}{\sqrt{{\left(im \cdot \left(-4 - re\right)\right)}^{2}}} \]
    14. Step-by-step derivation
      1. unpow241.7%

        \[\leadsto \sqrt{\color{blue}{\left(im \cdot \left(-4 - re\right)\right) \cdot \left(im \cdot \left(-4 - re\right)\right)}} \]
      2. rem-sqrt-square33.8%

        \[\leadsto \color{blue}{\left|im \cdot \left(-4 - re\right)\right|} \]
    15. Simplified33.8%

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

    if 6.5e252 < im < 6.59999999999999971e273

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + -0.16666666666666666 \cdot \left({im}^{2} \cdot \sin re\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative100.0%

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

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left(\sin re \cdot {im}^{2}\right)} - \sin re\right) \]
      5. associate-*r*100.0%

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

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left({im}^{2} \cdot \sin re\right)}\right) - im \cdot \sin re \]
      9. associate-*r*100.0%

        \[\leadsto im \cdot \color{blue}{\left(\left(-0.16666666666666666 \cdot {im}^{2}\right) \cdot \sin re\right)} - im \cdot \sin re \]
      10. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(im \cdot \left(-0.16666666666666666 \cdot {im}^{2}\right)\right) \cdot \sin re} - im \cdot \sin re \]
      11. distribute-rgt-out--100.0%

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

        \[\leadsto \sin re \cdot \left(im \cdot \color{blue}{\left({im}^{2} \cdot -0.16666666666666666\right)} - im\right) \]
      13. associate-*r*100.0%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(im \cdot {im}^{2}\right) \cdot -0.16666666666666666} - im\right) \]
      14. unpow2100.0%

        \[\leadsto \sin re \cdot \left(\left(im \cdot \color{blue}{\left(im \cdot im\right)}\right) \cdot -0.16666666666666666 - im\right) \]
      15. cube-unmult100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 8.5 \cdot 10^{+25}:\\ \;\;\;\;im \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+208}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;\left|im \cdot \left(-4 - re\right)\right|\\ \mathbf{elif}\;im \leq 7.2 \cdot 10^{+239}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(re \cdot {im}^{5}\right)\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+252} \lor \neg \left(im \leq 6.6 \cdot 10^{+273}\right):\\ \;\;\;\;\left|im \cdot \left(-4 - re\right)\right|\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 71.0% accurate, 2.2× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := -0.16666666666666666 \cdot \left(re \cdot {im\_m}^{3}\right)\\ t_1 := \left|im\_m \cdot \left(-4 - re\right)\right|\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 8.2 \cdot 10^{+26}:\\ \;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im\_m \leq 2.7 \cdot 10^{+208}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;im\_m \leq 6.4 \cdot 10^{+239}:\\ \;\;\;\;re \cdot \left(im\_m \cdot \frac{-4}{re} - im\_m\right)\\ \mathbf{elif}\;im\_m \leq 6.5 \cdot 10^{+252} \lor \neg \left(im\_m \leq 8.5 \cdot 10^{+272}\right):\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* -0.16666666666666666 (* re (pow im_m 3.0))))
        (t_1 (fabs (* im_m (- -4.0 re)))))
   (*
    im_s
    (if (<= im_m 2.6e-15)
      (* (- im_m) (sin re))
      (if (<= im_m 8.2e+26)
        (* im_m (- (expm1 re)))
        (if (<= im_m 2.7e+208)
          t_0
          (if (<= im_m 1.58e+227)
            t_1
            (if (<= im_m 6.4e+239)
              (* re (- (* im_m (/ -4.0 re)) im_m))
              (if (or (<= im_m 6.5e+252) (not (<= im_m 8.5e+272)))
                t_1
                t_0)))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = -0.16666666666666666 * (re * pow(im_m, 3.0));
	double t_1 = fabs((im_m * (-4.0 - re)));
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 8.2e+26) {
		tmp = im_m * -expm1(re);
	} else if (im_m <= 2.7e+208) {
		tmp = t_0;
	} else if (im_m <= 1.58e+227) {
		tmp = t_1;
	} else if (im_m <= 6.4e+239) {
		tmp = re * ((im_m * (-4.0 / re)) - im_m);
	} else if ((im_m <= 6.5e+252) || !(im_m <= 8.5e+272)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = -0.16666666666666666 * (re * Math.pow(im_m, 3.0));
	double t_1 = Math.abs((im_m * (-4.0 - re)));
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 8.2e+26) {
		tmp = im_m * -Math.expm1(re);
	} else if (im_m <= 2.7e+208) {
		tmp = t_0;
	} else if (im_m <= 1.58e+227) {
		tmp = t_1;
	} else if (im_m <= 6.4e+239) {
		tmp = re * ((im_m * (-4.0 / re)) - im_m);
	} else if ((im_m <= 6.5e+252) || !(im_m <= 8.5e+272)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = -0.16666666666666666 * (re * math.pow(im_m, 3.0))
	t_1 = math.fabs((im_m * (-4.0 - re)))
	tmp = 0
	if im_m <= 2.6e-15:
		tmp = -im_m * math.sin(re)
	elif im_m <= 8.2e+26:
		tmp = im_m * -math.expm1(re)
	elif im_m <= 2.7e+208:
		tmp = t_0
	elif im_m <= 1.58e+227:
		tmp = t_1
	elif im_m <= 6.4e+239:
		tmp = re * ((im_m * (-4.0 / re)) - im_m)
	elif (im_m <= 6.5e+252) or not (im_m <= 8.5e+272):
		tmp = t_1
	else:
		tmp = t_0
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(-0.16666666666666666 * Float64(re * (im_m ^ 3.0)))
	t_1 = abs(Float64(im_m * Float64(-4.0 - re)))
	tmp = 0.0
	if (im_m <= 2.6e-15)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 8.2e+26)
		tmp = Float64(im_m * Float64(-expm1(re)));
	elseif (im_m <= 2.7e+208)
		tmp = t_0;
	elseif (im_m <= 1.58e+227)
		tmp = t_1;
	elseif (im_m <= 6.4e+239)
		tmp = Float64(re * Float64(Float64(im_m * Float64(-4.0 / re)) - im_m));
	elseif ((im_m <= 6.5e+252) || !(im_m <= 8.5e+272))
		tmp = t_1;
	else
		tmp = t_0;
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(-0.16666666666666666 * N[(re * N[Power[im$95$m, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(im$95$m * N[(-4.0 - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 2.6e-15], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 8.2e+26], N[(im$95$m * (-N[(Exp[re] - 1), $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 2.7e+208], t$95$0, If[LessEqual[im$95$m, 1.58e+227], t$95$1, If[LessEqual[im$95$m, 6.4e+239], N[(re * N[(N[(im$95$m * N[(-4.0 / re), $MachinePrecision]), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im$95$m, 6.5e+252], N[Not[LessEqual[im$95$m, 8.5e+272]], $MachinePrecision]], t$95$1, t$95$0]]]]]]), $MachinePrecision]]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := -0.16666666666666666 \cdot \left(re \cdot {im\_m}^{3}\right)\\
t_1 := \left|im\_m \cdot \left(-4 - re\right)\right|\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\

\mathbf{elif}\;im\_m \leq 8.2 \cdot 10^{+26}:\\
\;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\

\mathbf{elif}\;im\_m \leq 2.7 \cdot 10^{+208}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;im\_m \leq 1.58 \cdot 10^{+227}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;im\_m \leq 6.4 \cdot 10^{+239}:\\
\;\;\;\;re \cdot \left(im\_m \cdot \frac{-4}{re} - im\_m\right)\\

\mathbf{elif}\;im\_m \leq 6.5 \cdot 10^{+252} \lor \neg \left(im\_m \leq 8.5 \cdot 10^{+272}\right):\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < 2.60000000000000004e-15

    1. Initial program 57.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 61.5%

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

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

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

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

    if 2.60000000000000004e-15 < im < 8.19999999999999967e26

    1. Initial program 89.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 21.3%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr21.3%

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

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

    if 8.19999999999999967e26 < im < 2.7e208 or 6.5e252 < im < 8.49999999999999996e272

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 63.2%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + -0.16666666666666666 \cdot \left({im}^{2} \cdot \sin re\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative63.2%

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

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left(\sin re \cdot {im}^{2}\right)} - \sin re\right) \]
      5. associate-*r*63.2%

        \[\leadsto im \cdot \left(\color{blue}{\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}} - \sin re\right) \]
      6. distribute-lft-out--63.2%

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

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

        \[\leadsto im \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left({im}^{2} \cdot \sin re\right)}\right) - im \cdot \sin re \]
      9. associate-*r*63.2%

        \[\leadsto im \cdot \color{blue}{\left(\left(-0.16666666666666666 \cdot {im}^{2}\right) \cdot \sin re\right)} - im \cdot \sin re \]
      10. associate-*r*69.6%

        \[\leadsto \color{blue}{\left(im \cdot \left(-0.16666666666666666 \cdot {im}^{2}\right)\right) \cdot \sin re} - im \cdot \sin re \]
      11. distribute-rgt-out--69.6%

        \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(-0.16666666666666666 \cdot {im}^{2}\right) - im\right)} \]
      12. *-commutative69.6%

        \[\leadsto \sin re \cdot \left(im \cdot \color{blue}{\left({im}^{2} \cdot -0.16666666666666666\right)} - im\right) \]
      13. associate-*r*69.6%

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(im \cdot {im}^{2}\right) \cdot -0.16666666666666666} - im\right) \]
      14. unpow269.6%

        \[\leadsto \sin re \cdot \left(\left(im \cdot \color{blue}{\left(im \cdot im\right)}\right) \cdot -0.16666666666666666 - im\right) \]
      15. cube-unmult69.6%

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

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

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

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

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

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

    if 2.7e208 < im < 1.57999999999999994e227 or 6.4000000000000003e239 < im < 6.5e252 or 8.49999999999999996e272 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 7.1%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    5. Simplified7.1%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr4.7%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sin re\right)} - -3\right)} \]
    7. Step-by-step derivation
      1. log1p-undefine4.7%

        \[\leadsto \left(-im\right) \cdot \left(e^{\color{blue}{\log \left(1 + \sin re\right)}} - -3\right) \]
      2. rem-exp-log4.7%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(1 + \sin re\right)} - -3\right) \]
      3. +-commutative4.7%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(\sin re + 1\right)} - -3\right) \]
      4. associate--l+4.7%

        \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + \left(1 - -3\right)\right)} \]
      5. metadata-eval4.7%

        \[\leadsto \left(-im\right) \cdot \left(\sin re + \color{blue}{4}\right) \]
    8. Simplified4.7%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + 4\right)} \]
    9. Taylor expanded in re around 0 1.1%

      \[\leadsto \color{blue}{-4 \cdot im + -1 \cdot \left(im \cdot re\right)} \]
    10. Step-by-step derivation
      1. *-commutative1.1%

        \[\leadsto \color{blue}{im \cdot -4} + -1 \cdot \left(im \cdot re\right) \]
      2. mul-1-neg1.1%

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

        \[\leadsto im \cdot -4 + \color{blue}{im \cdot \left(-re\right)} \]
      4. distribute-lft-out1.1%

        \[\leadsto \color{blue}{im \cdot \left(-4 + \left(-re\right)\right)} \]
      5. unsub-neg1.1%

        \[\leadsto im \cdot \color{blue}{\left(-4 - re\right)} \]
    11. Simplified1.1%

      \[\leadsto \color{blue}{im \cdot \left(-4 - re\right)} \]
    12. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \color{blue}{\sqrt{im \cdot \left(-4 - re\right)} \cdot \sqrt{im \cdot \left(-4 - re\right)}} \]
      2. sqrt-unprod41.7%

        \[\leadsto \color{blue}{\sqrt{\left(im \cdot \left(-4 - re\right)\right) \cdot \left(im \cdot \left(-4 - re\right)\right)}} \]
      3. pow241.7%

        \[\leadsto \sqrt{\color{blue}{{\left(im \cdot \left(-4 - re\right)\right)}^{2}}} \]
    13. Applied egg-rr41.7%

      \[\leadsto \color{blue}{\sqrt{{\left(im \cdot \left(-4 - re\right)\right)}^{2}}} \]
    14. Step-by-step derivation
      1. unpow241.7%

        \[\leadsto \sqrt{\color{blue}{\left(im \cdot \left(-4 - re\right)\right) \cdot \left(im \cdot \left(-4 - re\right)\right)}} \]
      2. rem-sqrt-square33.8%

        \[\leadsto \color{blue}{\left|im \cdot \left(-4 - re\right)\right|} \]
    15. Simplified33.8%

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

    if 1.57999999999999994e227 < im < 6.4000000000000003e239

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 4.2%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr4.7%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sin re\right)} - -3\right)} \]
    7. Step-by-step derivation
      1. log1p-undefine4.7%

        \[\leadsto \left(-im\right) \cdot \left(e^{\color{blue}{\log \left(1 + \sin re\right)}} - -3\right) \]
      2. rem-exp-log4.7%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(1 + \sin re\right)} - -3\right) \]
      3. +-commutative4.7%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(\sin re + 1\right)} - -3\right) \]
      4. associate--l+4.7%

        \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + \left(1 - -3\right)\right)} \]
      5. metadata-eval4.7%

        \[\leadsto \left(-im\right) \cdot \left(\sin re + \color{blue}{4}\right) \]
    8. Simplified4.7%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + 4\right)} \]
    9. Taylor expanded in re around 0 29.7%

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

        \[\leadsto \color{blue}{im \cdot -4} + -1 \cdot \left(im \cdot re\right) \]
      2. mul-1-neg29.7%

        \[\leadsto im \cdot -4 + \color{blue}{\left(-im \cdot re\right)} \]
      3. distribute-rgt-neg-out29.7%

        \[\leadsto im \cdot -4 + \color{blue}{im \cdot \left(-re\right)} \]
      4. distribute-lft-out29.7%

        \[\leadsto \color{blue}{im \cdot \left(-4 + \left(-re\right)\right)} \]
      5. unsub-neg29.7%

        \[\leadsto im \cdot \color{blue}{\left(-4 - re\right)} \]
    11. Simplified29.7%

      \[\leadsto \color{blue}{im \cdot \left(-4 - re\right)} \]
    12. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{re \cdot \left(-4 \cdot \frac{im}{re} + -1 \cdot im\right)} \]
    13. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto re \cdot \left(-4 \cdot \frac{im}{re} + \color{blue}{\left(-im\right)}\right) \]
      2. unsub-neg100.0%

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

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

        \[\leadsto re \cdot \left(\frac{\color{blue}{im \cdot -4}}{re} - im\right) \]
      5. associate-/l*100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+26}:\\ \;\;\;\;im \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+208}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \mathbf{elif}\;im \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;\left|im \cdot \left(-4 - re\right)\right|\\ \mathbf{elif}\;im \leq 6.4 \cdot 10^{+239}:\\ \;\;\;\;re \cdot \left(im \cdot \frac{-4}{re} - im\right)\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+252} \lor \neg \left(im \leq 8.5 \cdot 10^{+272}\right):\\ \;\;\;\;\left|im \cdot \left(-4 - re\right)\right|\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot \left(re \cdot {im}^{3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 60.8% accurate, 2.2× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 8.2 \cdot 10^{+26}:\\ \;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im\_m \leq 2.7 \cdot 10^{+208} \lor \neg \left(im\_m \leq 1.58 \cdot 10^{+227}\right) \land \left(im\_m \leq 7.2 \cdot 10^{+239} \lor \neg \left(im\_m \leq 6.5 \cdot 10^{+252}\right) \land im\_m \leq 3.9 \cdot 10^{+273}\right):\\ \;\;\;\;re \cdot \left(im\_m \cdot \frac{-4}{re} - im\_m\right)\\ \mathbf{else}:\\ \;\;\;\;\left|im\_m \cdot \left(-4 - re\right)\right|\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 2.6e-15)
    (* (- im_m) (sin re))
    (if (<= im_m 8.2e+26)
      (* im_m (- (expm1 re)))
      (if (or (<= im_m 2.7e+208)
              (and (not (<= im_m 1.58e+227))
                   (or (<= im_m 7.2e+239)
                       (and (not (<= im_m 6.5e+252)) (<= im_m 3.9e+273)))))
        (* re (- (* im_m (/ -4.0 re)) im_m))
        (fabs (* im_m (- -4.0 re))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 8.2e+26) {
		tmp = im_m * -expm1(re);
	} else if ((im_m <= 2.7e+208) || (!(im_m <= 1.58e+227) && ((im_m <= 7.2e+239) || (!(im_m <= 6.5e+252) && (im_m <= 3.9e+273))))) {
		tmp = re * ((im_m * (-4.0 / re)) - im_m);
	} else {
		tmp = fabs((im_m * (-4.0 - re)));
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 8.2e+26) {
		tmp = im_m * -Math.expm1(re);
	} else if ((im_m <= 2.7e+208) || (!(im_m <= 1.58e+227) && ((im_m <= 7.2e+239) || (!(im_m <= 6.5e+252) && (im_m <= 3.9e+273))))) {
		tmp = re * ((im_m * (-4.0 / re)) - im_m);
	} else {
		tmp = Math.abs((im_m * (-4.0 - re)));
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 2.6e-15:
		tmp = -im_m * math.sin(re)
	elif im_m <= 8.2e+26:
		tmp = im_m * -math.expm1(re)
	elif (im_m <= 2.7e+208) or (not (im_m <= 1.58e+227) and ((im_m <= 7.2e+239) or (not (im_m <= 6.5e+252) and (im_m <= 3.9e+273)))):
		tmp = re * ((im_m * (-4.0 / re)) - im_m)
	else:
		tmp = math.fabs((im_m * (-4.0 - re)))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 2.6e-15)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 8.2e+26)
		tmp = Float64(im_m * Float64(-expm1(re)));
	elseif ((im_m <= 2.7e+208) || (!(im_m <= 1.58e+227) && ((im_m <= 7.2e+239) || (!(im_m <= 6.5e+252) && (im_m <= 3.9e+273)))))
		tmp = Float64(re * Float64(Float64(im_m * Float64(-4.0 / re)) - im_m));
	else
		tmp = abs(Float64(im_m * Float64(-4.0 - re)));
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 2.6e-15], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 8.2e+26], N[(im$95$m * (-N[(Exp[re] - 1), $MachinePrecision])), $MachinePrecision], If[Or[LessEqual[im$95$m, 2.7e+208], And[N[Not[LessEqual[im$95$m, 1.58e+227]], $MachinePrecision], Or[LessEqual[im$95$m, 7.2e+239], And[N[Not[LessEqual[im$95$m, 6.5e+252]], $MachinePrecision], LessEqual[im$95$m, 3.9e+273]]]]], N[(re * N[(N[(im$95$m * N[(-4.0 / re), $MachinePrecision]), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision], N[Abs[N[(im$95$m * N[(-4.0 - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\

\mathbf{elif}\;im\_m \leq 8.2 \cdot 10^{+26}:\\
\;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\

\mathbf{elif}\;im\_m \leq 2.7 \cdot 10^{+208} \lor \neg \left(im\_m \leq 1.58 \cdot 10^{+227}\right) \land \left(im\_m \leq 7.2 \cdot 10^{+239} \lor \neg \left(im\_m \leq 6.5 \cdot 10^{+252}\right) \land im\_m \leq 3.9 \cdot 10^{+273}\right):\\
\;\;\;\;re \cdot \left(im\_m \cdot \frac{-4}{re} - im\_m\right)\\

\mathbf{else}:\\
\;\;\;\;\left|im\_m \cdot \left(-4 - re\right)\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if im < 2.60000000000000004e-15

    1. Initial program 57.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 61.5%

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

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

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

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

    if 2.60000000000000004e-15 < im < 8.19999999999999967e26

    1. Initial program 89.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 21.3%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr21.3%

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

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

    if 8.19999999999999967e26 < im < 2.7e208 or 1.57999999999999994e227 < im < 7.2e239 or 6.5e252 < im < 3.9000000000000001e273

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 3.9%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr3.1%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sin re\right)} - -3\right)} \]
    7. Step-by-step derivation
      1. log1p-undefine3.1%

        \[\leadsto \left(-im\right) \cdot \left(e^{\color{blue}{\log \left(1 + \sin re\right)}} - -3\right) \]
      2. rem-exp-log3.1%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(1 + \sin re\right)} - -3\right) \]
      3. +-commutative3.1%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(\sin re + 1\right)} - -3\right) \]
      4. associate--l+3.1%

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

        \[\leadsto \left(-im\right) \cdot \left(\sin re + \color{blue}{4}\right) \]
    8. Simplified3.1%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + 4\right)} \]
    9. Taylor expanded in re around 0 12.9%

      \[\leadsto \color{blue}{-4 \cdot im + -1 \cdot \left(im \cdot re\right)} \]
    10. Step-by-step derivation
      1. *-commutative12.9%

        \[\leadsto \color{blue}{im \cdot -4} + -1 \cdot \left(im \cdot re\right) \]
      2. mul-1-neg12.9%

        \[\leadsto im \cdot -4 + \color{blue}{\left(-im \cdot re\right)} \]
      3. distribute-rgt-neg-out12.9%

        \[\leadsto im \cdot -4 + \color{blue}{im \cdot \left(-re\right)} \]
      4. distribute-lft-out12.9%

        \[\leadsto \color{blue}{im \cdot \left(-4 + \left(-re\right)\right)} \]
      5. unsub-neg12.9%

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

      \[\leadsto \color{blue}{im \cdot \left(-4 - re\right)} \]
    12. Taylor expanded in re around inf 36.3%

      \[\leadsto \color{blue}{re \cdot \left(-4 \cdot \frac{im}{re} + -1 \cdot im\right)} \]
    13. Step-by-step derivation
      1. mul-1-neg36.3%

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

        \[\leadsto re \cdot \color{blue}{\left(-4 \cdot \frac{im}{re} - im\right)} \]
      3. associate-*r/36.3%

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

        \[\leadsto re \cdot \left(\frac{\color{blue}{im \cdot -4}}{re} - im\right) \]
      5. associate-/l*36.3%

        \[\leadsto re \cdot \left(\color{blue}{im \cdot \frac{-4}{re}} - im\right) \]
    14. Simplified36.3%

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

    if 2.7e208 < im < 1.57999999999999994e227 or 7.2e239 < im < 6.5e252 or 3.9000000000000001e273 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 7.1%

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

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

        \[\leadsto \color{blue}{\left(-im\right)} \cdot \sin re \]
    5. Simplified7.1%

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr4.7%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sin re\right)} - -3\right)} \]
    7. Step-by-step derivation
      1. log1p-undefine4.7%

        \[\leadsto \left(-im\right) \cdot \left(e^{\color{blue}{\log \left(1 + \sin re\right)}} - -3\right) \]
      2. rem-exp-log4.7%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(1 + \sin re\right)} - -3\right) \]
      3. +-commutative4.7%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(\sin re + 1\right)} - -3\right) \]
      4. associate--l+4.7%

        \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + \left(1 - -3\right)\right)} \]
      5. metadata-eval4.7%

        \[\leadsto \left(-im\right) \cdot \left(\sin re + \color{blue}{4}\right) \]
    8. Simplified4.7%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + 4\right)} \]
    9. Taylor expanded in re around 0 1.1%

      \[\leadsto \color{blue}{-4 \cdot im + -1 \cdot \left(im \cdot re\right)} \]
    10. Step-by-step derivation
      1. *-commutative1.1%

        \[\leadsto \color{blue}{im \cdot -4} + -1 \cdot \left(im \cdot re\right) \]
      2. mul-1-neg1.1%

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

        \[\leadsto im \cdot -4 + \color{blue}{im \cdot \left(-re\right)} \]
      4. distribute-lft-out1.1%

        \[\leadsto \color{blue}{im \cdot \left(-4 + \left(-re\right)\right)} \]
      5. unsub-neg1.1%

        \[\leadsto im \cdot \color{blue}{\left(-4 - re\right)} \]
    11. Simplified1.1%

      \[\leadsto \color{blue}{im \cdot \left(-4 - re\right)} \]
    12. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \color{blue}{\sqrt{im \cdot \left(-4 - re\right)} \cdot \sqrt{im \cdot \left(-4 - re\right)}} \]
      2. sqrt-unprod41.7%

        \[\leadsto \color{blue}{\sqrt{\left(im \cdot \left(-4 - re\right)\right) \cdot \left(im \cdot \left(-4 - re\right)\right)}} \]
      3. pow241.7%

        \[\leadsto \sqrt{\color{blue}{{\left(im \cdot \left(-4 - re\right)\right)}^{2}}} \]
    13. Applied egg-rr41.7%

      \[\leadsto \color{blue}{\sqrt{{\left(im \cdot \left(-4 - re\right)\right)}^{2}}} \]
    14. Step-by-step derivation
      1. unpow241.7%

        \[\leadsto \sqrt{\color{blue}{\left(im \cdot \left(-4 - re\right)\right) \cdot \left(im \cdot \left(-4 - re\right)\right)}} \]
      2. rem-sqrt-square33.8%

        \[\leadsto \color{blue}{\left|im \cdot \left(-4 - re\right)\right|} \]
    15. Simplified33.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 8.2 \cdot 10^{+26}:\\ \;\;\;\;im \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+208} \lor \neg \left(im \leq 1.58 \cdot 10^{+227}\right) \land \left(im \leq 7.2 \cdot 10^{+239} \lor \neg \left(im \leq 6.5 \cdot 10^{+252}\right) \land im \leq 3.9 \cdot 10^{+273}\right):\\ \;\;\;\;re \cdot \left(im \cdot \frac{-4}{re} - im\right)\\ \mathbf{else}:\\ \;\;\;\;\left|im \cdot \left(-4 - re\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 62.5% accurate, 2.7× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 1.1 \cdot 10^{+23}:\\ \;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(im\_m \cdot \frac{-4}{re} - im\_m\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 2.6e-15)
    (* (- im_m) (sin re))
    (if (<= im_m 1.1e+23)
      (* im_m (- (expm1 re)))
      (* re (- (* im_m (/ -4.0 re)) im_m))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 1.1e+23) {
		tmp = im_m * -expm1(re);
	} else {
		tmp = re * ((im_m * (-4.0 / re)) - im_m);
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 2.6e-15) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 1.1e+23) {
		tmp = im_m * -Math.expm1(re);
	} else {
		tmp = re * ((im_m * (-4.0 / re)) - im_m);
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 2.6e-15:
		tmp = -im_m * math.sin(re)
	elif im_m <= 1.1e+23:
		tmp = im_m * -math.expm1(re)
	else:
		tmp = re * ((im_m * (-4.0 / re)) - im_m)
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 2.6e-15)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 1.1e+23)
		tmp = Float64(im_m * Float64(-expm1(re)));
	else
		tmp = Float64(re * Float64(Float64(im_m * Float64(-4.0 / re)) - im_m));
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 2.6e-15], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 1.1e+23], N[(im$95$m * (-N[(Exp[re] - 1), $MachinePrecision])), $MachinePrecision], N[(re * N[(N[(im$95$m * N[(-4.0 / re), $MachinePrecision]), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 2.6 \cdot 10^{-15}:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\

\mathbf{elif}\;im\_m \leq 1.1 \cdot 10^{+23}:\\
\;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 2.60000000000000004e-15

    1. Initial program 57.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 61.5%

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

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

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

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

    if 2.60000000000000004e-15 < im < 1.10000000000000004e23

    1. Initial program 89.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 21.3%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr21.3%

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

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

    if 1.10000000000000004e23 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 4.6%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr3.4%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sin re\right)} - -3\right)} \]
    7. Step-by-step derivation
      1. log1p-undefine3.4%

        \[\leadsto \left(-im\right) \cdot \left(e^{\color{blue}{\log \left(1 + \sin re\right)}} - -3\right) \]
      2. rem-exp-log3.4%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(1 + \sin re\right)} - -3\right) \]
      3. +-commutative3.4%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(\sin re + 1\right)} - -3\right) \]
      4. associate--l+3.4%

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

        \[\leadsto \left(-im\right) \cdot \left(\sin re + \color{blue}{4}\right) \]
    8. Simplified3.4%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + 4\right)} \]
    9. Taylor expanded in re around 0 10.5%

      \[\leadsto \color{blue}{-4 \cdot im + -1 \cdot \left(im \cdot re\right)} \]
    10. Step-by-step derivation
      1. *-commutative10.5%

        \[\leadsto \color{blue}{im \cdot -4} + -1 \cdot \left(im \cdot re\right) \]
      2. mul-1-neg10.5%

        \[\leadsto im \cdot -4 + \color{blue}{\left(-im \cdot re\right)} \]
      3. distribute-rgt-neg-out10.5%

        \[\leadsto im \cdot -4 + \color{blue}{im \cdot \left(-re\right)} \]
      4. distribute-lft-out10.5%

        \[\leadsto \color{blue}{im \cdot \left(-4 + \left(-re\right)\right)} \]
      5. unsub-neg10.5%

        \[\leadsto im \cdot \color{blue}{\left(-4 - re\right)} \]
    11. Simplified10.5%

      \[\leadsto \color{blue}{im \cdot \left(-4 - re\right)} \]
    12. Taylor expanded in re around inf 30.8%

      \[\leadsto \color{blue}{re \cdot \left(-4 \cdot \frac{im}{re} + -1 \cdot im\right)} \]
    13. Step-by-step derivation
      1. mul-1-neg30.8%

        \[\leadsto re \cdot \left(-4 \cdot \frac{im}{re} + \color{blue}{\left(-im\right)}\right) \]
      2. unsub-neg30.8%

        \[\leadsto re \cdot \color{blue}{\left(-4 \cdot \frac{im}{re} - im\right)} \]
      3. associate-*r/30.8%

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

        \[\leadsto re \cdot \left(\frac{\color{blue}{im \cdot -4}}{re} - im\right) \]
      5. associate-/l*30.8%

        \[\leadsto re \cdot \left(\color{blue}{im \cdot \frac{-4}{re}} - im\right) \]
    14. Simplified30.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+23}:\\ \;\;\;\;im \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(im \cdot \frac{-4}{re} - im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 39.5% accurate, 2.8× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 1.05 \cdot 10^{+109}:\\ \;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(im\_m \cdot \frac{-4}{re} - im\_m\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 1.05e+109)
    (* im_m (- (expm1 re)))
    (* re (- (* im_m (/ -4.0 re)) im_m)))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 1.05e+109) {
		tmp = im_m * -expm1(re);
	} else {
		tmp = re * ((im_m * (-4.0 / re)) - im_m);
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 1.05e+109) {
		tmp = im_m * -Math.expm1(re);
	} else {
		tmp = re * ((im_m * (-4.0 / re)) - im_m);
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 1.05e+109:
		tmp = im_m * -math.expm1(re)
	else:
		tmp = re * ((im_m * (-4.0 / re)) - im_m)
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 1.05e+109)
		tmp = Float64(im_m * Float64(-expm1(re)));
	else
		tmp = Float64(re * Float64(Float64(im_m * Float64(-4.0 / re)) - im_m));
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 1.05e+109], N[(im$95$m * (-N[(Exp[re] - 1), $MachinePrecision])), $MachinePrecision], N[(re * N[(N[(im$95$m * N[(-4.0 / re), $MachinePrecision]), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 1.05 \cdot 10^{+109}:\\
\;\;\;\;im\_m \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 1.0500000000000001e109

    1. Initial program 61.8%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 56.3%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr56.2%

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

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

    if 1.0500000000000001e109 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 5.0%

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

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

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

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

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sin re\right)} - -3\right)} \]
    7. Step-by-step derivation
      1. log1p-undefine3.8%

        \[\leadsto \left(-im\right) \cdot \left(e^{\color{blue}{\log \left(1 + \sin re\right)}} - -3\right) \]
      2. rem-exp-log3.8%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(1 + \sin re\right)} - -3\right) \]
      3. +-commutative3.8%

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(\sin re + 1\right)} - -3\right) \]
      4. associate--l+3.8%

        \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + \left(1 - -3\right)\right)} \]
      5. metadata-eval3.8%

        \[\leadsto \left(-im\right) \cdot \left(\sin re + \color{blue}{4}\right) \]
    8. Simplified3.8%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + 4\right)} \]
    9. Taylor expanded in re around 0 13.3%

      \[\leadsto \color{blue}{-4 \cdot im + -1 \cdot \left(im \cdot re\right)} \]
    10. Step-by-step derivation
      1. *-commutative13.3%

        \[\leadsto \color{blue}{im \cdot -4} + -1 \cdot \left(im \cdot re\right) \]
      2. mul-1-neg13.3%

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

        \[\leadsto im \cdot -4 + \color{blue}{im \cdot \left(-re\right)} \]
      4. distribute-lft-out13.3%

        \[\leadsto \color{blue}{im \cdot \left(-4 + \left(-re\right)\right)} \]
      5. unsub-neg13.3%

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

      \[\leadsto \color{blue}{im \cdot \left(-4 - re\right)} \]
    12. Taylor expanded in re around inf 39.8%

      \[\leadsto \color{blue}{re \cdot \left(-4 \cdot \frac{im}{re} + -1 \cdot im\right)} \]
    13. Step-by-step derivation
      1. mul-1-neg39.8%

        \[\leadsto re \cdot \left(-4 \cdot \frac{im}{re} + \color{blue}{\left(-im\right)}\right) \]
      2. unsub-neg39.8%

        \[\leadsto re \cdot \color{blue}{\left(-4 \cdot \frac{im}{re} - im\right)} \]
      3. associate-*r/39.8%

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

        \[\leadsto re \cdot \left(\frac{\color{blue}{im \cdot -4}}{re} - im\right) \]
      5. associate-/l*39.8%

        \[\leadsto re \cdot \left(\color{blue}{im \cdot \frac{-4}{re}} - im\right) \]
    14. Simplified39.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.05 \cdot 10^{+109}:\\ \;\;\;\;im \cdot \left(-\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(im \cdot \frac{-4}{re} - im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 38.3% accurate, 22.0× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 0.00078:\\ \;\;\;\;im\_m \cdot \left(-re\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(im\_m \cdot \frac{-4}{re} - im\_m\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 0.00078) (* im_m (- re)) (* re (- (* im_m (/ -4.0 re)) im_m)))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 0.00078) {
		tmp = im_m * -re;
	} else {
		tmp = re * ((im_m * (-4.0 / re)) - im_m);
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 0.00078d0) then
        tmp = im_m * -re
    else
        tmp = re * ((im_m * ((-4.0d0) / re)) - im_m)
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 0.00078) {
		tmp = im_m * -re;
	} else {
		tmp = re * ((im_m * (-4.0 / re)) - im_m);
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 0.00078:
		tmp = im_m * -re
	else:
		tmp = re * ((im_m * (-4.0 / re)) - im_m)
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 0.00078)
		tmp = Float64(im_m * Float64(-re));
	else
		tmp = Float64(re * Float64(Float64(im_m * Float64(-4.0 / re)) - im_m));
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 0.00078)
		tmp = im_m * -re;
	else
		tmp = re * ((im_m * (-4.0 / re)) - im_m);
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 0.00078], N[(im$95$m * (-re)), $MachinePrecision], N[(re * N[(N[(im$95$m * N[(-4.0 / re), $MachinePrecision]), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 0.00078:\\
\;\;\;\;im\_m \cdot \left(-re\right)\\

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


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

    1. Initial program 57.8%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 61.7%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Taylor expanded in re around 0 35.7%

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

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

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

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

    if 7.79999999999999986e-4 < im

    1. Initial program 99.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 4.9%

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

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

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

      \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
    6. Applied egg-rr3.2%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sin re\right)} - -3\right)} \]
    7. Step-by-step derivation
      1. log1p-undefine3.2%

        \[\leadsto \left(-im\right) \cdot \left(e^{\color{blue}{\log \left(1 + \sin re\right)}} - -3\right) \]
      2. rem-exp-log3.2%

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

        \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(\sin re + 1\right)} - -3\right) \]
      4. associate--l+3.2%

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

        \[\leadsto \left(-im\right) \cdot \left(\sin re + \color{blue}{4}\right) \]
    8. Simplified3.2%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + 4\right)} \]
    9. Taylor expanded in re around 0 9.9%

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

        \[\leadsto \color{blue}{im \cdot -4} + -1 \cdot \left(im \cdot re\right) \]
      2. mul-1-neg9.9%

        \[\leadsto im \cdot -4 + \color{blue}{\left(-im \cdot re\right)} \]
      3. distribute-rgt-neg-out9.9%

        \[\leadsto im \cdot -4 + \color{blue}{im \cdot \left(-re\right)} \]
      4. distribute-lft-out9.9%

        \[\leadsto \color{blue}{im \cdot \left(-4 + \left(-re\right)\right)} \]
      5. unsub-neg9.9%

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

      \[\leadsto \color{blue}{im \cdot \left(-4 - re\right)} \]
    12. Taylor expanded in re around inf 28.3%

      \[\leadsto \color{blue}{re \cdot \left(-4 \cdot \frac{im}{re} + -1 \cdot im\right)} \]
    13. Step-by-step derivation
      1. mul-1-neg28.3%

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

        \[\leadsto re \cdot \color{blue}{\left(-4 \cdot \frac{im}{re} - im\right)} \]
      3. associate-*r/28.3%

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

        \[\leadsto re \cdot \left(\frac{\color{blue}{im \cdot -4}}{re} - im\right) \]
      5. associate-/l*28.3%

        \[\leadsto re \cdot \left(\color{blue}{im \cdot \frac{-4}{re}} - im\right) \]
    14. Simplified28.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.00078:\\ \;\;\;\;im \cdot \left(-re\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(im \cdot \frac{-4}{re} - im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 15.9% accurate, 38.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 3.4 \cdot 10^{-83}:\\ \;\;\;\;im\_m \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im\_m\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 3.4e-83) (* im_m 0.0) im_m)))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 3.4e-83) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m;
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (re <= 3.4d-83) then
        tmp = im_m * 0.0d0
    else
        tmp = im_m
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 3.4e-83) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m;
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if re <= 3.4e-83:
		tmp = im_m * 0.0
	else:
		tmp = im_m
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (re <= 3.4e-83)
		tmp = Float64(im_m * 0.0);
	else
		tmp = im_m;
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (re <= 3.4e-83)
		tmp = im_m * 0.0;
	else
		tmp = im_m;
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 3.4e-83], N[(im$95$m * 0.0), $MachinePrecision], im$95$m]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;re \leq 3.4 \cdot 10^{-83}:\\
\;\;\;\;im\_m \cdot 0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 3.3999999999999998e-83

    1. Initial program 72.5%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 91.6%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in91.6%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+91.6%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative91.6%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative91.6%

        \[\leadsto im \cdot \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right)\right)} \]
      5. +-commutative91.6%

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr17.5%

      \[\leadsto im \cdot \color{blue}{0} \]

    if 3.3999999999999998e-83 < re

    1. Initial program 60.3%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 95.1%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in95.1%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+95.1%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative95.1%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative95.1%

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr8.3%

      \[\leadsto im \cdot \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification14.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 3.4 \cdot 10^{-83}:\\ \;\;\;\;im \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 16.0% accurate, 38.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 7 \cdot 10^{-77}:\\ \;\;\;\;im\_m \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot 0.9916666666666667\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 7e-77) (* im_m 0.0) (* im_m 0.9916666666666667))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 7e-77) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.9916666666666667;
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (re <= 7d-77) then
        tmp = im_m * 0.0d0
    else
        tmp = im_m * 0.9916666666666667d0
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 7e-77) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.9916666666666667;
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if re <= 7e-77:
		tmp = im_m * 0.0
	else:
		tmp = im_m * 0.9916666666666667
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (re <= 7e-77)
		tmp = Float64(im_m * 0.0);
	else
		tmp = Float64(im_m * 0.9916666666666667);
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (re <= 7e-77)
		tmp = im_m * 0.0;
	else
		tmp = im_m * 0.9916666666666667;
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 7e-77], N[(im$95$m * 0.0), $MachinePrecision], N[(im$95$m * 0.9916666666666667), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;re \leq 7 \cdot 10^{-77}:\\
\;\;\;\;im\_m \cdot 0\\

\mathbf{else}:\\
\;\;\;\;im\_m \cdot 0.9916666666666667\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 7.00000000000000026e-77

    1. Initial program 72.5%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 91.6%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in91.6%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+91.6%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative91.6%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative91.6%

        \[\leadsto im \cdot \color{blue}{\left({im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right)\right)} \]
      5. +-commutative91.6%

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr17.5%

      \[\leadsto im \cdot \color{blue}{0} \]

    if 7.00000000000000026e-77 < re

    1. Initial program 60.3%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 95.1%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in95.1%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+95.1%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative95.1%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative95.1%

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr8.0%

      \[\leadsto im \cdot \color{blue}{0.9916666666666667} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 17: 16.1% accurate, 38.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 2.05 \cdot 10^{-48}:\\ \;\;\;\;im\_m \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot 0.75\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 2.05e-48) (* im_m 0.0) (* im_m 0.75))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 2.05e-48) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.75;
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (re <= 2.05d-48) then
        tmp = im_m * 0.0d0
    else
        tmp = im_m * 0.75d0
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 2.05e-48) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.75;
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if re <= 2.05e-48:
		tmp = im_m * 0.0
	else:
		tmp = im_m * 0.75
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (re <= 2.05e-48)
		tmp = Float64(im_m * 0.0);
	else
		tmp = Float64(im_m * 0.75);
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (re <= 2.05e-48)
		tmp = im_m * 0.0;
	else
		tmp = im_m * 0.75;
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 2.05e-48], N[(im$95$m * 0.0), $MachinePrecision], N[(im$95$m * 0.75), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;re \leq 2.05 \cdot 10^{-48}:\\
\;\;\;\;im\_m \cdot 0\\

\mathbf{else}:\\
\;\;\;\;im\_m \cdot 0.75\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 2.05000000000000007e-48

    1. Initial program 72.6%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 91.3%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in91.3%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+91.3%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative91.3%

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

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + -1 \cdot \sin re\right)}\right) \]
    5. Simplified93.4%

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr17.2%

      \[\leadsto im \cdot \color{blue}{0} \]

    if 2.05000000000000007e-48 < re

    1. Initial program 59.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 96.1%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in96.1%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+96.1%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative96.1%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative96.1%

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr8.0%

      \[\leadsto im \cdot \color{blue}{0.75} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 18: 16.1% accurate, 38.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 5.8 \cdot 10^{-45}:\\ \;\;\;\;im\_m \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot 0.5\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 5.8e-45) (* im_m 0.0) (* im_m 0.5))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 5.8e-45) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.5;
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (re <= 5.8d-45) then
        tmp = im_m * 0.0d0
    else
        tmp = im_m * 0.5d0
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 5.8e-45) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.5;
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if re <= 5.8e-45:
		tmp = im_m * 0.0
	else:
		tmp = im_m * 0.5
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (re <= 5.8e-45)
		tmp = Float64(im_m * 0.0);
	else
		tmp = Float64(im_m * 0.5);
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (re <= 5.8e-45)
		tmp = im_m * 0.0;
	else
		tmp = im_m * 0.5;
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 5.8e-45], N[(im$95$m * 0.0), $MachinePrecision], N[(im$95$m * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;re \leq 5.8 \cdot 10^{-45}:\\
\;\;\;\;im\_m \cdot 0\\

\mathbf{else}:\\
\;\;\;\;im\_m \cdot 0.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 5.8e-45

    1. Initial program 72.6%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 91.3%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in91.3%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+91.3%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative91.3%

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

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + -1 \cdot \sin re\right)}\right) \]
    5. Simplified93.4%

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr17.2%

      \[\leadsto im \cdot \color{blue}{0} \]

    if 5.8e-45 < re

    1. Initial program 59.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 96.1%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in96.1%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+96.1%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative96.1%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative96.1%

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr7.7%

      \[\leadsto im \cdot \color{blue}{0.5} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 19: 16.0% accurate, 38.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 5.8 \cdot 10^{-45}:\\ \;\;\;\;im\_m \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot 0.3333333333333333\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 5.8e-45) (* im_m 0.0) (* im_m 0.3333333333333333))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 5.8e-45) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.3333333333333333;
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (re <= 5.8d-45) then
        tmp = im_m * 0.0d0
    else
        tmp = im_m * 0.3333333333333333d0
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 5.8e-45) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.3333333333333333;
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if re <= 5.8e-45:
		tmp = im_m * 0.0
	else:
		tmp = im_m * 0.3333333333333333
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (re <= 5.8e-45)
		tmp = Float64(im_m * 0.0);
	else
		tmp = Float64(im_m * 0.3333333333333333);
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (re <= 5.8e-45)
		tmp = im_m * 0.0;
	else
		tmp = im_m * 0.3333333333333333;
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 5.8e-45], N[(im$95$m * 0.0), $MachinePrecision], N[(im$95$m * 0.3333333333333333), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;re \leq 5.8 \cdot 10^{-45}:\\
\;\;\;\;im\_m \cdot 0\\

\mathbf{else}:\\
\;\;\;\;im\_m \cdot 0.3333333333333333\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 5.8e-45

    1. Initial program 72.6%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 91.3%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in91.3%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+91.3%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative91.3%

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

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + -1 \cdot \sin re\right)}\right) \]
    5. Simplified93.4%

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr17.2%

      \[\leadsto im \cdot \color{blue}{0} \]

    if 5.8e-45 < re

    1. Initial program 59.4%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 96.1%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in96.1%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+96.1%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative96.1%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative96.1%

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr7.5%

      \[\leadsto im \cdot \color{blue}{0.3333333333333333} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 20: 16.0% accurate, 38.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 2.5 \cdot 10^{-43}:\\ \;\;\;\;im\_m \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot 0.25\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 2.5e-43) (* im_m 0.0) (* im_m 0.25))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 2.5e-43) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.25;
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (re <= 2.5d-43) then
        tmp = im_m * 0.0d0
    else
        tmp = im_m * 0.25d0
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 2.5e-43) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.25;
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if re <= 2.5e-43:
		tmp = im_m * 0.0
	else:
		tmp = im_m * 0.25
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (re <= 2.5e-43)
		tmp = Float64(im_m * 0.0);
	else
		tmp = Float64(im_m * 0.25);
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (re <= 2.5e-43)
		tmp = im_m * 0.0;
	else
		tmp = im_m * 0.25;
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 2.5e-43], N[(im$95$m * 0.0), $MachinePrecision], N[(im$95$m * 0.25), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;re \leq 2.5 \cdot 10^{-43}:\\
\;\;\;\;im\_m \cdot 0\\

\mathbf{else}:\\
\;\;\;\;im\_m \cdot 0.25\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 2.50000000000000009e-43

    1. Initial program 72.7%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 91.3%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in91.3%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+91.3%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative91.3%

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

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + -1 \cdot \sin re\right)}\right) \]
    5. Simplified93.4%

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr17.7%

      \[\leadsto im \cdot \color{blue}{0} \]

    if 2.50000000000000009e-43 < re

    1. Initial program 58.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 96.0%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in96.0%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+96.0%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative96.0%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative96.0%

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr7.5%

      \[\leadsto im \cdot \color{blue}{0.25} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 21: 16.0% accurate, 38.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 2.5 \cdot 10^{-43}:\\ \;\;\;\;im\_m \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot 0.16666666666666666\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 2.5e-43) (* im_m 0.0) (* im_m 0.16666666666666666))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 2.5e-43) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.16666666666666666;
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (re <= 2.5d-43) then
        tmp = im_m * 0.0d0
    else
        tmp = im_m * 0.16666666666666666d0
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 2.5e-43) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.16666666666666666;
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if re <= 2.5e-43:
		tmp = im_m * 0.0
	else:
		tmp = im_m * 0.16666666666666666
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (re <= 2.5e-43)
		tmp = Float64(im_m * 0.0);
	else
		tmp = Float64(im_m * 0.16666666666666666);
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (re <= 2.5e-43)
		tmp = im_m * 0.0;
	else
		tmp = im_m * 0.16666666666666666;
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 2.5e-43], N[(im$95$m * 0.0), $MachinePrecision], N[(im$95$m * 0.16666666666666666), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;re \leq 2.5 \cdot 10^{-43}:\\
\;\;\;\;im\_m \cdot 0\\

\mathbf{else}:\\
\;\;\;\;im\_m \cdot 0.16666666666666666\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 2.50000000000000009e-43

    1. Initial program 72.7%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 91.3%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in91.3%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+91.3%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative91.3%

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

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + -1 \cdot \sin re\right)}\right) \]
    5. Simplified93.4%

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr17.7%

      \[\leadsto im \cdot \color{blue}{0} \]

    if 2.50000000000000009e-43 < re

    1. Initial program 58.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 96.0%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in96.0%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+96.0%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative96.0%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative96.0%

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr7.3%

      \[\leadsto im \cdot \color{blue}{0.16666666666666666} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 22: 15.9% accurate, 38.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 8.2 \cdot 10^{-29}:\\ \;\;\;\;im\_m \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot 0.027777777777777776\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 8.2e-29) (* im_m 0.0) (* im_m 0.027777777777777776))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 8.2e-29) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.027777777777777776;
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (re <= 8.2d-29) then
        tmp = im_m * 0.0d0
    else
        tmp = im_m * 0.027777777777777776d0
    end if
    code = im_s * tmp
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (re <= 8.2e-29) {
		tmp = im_m * 0.0;
	} else {
		tmp = im_m * 0.027777777777777776;
	}
	return im_s * tmp;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if re <= 8.2e-29:
		tmp = im_m * 0.0
	else:
		tmp = im_m * 0.027777777777777776
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (re <= 8.2e-29)
		tmp = Float64(im_m * 0.0);
	else
		tmp = Float64(im_m * 0.027777777777777776);
	end
	return Float64(im_s * tmp)
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (re <= 8.2e-29)
		tmp = im_m * 0.0;
	else
		tmp = im_m * 0.027777777777777776;
	end
	tmp_2 = im_s * tmp;
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[re, 8.2e-29], N[(im$95$m * 0.0), $MachinePrecision], N[(im$95$m * 0.027777777777777776), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;re \leq 8.2 \cdot 10^{-29}:\\
\;\;\;\;im\_m \cdot 0\\

\mathbf{else}:\\
\;\;\;\;im\_m \cdot 0.027777777777777776\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 8.1999999999999996e-29

    1. Initial program 73.3%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 91.5%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in91.5%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+91.5%

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

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative91.5%

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + -1 \cdot \sin re\right)}\right) \]
    5. Simplified93.6%

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr17.3%

      \[\leadsto im \cdot \color{blue}{0} \]

    if 8.1999999999999996e-29 < re

    1. Initial program 56.6%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 95.8%

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-in95.8%

        \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
      2. associate-+r+95.8%

        \[\leadsto im \cdot \color{blue}{\left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)} \]
      3. *-commutative95.8%

        \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
      4. +-commutative95.8%

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    6. Applied egg-rr7.0%

      \[\leadsto im \cdot \color{blue}{0.027777777777777776} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 23: 32.7% accurate, 77.0× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \left(im\_m \cdot \left(-re\right)\right) \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m) :precision binary64 (* im_s (* im_m (- re))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	return im_s * (im_m * -re);
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = im_s * (im_m * -re)
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	return im_s * (im_m * -re);
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	return im_s * (im_m * -re)
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	return Float64(im_s * Float64(im_m * Float64(-re)))
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp = code(im_s, re, im_m)
	tmp = im_s * (im_m * -re);
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * N[(im$95$m * (-re)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \left(im\_m \cdot \left(-re\right)\right)
\end{array}
Derivation
  1. Initial program 68.6%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in im around 0 47.1%

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

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

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

    \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
  6. Taylor expanded in re around 0 29.0%

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

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

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

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

    \[\leadsto im \cdot \left(-re\right) \]
  10. Add Preprocessing

Alternative 24: 15.3% accurate, 102.7× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \left(im\_m \cdot 0\right) \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m) :precision binary64 (* im_s (* im_m 0.0)))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	return im_s * (im_m * 0.0);
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = im_s * (im_m * 0.0d0)
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	return im_s * (im_m * 0.0);
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	return im_s * (im_m * 0.0)
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	return Float64(im_s * Float64(im_m * 0.0))
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp = code(im_s, re, im_m)
	tmp = im_s * (im_m * 0.0);
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * N[(im$95$m * 0.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \left(im\_m \cdot 0\right)
\end{array}
Derivation
  1. Initial program 68.6%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in im around 0 92.7%

    \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
  4. Step-by-step derivation
    1. distribute-rgt-in92.7%

      \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
    2. associate-+r+92.7%

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

      \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
    4. +-commutative92.7%

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

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

    \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
  6. Applied egg-rr13.4%

    \[\leadsto im \cdot \color{blue}{0} \]
  7. Add Preprocessing

Alternative 25: 5.7% accurate, 102.7× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \left(im\_m \cdot -2\right) \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m) :precision binary64 (* im_s (* im_m -2.0)))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	return im_s * (im_m * -2.0);
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = im_s * (im_m * (-2.0d0))
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	return im_s * (im_m * -2.0);
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	return im_s * (im_m * -2.0)
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	return Float64(im_s * Float64(im_m * -2.0))
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp = code(im_s, re, im_m)
	tmp = im_s * (im_m * -2.0);
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * N[(im$95$m * -2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \left(im\_m \cdot -2\right)
\end{array}
Derivation
  1. Initial program 68.6%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in im around 0 92.7%

    \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
  4. Step-by-step derivation
    1. distribute-rgt-in92.7%

      \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
    2. associate-+r+92.7%

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

      \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
    4. +-commutative92.7%

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

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

    \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
  6. Applied egg-rr5.1%

    \[\leadsto im \cdot \color{blue}{-2} \]
  7. Add Preprocessing

Alternative 26: 5.6% accurate, 102.7× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \left(im\_m \cdot -3\right) \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m) :precision binary64 (* im_s (* im_m -3.0)))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	return im_s * (im_m * -3.0);
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = im_s * (im_m * (-3.0d0))
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	return im_s * (im_m * -3.0);
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	return im_s * (im_m * -3.0)
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	return Float64(im_s * Float64(im_m * -3.0))
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp = code(im_s, re, im_m)
	tmp = im_s * (im_m * -3.0);
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * N[(im$95$m * -3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \left(im\_m \cdot -3\right)
\end{array}
Derivation
  1. Initial program 68.6%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in im around 0 92.7%

    \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + {im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)\right)} \]
  4. Step-by-step derivation
    1. distribute-rgt-in92.7%

      \[\leadsto im \cdot \left(-1 \cdot \sin re + \color{blue}{\left(\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2} + \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot {im}^{2}\right)}\right) \]
    2. associate-+r+92.7%

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

      \[\leadsto im \cdot \left(\left(-1 \cdot \sin re + \left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot \left({im}^{2} \cdot \left(-0.008333333333333333 \cdot \sin re + -0.0001984126984126984 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)}\right) \]
    4. +-commutative92.7%

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

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

    \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(\mathsf{fma}\left({im}^{2}, -0.0001984126984126984, -0.008333333333333333\right) \cdot {im}^{4} + \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
  6. Applied egg-rr5.0%

    \[\leadsto im \cdot \color{blue}{-3} \]
  7. Add Preprocessing

Alternative 27: 5.6% accurate, 102.7× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \left(im\_m \cdot -4\right) \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m) :precision binary64 (* im_s (* im_m -4.0)))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	return im_s * (im_m * -4.0);
}
im\_m = abs(im)
im\_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = im_s * (im_m * (-4.0d0))
end function
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	return im_s * (im_m * -4.0);
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	return im_s * (im_m * -4.0)
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	return Float64(im_s * Float64(im_m * -4.0))
end
im\_m = abs(im);
im\_s = sign(im) * abs(1.0);
function tmp = code(im_s, re, im_m)
	tmp = im_s * (im_m * -4.0);
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * N[(im$95$m * -4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \left(im\_m \cdot -4\right)
\end{array}
Derivation
  1. Initial program 68.6%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in im around 0 47.1%

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

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

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

    \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
  6. Applied egg-rr5.0%

    \[\leadsto \left(-im\right) \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sin re\right)} - -3\right)} \]
  7. Step-by-step derivation
    1. log1p-undefine5.0%

      \[\leadsto \left(-im\right) \cdot \left(e^{\color{blue}{\log \left(1 + \sin re\right)}} - -3\right) \]
    2. rem-exp-log5.0%

      \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(1 + \sin re\right)} - -3\right) \]
    3. +-commutative5.0%

      \[\leadsto \left(-im\right) \cdot \left(\color{blue}{\left(\sin re + 1\right)} - -3\right) \]
    4. associate--l+5.0%

      \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + \left(1 - -3\right)\right)} \]
    5. metadata-eval5.0%

      \[\leadsto \left(-im\right) \cdot \left(\sin re + \color{blue}{4}\right) \]
  8. Simplified5.0%

    \[\leadsto \left(-im\right) \cdot \color{blue}{\left(\sin re + 4\right)} \]
  9. Taylor expanded in re around 0 5.0%

    \[\leadsto \color{blue}{-4 \cdot im} \]
  10. Step-by-step derivation
    1. *-commutative5.0%

      \[\leadsto \color{blue}{im \cdot -4} \]
  11. Simplified5.0%

    \[\leadsto \color{blue}{im \cdot -4} \]
  12. Add Preprocessing

Developer target: 99.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\sin 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 \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024107 
(FPCore (re im)
  :name "math.cos on complex, imaginary part"
  :precision binary64

  :alt
  (if (< (fabs im) 1.0) (- (* (sin re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))

  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))