math.cos on complex, imaginary part

Percentage Accurate: 65.2% → 99.7%
Time: 10.6s
Alternatives: 17
Speedup: 2.5×

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 17 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.2% 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.7% accurate, 0.6× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := e^{-im\_m} - e^{im\_m}\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq -0.5:\\ \;\;\;\;t\_0 \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (- (exp (- im_m)) (exp im_m))))
   (*
    im_s
    (if (<= t_0 -0.5)
      (* t_0 (* 0.5 (sin re)))
      (* (sin re) (- (* (pow im_m 3.0) -0.16666666666666666) im_m))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = exp(-im_m) - exp(im_m);
	double tmp;
	if (t_0 <= -0.5) {
		tmp = t_0 * (0.5 * sin(re));
	} else {
		tmp = sin(re) * ((pow(im_m, 3.0) * -0.16666666666666666) - 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) :: t_0
    real(8) :: tmp
    t_0 = exp(-im_m) - exp(im_m)
    if (t_0 <= (-0.5d0)) then
        tmp = t_0 * (0.5d0 * sin(re))
    else
        tmp = sin(re) * (((im_m ** 3.0d0) * (-0.16666666666666666d0)) - 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 t_0 = Math.exp(-im_m) - Math.exp(im_m);
	double tmp;
	if (t_0 <= -0.5) {
		tmp = t_0 * (0.5 * Math.sin(re));
	} else {
		tmp = Math.sin(re) * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - 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):
	t_0 = math.exp(-im_m) - math.exp(im_m)
	tmp = 0
	if t_0 <= -0.5:
		tmp = t_0 * (0.5 * math.sin(re))
	else:
		tmp = math.sin(re) * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m)
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(exp(Float64(-im_m)) - exp(im_m))
	tmp = 0.0
	if (t_0 <= -0.5)
		tmp = Float64(t_0 * Float64(0.5 * sin(re)));
	else
		tmp = Float64(sin(re) * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - 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)
	t_0 = exp(-im_m) - exp(im_m);
	tmp = 0.0;
	if (t_0 <= -0.5)
		tmp = t_0 * (0.5 * sin(re));
	else
		tmp = sin(re) * (((im_m ^ 3.0) * -0.16666666666666666) - 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_] := Block[{t$95$0 = N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[t$95$0, -0.5], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := e^{-im\_m} - e^{im\_m}\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -0.5:\\
\;\;\;\;t\_0 \cdot \left(0.5 \cdot \sin re\right)\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)) < -0.5

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing

    if -0.5 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 58.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 87.8%

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

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

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

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

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

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

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

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

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

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

        \[\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--89.7%

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

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

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

Alternative 2: 78.2% 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 450000000:\\ \;\;\;\;im\_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im\_m \leq 9.8 \cdot 10^{+24} \lor \neg \left(im\_m \leq 6 \cdot 10^{+249}\right) \land im\_m \leq 6.8 \cdot 10^{+259}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot 0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 450000000.0)
    (* im_m (- (sin re)))
    (if (or (<= im_m 9.8e+24) (and (not (<= im_m 6e+249)) (<= im_m 6.8e+259)))
      (log1p (expm1 (* im_m 0.16666666666666666)))
      (* re (- (* (pow im_m 3.0) -0.16666666666666666) 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 <= 450000000.0) {
		tmp = im_m * -sin(re);
	} else if ((im_m <= 9.8e+24) || (!(im_m <= 6e+249) && (im_m <= 6.8e+259))) {
		tmp = log1p(expm1((im_m * 0.16666666666666666)));
	} else {
		tmp = re * ((pow(im_m, 3.0) * -0.16666666666666666) - 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 <= 450000000.0) {
		tmp = im_m * -Math.sin(re);
	} else if ((im_m <= 9.8e+24) || (!(im_m <= 6e+249) && (im_m <= 6.8e+259))) {
		tmp = Math.log1p(Math.expm1((im_m * 0.16666666666666666)));
	} else {
		tmp = re * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - 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 <= 450000000.0:
		tmp = im_m * -math.sin(re)
	elif (im_m <= 9.8e+24) or (not (im_m <= 6e+249) and (im_m <= 6.8e+259)):
		tmp = math.log1p(math.expm1((im_m * 0.16666666666666666)))
	else:
		tmp = re * ((math.pow(im_m, 3.0) * -0.16666666666666666) - 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 <= 450000000.0)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif ((im_m <= 9.8e+24) || (!(im_m <= 6e+249) && (im_m <= 6.8e+259)))
		tmp = log1p(expm1(Float64(im_m * 0.16666666666666666)));
	else
		tmp = Float64(re * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - 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, 450000000.0], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[Or[LessEqual[im$95$m, 9.8e+24], And[N[Not[LessEqual[im$95$m, 6e+249]], $MachinePrecision], LessEqual[im$95$m, 6.8e+259]]], N[Log[1 + N[(Exp[N[(im$95$m * 0.16666666666666666), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], N[(re * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $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 450000000:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im\_m \leq 9.8 \cdot 10^{+24} \lor \neg \left(im\_m \leq 6 \cdot 10^{+249}\right) \land im\_m \leq 6.8 \cdot 10^{+259}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot 0.16666666666666666\right)\right)\\

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


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

    1. Initial program 59.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 64.5%

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

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

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

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

    if 4.5e8 < im < 9.80000000000000059e24 or 6.00000000000000032e249 < im < 6.79999999999999979e259

    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 61.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. associate-*r*61.4%

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

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

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

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

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

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

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

    if 9.80000000000000059e24 < im < 6.00000000000000032e249 or 6.79999999999999979e259 < 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 66.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. +-commutative66.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-neg66.4%

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

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

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

        \[\leadsto im \cdot \left(\color{blue}{\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}} - \sin re\right) \]
      6. distribute-lft-out--66.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*66.4%

        \[\leadsto im \cdot \color{blue}{\left(-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{2}\right)\right)} - im \cdot \sin re \]
      8. *-commutative66.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*66.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*74.3%

        \[\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--74.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 450000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 9.8 \cdot 10^{+24} \lor \neg \left(im \leq 6 \cdot 10^{+249}\right) \land im \leq 6.8 \cdot 10^{+259}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot 0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.7% 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 580:\\ \;\;\;\;im\_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im\_m \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;\left(-im\_m\right) \cdot {\sin re}^{-3}\\ \mathbf{elif}\;im\_m \leq 6 \cdot 10^{+249} \lor \neg \left(im\_m \leq 6.8 \cdot 10^{+259}\right):\\ \;\;\;\;re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot 0.16666666666666666\right)\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 580.0)
    (* im_m (- (sin re)))
    (if (<= im_m 5.6e+102)
      (* (- im_m) (pow (sin re) -3.0))
      (if (or (<= im_m 6e+249) (not (<= im_m 6.8e+259)))
        (* re (- (* (pow im_m 3.0) -0.16666666666666666) im_m))
        (log1p (expm1 (* 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 (im_m <= 580.0) {
		tmp = im_m * -sin(re);
	} else if (im_m <= 5.6e+102) {
		tmp = -im_m * pow(sin(re), -3.0);
	} else if ((im_m <= 6e+249) || !(im_m <= 6.8e+259)) {
		tmp = re * ((pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	} else {
		tmp = log1p(expm1((im_m * 0.16666666666666666)));
	}
	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 <= 580.0) {
		tmp = im_m * -Math.sin(re);
	} else if (im_m <= 5.6e+102) {
		tmp = -im_m * Math.pow(Math.sin(re), -3.0);
	} else if ((im_m <= 6e+249) || !(im_m <= 6.8e+259)) {
		tmp = re * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	} else {
		tmp = Math.log1p(Math.expm1((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 im_m <= 580.0:
		tmp = im_m * -math.sin(re)
	elif im_m <= 5.6e+102:
		tmp = -im_m * math.pow(math.sin(re), -3.0)
	elif (im_m <= 6e+249) or not (im_m <= 6.8e+259):
		tmp = re * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m)
	else:
		tmp = math.log1p(math.expm1((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 (im_m <= 580.0)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif (im_m <= 5.6e+102)
		tmp = Float64(Float64(-im_m) * (sin(re) ^ -3.0));
	elseif ((im_m <= 6e+249) || !(im_m <= 6.8e+259))
		tmp = Float64(re * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - im_m));
	else
		tmp = log1p(expm1(Float64(im_m * 0.16666666666666666)));
	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, 580.0], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 5.6e+102], N[((-im$95$m) * N[Power[N[Sin[re], $MachinePrecision], -3.0], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im$95$m, 6e+249], N[Not[LessEqual[im$95$m, 6.8e+259]], $MachinePrecision]], N[(re * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision], N[Log[1 + N[(Exp[N[(im$95$m * 0.16666666666666666), $MachinePrecision]] - 1), $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 580:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im\_m \leq 5.6 \cdot 10^{+102}:\\
\;\;\;\;\left(-im\_m\right) \cdot {\sin re}^{-3}\\

\mathbf{elif}\;im\_m \leq 6 \cdot 10^{+249} \lor \neg \left(im\_m \leq 6.8 \cdot 10^{+259}\right):\\
\;\;\;\;re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot 0.16666666666666666\right)\right)\\


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

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

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

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

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

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

    if 580 < im < 5.60000000000000037e102

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

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

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

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

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

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

    if 5.60000000000000037e102 < im < 6.00000000000000032e249 or 6.79999999999999979e259 < 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 89.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. +-commutative89.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-neg89.2%

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

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

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

        \[\leadsto im \cdot \left(\color{blue}{\left(-0.16666666666666666 \cdot \sin re\right) \cdot {im}^{2}} - \sin re\right) \]
      6. distribute-lft-out--89.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*89.2%

        \[\leadsto im \cdot \color{blue}{\left(-0.16666666666666666 \cdot \left(\sin re \cdot {im}^{2}\right)\right)} - im \cdot \sin re \]
      8. *-commutative89.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*89.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*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)} \]
    5. Simplified100.0%

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

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

    if 6.00000000000000032e249 < im < 6.79999999999999979e259

    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. associate-*r*100.0%

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(-1 + {im}^{2} \cdot -0.16666666666666666\right)\right)} \]
    6. Applied egg-rr4.8%

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot 0.16666666666666666\right)\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification64.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 580:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;\left(-im\right) \cdot {\sin re}^{-3}\\ \mathbf{elif}\;im \leq 6 \cdot 10^{+249} \lor \neg \left(im \leq 6.8 \cdot 10^{+259}\right):\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot 0.16666666666666666\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 95.7% accurate, 1.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := {im\_m}^{3} \cdot -0.16666666666666666\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 0.2:\\ \;\;\;\;\sin re \cdot \left(t\_0 - im\_m\right)\\ \mathbf{elif}\;im\_m \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;\left(e^{-im\_m} - e^{im\_m}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot t\_0\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* (pow im_m 3.0) -0.16666666666666666)))
   (*
    im_s
    (if (<= im_m 0.2)
      (* (sin re) (- t_0 im_m))
      (if (<= im_m 5.6e+102)
        (* (- (exp (- im_m)) (exp im_m)) (* 0.5 re))
        (* (sin re) 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 = pow(im_m, 3.0) * -0.16666666666666666;
	double tmp;
	if (im_m <= 0.2) {
		tmp = sin(re) * (t_0 - im_m);
	} else if (im_m <= 5.6e+102) {
		tmp = (exp(-im_m) - exp(im_m)) * (0.5 * re);
	} else {
		tmp = sin(re) * t_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) :: t_0
    real(8) :: tmp
    t_0 = (im_m ** 3.0d0) * (-0.16666666666666666d0)
    if (im_m <= 0.2d0) then
        tmp = sin(re) * (t_0 - im_m)
    else if (im_m <= 5.6d+102) then
        tmp = (exp(-im_m) - exp(im_m)) * (0.5d0 * re)
    else
        tmp = sin(re) * t_0
    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 t_0 = Math.pow(im_m, 3.0) * -0.16666666666666666;
	double tmp;
	if (im_m <= 0.2) {
		tmp = Math.sin(re) * (t_0 - im_m);
	} else if (im_m <= 5.6e+102) {
		tmp = (Math.exp(-im_m) - Math.exp(im_m)) * (0.5 * re);
	} else {
		tmp = Math.sin(re) * 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 = math.pow(im_m, 3.0) * -0.16666666666666666
	tmp = 0
	if im_m <= 0.2:
		tmp = math.sin(re) * (t_0 - im_m)
	elif im_m <= 5.6e+102:
		tmp = (math.exp(-im_m) - math.exp(im_m)) * (0.5 * re)
	else:
		tmp = math.sin(re) * 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((im_m ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im_m <= 0.2)
		tmp = Float64(sin(re) * Float64(t_0 - im_m));
	elseif (im_m <= 5.6e+102)
		tmp = Float64(Float64(exp(Float64(-im_m)) - exp(im_m)) * Float64(0.5 * re));
	else
		tmp = Float64(sin(re) * t_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)
	t_0 = (im_m ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im_m <= 0.2)
		tmp = sin(re) * (t_0 - im_m);
	elseif (im_m <= 5.6e+102)
		tmp = (exp(-im_m) - exp(im_m)) * (0.5 * re);
	else
		tmp = sin(re) * t_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_] := Block[{t$95$0 = N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 0.2], N[(N[Sin[re], $MachinePrecision] * N[(t$95$0 - im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 5.6e+102], N[(N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * t$95$0), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

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

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

\mathbf{else}:\\
\;\;\;\;\sin re \cdot t\_0\\


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

    1. Initial program 58.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 87.8%

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

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

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

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

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

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

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

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

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

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

        \[\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--89.7%

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

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

    if 0.20000000000000001 < im < 5.60000000000000037e102

    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 re around 0 77.1%

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

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

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

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

    if 5.60000000000000037e102 < 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 89.9%

      \[\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. associate-*r*89.9%

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

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

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

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

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

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

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

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

    \[\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 5.6 \cdot 10^{+102}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 89.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 440:\\ \;\;\;\;im\_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im\_m \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;\left(-im\_m\right) \cdot {\sin re}^{-3}\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 440.0)
    (* im_m (- (sin re)))
    (if (<= im_m 5.6e+102)
      (* (- im_m) (pow (sin re) -3.0))
      (* (sin re) (* (pow im_m 3.0) -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 (im_m <= 440.0) {
		tmp = im_m * -sin(re);
	} else if (im_m <= 5.6e+102) {
		tmp = -im_m * pow(sin(re), -3.0);
	} else {
		tmp = sin(re) * (pow(im_m, 3.0) * -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 (im_m <= 440.0d0) then
        tmp = im_m * -sin(re)
    else if (im_m <= 5.6d+102) then
        tmp = -im_m * (sin(re) ** (-3.0d0))
    else
        tmp = sin(re) * ((im_m ** 3.0d0) * (-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 (im_m <= 440.0) {
		tmp = im_m * -Math.sin(re);
	} else if (im_m <= 5.6e+102) {
		tmp = -im_m * Math.pow(Math.sin(re), -3.0);
	} else {
		tmp = Math.sin(re) * (Math.pow(im_m, 3.0) * -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 im_m <= 440.0:
		tmp = im_m * -math.sin(re)
	elif im_m <= 5.6e+102:
		tmp = -im_m * math.pow(math.sin(re), -3.0)
	else:
		tmp = math.sin(re) * (math.pow(im_m, 3.0) * -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 (im_m <= 440.0)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif (im_m <= 5.6e+102)
		tmp = Float64(Float64(-im_m) * (sin(re) ^ -3.0));
	else
		tmp = Float64(sin(re) * Float64((im_m ^ 3.0) * -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 (im_m <= 440.0)
		tmp = im_m * -sin(re);
	elseif (im_m <= 5.6e+102)
		tmp = -im_m * (sin(re) ^ -3.0);
	else
		tmp = sin(re) * ((im_m ^ 3.0) * -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[im$95$m, 440.0], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 5.6e+102], N[((-im$95$m) * N[Power[N[Sin[re], $MachinePrecision], -3.0], $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $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 440:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im\_m \leq 5.6 \cdot 10^{+102}:\\
\;\;\;\;\left(-im\_m\right) \cdot {\sin re}^{-3}\\

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


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

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

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

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

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

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

    if 440 < im < 5.60000000000000037e102

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

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

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

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

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

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

    if 5.60000000000000037e102 < 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 89.9%

      \[\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. associate-*r*89.9%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 440:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;\left(-im\right) \cdot {\sin re}^{-3}\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 89.3% accurate, 1.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := {im\_m}^{3} \cdot -0.16666666666666666\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 420:\\ \;\;\;\;\sin re \cdot \left(t\_0 - im\_m\right)\\ \mathbf{elif}\;im\_m \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;\left(-im\_m\right) \cdot {\sin re}^{-3}\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot t\_0\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* (pow im_m 3.0) -0.16666666666666666)))
   (*
    im_s
    (if (<= im_m 420.0)
      (* (sin re) (- t_0 im_m))
      (if (<= im_m 5.6e+102)
        (* (- im_m) (pow (sin re) -3.0))
        (* (sin re) 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 = pow(im_m, 3.0) * -0.16666666666666666;
	double tmp;
	if (im_m <= 420.0) {
		tmp = sin(re) * (t_0 - im_m);
	} else if (im_m <= 5.6e+102) {
		tmp = -im_m * pow(sin(re), -3.0);
	} else {
		tmp = sin(re) * t_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) :: t_0
    real(8) :: tmp
    t_0 = (im_m ** 3.0d0) * (-0.16666666666666666d0)
    if (im_m <= 420.0d0) then
        tmp = sin(re) * (t_0 - im_m)
    else if (im_m <= 5.6d+102) then
        tmp = -im_m * (sin(re) ** (-3.0d0))
    else
        tmp = sin(re) * t_0
    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 t_0 = Math.pow(im_m, 3.0) * -0.16666666666666666;
	double tmp;
	if (im_m <= 420.0) {
		tmp = Math.sin(re) * (t_0 - im_m);
	} else if (im_m <= 5.6e+102) {
		tmp = -im_m * Math.pow(Math.sin(re), -3.0);
	} else {
		tmp = Math.sin(re) * 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 = math.pow(im_m, 3.0) * -0.16666666666666666
	tmp = 0
	if im_m <= 420.0:
		tmp = math.sin(re) * (t_0 - im_m)
	elif im_m <= 5.6e+102:
		tmp = -im_m * math.pow(math.sin(re), -3.0)
	else:
		tmp = math.sin(re) * 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((im_m ^ 3.0) * -0.16666666666666666)
	tmp = 0.0
	if (im_m <= 420.0)
		tmp = Float64(sin(re) * Float64(t_0 - im_m));
	elseif (im_m <= 5.6e+102)
		tmp = Float64(Float64(-im_m) * (sin(re) ^ -3.0));
	else
		tmp = Float64(sin(re) * t_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)
	t_0 = (im_m ^ 3.0) * -0.16666666666666666;
	tmp = 0.0;
	if (im_m <= 420.0)
		tmp = sin(re) * (t_0 - im_m);
	elseif (im_m <= 5.6e+102)
		tmp = -im_m * (sin(re) ^ -3.0);
	else
		tmp = sin(re) * t_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_] := Block[{t$95$0 = N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 420.0], N[(N[Sin[re], $MachinePrecision] * N[(t$95$0 - im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 5.6e+102], N[((-im$95$m) * N[Power[N[Sin[re], $MachinePrecision], -3.0], $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * t$95$0), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

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

\mathbf{elif}\;im\_m \leq 5.6 \cdot 10^{+102}:\\
\;\;\;\;\left(-im\_m\right) \cdot {\sin re}^{-3}\\

\mathbf{else}:\\
\;\;\;\;\sin re \cdot t\_0\\


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

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

      \[\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. +-commutative86.9%

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

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

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

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

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

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

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

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

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

        \[\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--88.7%

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

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

    if 420 < im < 5.60000000000000037e102

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

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

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

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

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

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

    if 5.60000000000000037e102 < 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 89.9%

      \[\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. associate-*r*89.9%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 420:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;\left(-im\right) \cdot {\sin re}^{-3}\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 76.2% accurate, 2.5× 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.00055:\\ \;\;\;\;im\_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im\_m \leq 1.8 \cdot 10^{+243} \lor \neg \left(im\_m \leq 6.8 \cdot 10^{+259}\right):\\ \;\;\;\;re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(im\_m \cdot \left(0.16666666666666666 \cdot {re}^{2} + -1\right)\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 0.00055)
    (* im_m (- (sin re)))
    (if (or (<= im_m 1.8e+243) (not (<= im_m 6.8e+259)))
      (* re (- (* (pow im_m 3.0) -0.16666666666666666) im_m))
      (* re (* im_m (+ (* 0.16666666666666666 (pow re 2.0)) -1.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.00055) {
		tmp = im_m * -sin(re);
	} else if ((im_m <= 1.8e+243) || !(im_m <= 6.8e+259)) {
		tmp = re * ((pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	} else {
		tmp = re * (im_m * ((0.16666666666666666 * pow(re, 2.0)) + -1.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 <= 0.00055d0) then
        tmp = im_m * -sin(re)
    else if ((im_m <= 1.8d+243) .or. (.not. (im_m <= 6.8d+259))) then
        tmp = re * (((im_m ** 3.0d0) * (-0.16666666666666666d0)) - im_m)
    else
        tmp = re * (im_m * ((0.16666666666666666d0 * (re ** 2.0d0)) + (-1.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 <= 0.00055) {
		tmp = im_m * -Math.sin(re);
	} else if ((im_m <= 1.8e+243) || !(im_m <= 6.8e+259)) {
		tmp = re * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	} else {
		tmp = re * (im_m * ((0.16666666666666666 * Math.pow(re, 2.0)) + -1.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.00055:
		tmp = im_m * -math.sin(re)
	elif (im_m <= 1.8e+243) or not (im_m <= 6.8e+259):
		tmp = re * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m)
	else:
		tmp = re * (im_m * ((0.16666666666666666 * math.pow(re, 2.0)) + -1.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.00055)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif ((im_m <= 1.8e+243) || !(im_m <= 6.8e+259))
		tmp = Float64(re * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - im_m));
	else
		tmp = Float64(re * Float64(im_m * Float64(Float64(0.16666666666666666 * (re ^ 2.0)) + -1.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 <= 0.00055)
		tmp = im_m * -sin(re);
	elseif ((im_m <= 1.8e+243) || ~((im_m <= 6.8e+259)))
		tmp = re * (((im_m ^ 3.0) * -0.16666666666666666) - im_m);
	else
		tmp = re * (im_m * ((0.16666666666666666 * (re ^ 2.0)) + -1.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, 0.00055], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[Or[LessEqual[im$95$m, 1.8e+243], N[Not[LessEqual[im$95$m, 6.8e+259]], $MachinePrecision]], N[(re * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision], N[(re * N[(im$95$m * N[(N[(0.16666666666666666 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision] + -1.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.00055:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im\_m \leq 1.8 \cdot 10^{+243} \lor \neg \left(im\_m \leq 6.8 \cdot 10^{+259}\right):\\
\;\;\;\;re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\

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


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

    1. Initial program 58.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 65.5%

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

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

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

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

    if 5.50000000000000033e-4 < im < 1.7999999999999998e243 or 6.79999999999999979e259 < 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 61.8%

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

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

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

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

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

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

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

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

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

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

        \[\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--68.9%

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

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

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

    if 1.7999999999999998e243 < im < 6.79999999999999979e259

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.00055:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+243} \lor \neg \left(im \leq 6.8 \cdot 10^{+259}\right):\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(im \cdot \left(0.16666666666666666 \cdot {re}^{2} + -1\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 76.2% accurate, 2.5× 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.3:\\ \;\;\;\;im\_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im\_m \leq 1.8 \cdot 10^{+243} \lor \neg \left(im\_m \leq 6.8 \cdot 10^{+259}\right):\\ \;\;\;\;re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\ \mathbf{else}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im\_m \cdot {re}^{3}\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 0.3)
    (* im_m (- (sin re)))
    (if (or (<= im_m 1.8e+243) (not (<= im_m 6.8e+259)))
      (* re (- (* (pow im_m 3.0) -0.16666666666666666) im_m))
      (* 0.16666666666666666 (* im_m (pow re 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 <= 0.3) {
		tmp = im_m * -sin(re);
	} else if ((im_m <= 1.8e+243) || !(im_m <= 6.8e+259)) {
		tmp = re * ((pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	} else {
		tmp = 0.16666666666666666 * (im_m * pow(re, 3.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 <= 0.3d0) then
        tmp = im_m * -sin(re)
    else if ((im_m <= 1.8d+243) .or. (.not. (im_m <= 6.8d+259))) then
        tmp = re * (((im_m ** 3.0d0) * (-0.16666666666666666d0)) - im_m)
    else
        tmp = 0.16666666666666666d0 * (im_m * (re ** 3.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 <= 0.3) {
		tmp = im_m * -Math.sin(re);
	} else if ((im_m <= 1.8e+243) || !(im_m <= 6.8e+259)) {
		tmp = re * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	} else {
		tmp = 0.16666666666666666 * (im_m * Math.pow(re, 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 <= 0.3:
		tmp = im_m * -math.sin(re)
	elif (im_m <= 1.8e+243) or not (im_m <= 6.8e+259):
		tmp = re * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m)
	else:
		tmp = 0.16666666666666666 * (im_m * math.pow(re, 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 <= 0.3)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif ((im_m <= 1.8e+243) || !(im_m <= 6.8e+259))
		tmp = Float64(re * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - im_m));
	else
		tmp = Float64(0.16666666666666666 * Float64(im_m * (re ^ 3.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 <= 0.3)
		tmp = im_m * -sin(re);
	elseif ((im_m <= 1.8e+243) || ~((im_m <= 6.8e+259)))
		tmp = re * (((im_m ^ 3.0) * -0.16666666666666666) - im_m);
	else
		tmp = 0.16666666666666666 * (im_m * (re ^ 3.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, 0.3], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[Or[LessEqual[im$95$m, 1.8e+243], N[Not[LessEqual[im$95$m, 6.8e+259]], $MachinePrecision]], N[(re * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision], N[(0.16666666666666666 * N[(im$95$m * N[Power[re, 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 0.3:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im\_m \leq 1.8 \cdot 10^{+243} \lor \neg \left(im\_m \leq 6.8 \cdot 10^{+259}\right):\\
\;\;\;\;re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\

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


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

    1. Initial program 58.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 65.5%

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

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

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

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

    if 0.299999999999999989 < im < 1.7999999999999998e243 or 6.79999999999999979e259 < 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 61.8%

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

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

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

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

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

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

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

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

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

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

        \[\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--68.9%

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

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

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

    if 1.7999999999999998e243 < im < 6.79999999999999979e259

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.3:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+243} \lor \neg \left(im \leq 6.8 \cdot 10^{+259}\right):\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 59.6% 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 560000000:\\ \;\;\;\;im\_m \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im\_m \cdot {re}^{3}\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 560000000.0)
    (* im_m (- (sin re)))
    (* 0.16666666666666666 (* im_m (pow re 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 <= 560000000.0) {
		tmp = im_m * -sin(re);
	} else {
		tmp = 0.16666666666666666 * (im_m * pow(re, 3.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 <= 560000000.0d0) then
        tmp = im_m * -sin(re)
    else
        tmp = 0.16666666666666666d0 * (im_m * (re ** 3.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 <= 560000000.0) {
		tmp = im_m * -Math.sin(re);
	} else {
		tmp = 0.16666666666666666 * (im_m * Math.pow(re, 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 <= 560000000.0:
		tmp = im_m * -math.sin(re)
	else:
		tmp = 0.16666666666666666 * (im_m * math.pow(re, 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 <= 560000000.0)
		tmp = Float64(im_m * Float64(-sin(re)));
	else
		tmp = Float64(0.16666666666666666 * Float64(im_m * (re ^ 3.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 <= 560000000.0)
		tmp = im_m * -sin(re);
	else
		tmp = 0.16666666666666666 * (im_m * (re ^ 3.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, 560000000.0], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], N[(0.16666666666666666 * N[(im$95$m * N[Power[re, 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 560000000:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

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


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

    1. Initial program 59.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 64.5%

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

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

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

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

    if 5.6e8 < 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.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 560000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 57.3% 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 4.2 \cdot 10^{+44}:\\ \;\;\;\;im\_m \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-im\_m\right) \cdot re\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= im_m 4.2e+44) (* im_m (- (sin re))) (* (- im_m) 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 <= 4.2e+44) {
		tmp = im_m * -sin(re);
	} else {
		tmp = -im_m * re;
	}
	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 <= 4.2d+44) then
        tmp = im_m * -sin(re)
    else
        tmp = -im_m * re
    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 <= 4.2e+44) {
		tmp = im_m * -Math.sin(re);
	} else {
		tmp = -im_m * 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 <= 4.2e+44:
		tmp = im_m * -math.sin(re)
	else:
		tmp = -im_m * 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 <= 4.2e+44)
		tmp = Float64(im_m * Float64(-sin(re)));
	else
		tmp = Float64(Float64(-im_m) * re);
	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 <= 4.2e+44)
		tmp = im_m * -sin(re);
	else
		tmp = -im_m * re;
	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, 4.2e+44], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], 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 \begin{array}{l}
\mathbf{if}\;im\_m \leq 4.2 \cdot 10^{+44}:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

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


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

    1. Initial program 60.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 62.6%

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

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

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

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

    if 4.19999999999999974e44 < 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.5%

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

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

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

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

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

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

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

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

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

Alternative 11: 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 5.2 \cdot 10^{-25}:\\ \;\;\;\;im\_m \cdot 0\\ \mathbf{else}:\\ \;\;\;\;-im\_m\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 5.2e-25) (* 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 <= 5.2e-25) {
		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 <= 5.2d-25) 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 <= 5.2e-25) {
		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 <= 5.2e-25:
		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 <= 5.2e-25)
		tmp = Float64(im_m * 0.0);
	else
		tmp = Float64(-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 <= 5.2e-25)
		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, 5.2e-25], 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 5.2 \cdot 10^{-25}:\\
\;\;\;\;im\_m \cdot 0\\

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


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

    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 79.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. associate-*r*79.0%

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

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

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

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

      \[\leadsto im \cdot \color{blue}{0} \]

    if 5.2e-25 < re

    1. Initial program 59.2%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 88.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. associate-*r*88.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 5.2 \cdot 10^{-25}:\\ \;\;\;\;im \cdot 0\\ \mathbf{else}:\\ \;\;\;\;-im\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 15.5% 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 1250000:\\ \;\;\;\;im\_m \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot 0.3333333333333333\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 1250000.0) (* 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 <= 1250000.0) {
		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 <= 1250000.0d0) 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 <= 1250000.0) {
		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 <= 1250000.0:
		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 <= 1250000.0)
		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 <= 1250000.0)
		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, 1250000.0], 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 1250000:\\
\;\;\;\;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 < 1.25e6

    1. Initial program 73.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 78.8%

      \[\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. associate-*r*78.8%

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(-1 + {im}^{2} \cdot -0.16666666666666666\right)\right)} \]
    6. Applied egg-rr20.8%

      \[\leadsto im \cdot \color{blue}{0} \]

    if 1.25e6 < re

    1. Initial program 57.2%

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

      \[\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. associate-*r*89.1%

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

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

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

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

      \[\leadsto im \cdot \color{blue}{0.3333333333333333} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification17.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1250000:\\ \;\;\;\;im \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im \cdot 0.3333333333333333\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 15.5% 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 1250000:\\ \;\;\;\;im\_m \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot 0.5\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 1250000.0) (* 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 <= 1250000.0) {
		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 <= 1250000.0d0) 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 <= 1250000.0) {
		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 <= 1250000.0:
		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 <= 1250000.0)
		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 <= 1250000.0)
		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, 1250000.0], 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 1250000:\\
\;\;\;\;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 < 1.25e6

    1. Initial program 73.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 78.8%

      \[\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. associate-*r*78.8%

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(-1 + {im}^{2} \cdot -0.16666666666666666\right)\right)} \]
    6. Applied egg-rr20.8%

      \[\leadsto im \cdot \color{blue}{0} \]

    if 1.25e6 < re

    1. Initial program 57.2%

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

      \[\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. associate-*r*89.1%

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

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

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

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

      \[\leadsto im \cdot \color{blue}{0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification17.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1250000:\\ \;\;\;\;im \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 15.6% 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 1250000:\\ \;\;\;\;im\_m \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot 0.75\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= re 1250000.0) (* 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 <= 1250000.0) {
		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 <= 1250000.0d0) 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 <= 1250000.0) {
		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 <= 1250000.0:
		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 <= 1250000.0)
		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 <= 1250000.0)
		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, 1250000.0], 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 1250000:\\
\;\;\;\;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 < 1.25e6

    1. Initial program 73.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 78.8%

      \[\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. associate-*r*78.8%

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

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

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

      \[\leadsto \color{blue}{im \cdot \left(\sin re \cdot \left(-1 + {im}^{2} \cdot -0.16666666666666666\right)\right)} \]
    6. Applied egg-rr20.8%

      \[\leadsto im \cdot \color{blue}{0} \]

    if 1.25e6 < re

    1. Initial program 57.2%

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

      \[\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. associate-*r*89.1%

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

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

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

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

      \[\leadsto im \cdot \color{blue}{0.75} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification17.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1250000:\\ \;\;\;\;im \cdot 0\\ \mathbf{else}:\\ \;\;\;\;im \cdot 0.75\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 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(\left(-im\_m\right) \cdot re\right) \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 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(Float64(-im_m) * 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(\left(-im\_m\right) \cdot re\right)
\end{array}
Derivation
  1. Initial program 69.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 49.4%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(-im\right) \cdot re} \]
  9. Final simplification32.1%

    \[\leadsto \left(-im\right) \cdot re \]
  10. Add Preprocessing

Alternative 16: 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 1 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 69.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 81.3%

    \[\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. associate-*r*81.3%

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

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

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

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

    \[\leadsto im \cdot \color{blue}{-3} \]
  7. Final simplification5.1%

    \[\leadsto im \cdot -3 \]
  8. Add Preprocessing

Alternative 17: 6.2% accurate, 154.0× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \left(-im\_m\right) \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 1 im)
(FPCore (im_s re im_m) :precision binary64 (* im_s (- im_m)))
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;
}
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
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;
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	return im_s * -im_m
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	return Float64(im_s * Float64(-im_m))
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;
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 * (-im$95$m)), $MachinePrecision]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
im\_s \cdot \left(-im\_m\right)
\end{array}
Derivation
  1. Initial program 69.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 81.3%

    \[\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. associate-*r*81.3%

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

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

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

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

    \[\leadsto im \cdot \color{blue}{-1} \]
  7. Final simplification5.6%

    \[\leadsto -im \]
  8. 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 2024055 
(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))))