math.cos on complex, imaginary part

Percentage Accurate: 65.2% → 99.5%
Time: 15.3s
Alternatives: 15
Speedup: 2.7×

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 15 alternatives:

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

Initial Program: 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.5% 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 -1 \cdot 10^{+26}:\\ \;\;\;\;t\_0 \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot \left(-0.008333333333333333 \cdot {im\_m}^{2} - 0.16666666666666666\right) - im\_m\right)\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (- (exp (- im_m)) (exp im_m))))
   (*
    im_s
    (if (<= t_0 -1e+26)
      (* t_0 (* 0.5 (sin re)))
      (*
       (sin re)
       (-
        (*
         (pow im_m 3.0)
         (- (* -0.008333333333333333 (pow im_m 2.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 <= -1e+26) {
		tmp = t_0 * (0.5 * sin(re));
	} else {
		tmp = sin(re) * ((pow(im_m, 3.0) * ((-0.008333333333333333 * pow(im_m, 2.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 <= (-1d+26)) then
        tmp = t_0 * (0.5d0 * sin(re))
    else
        tmp = sin(re) * (((im_m ** 3.0d0) * (((-0.008333333333333333d0) * (im_m ** 2.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 <= -1e+26) {
		tmp = t_0 * (0.5 * Math.sin(re));
	} else {
		tmp = Math.sin(re) * ((Math.pow(im_m, 3.0) * ((-0.008333333333333333 * Math.pow(im_m, 2.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 <= -1e+26:
		tmp = t_0 * (0.5 * math.sin(re))
	else:
		tmp = math.sin(re) * ((math.pow(im_m, 3.0) * ((-0.008333333333333333 * math.pow(im_m, 2.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 <= -1e+26)
		tmp = Float64(t_0 * Float64(0.5 * sin(re)));
	else
		tmp = Float64(sin(re) * Float64(Float64((im_m ^ 3.0) * Float64(Float64(-0.008333333333333333 * (im_m ^ 2.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 <= -1e+26)
		tmp = t_0 * (0.5 * sin(re));
	else
		tmp = sin(re) * (((im_m ^ 3.0) * ((-0.008333333333333333 * (im_m ^ 2.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, -1e+26], 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] * N[(N[(-0.008333333333333333 * N[Power[im$95$m, 2.0], $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $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 -1 \cdot 10^{+26}:\\
\;\;\;\;t\_0 \cdot \left(0.5 \cdot \sin re\right)\\

\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot \left(-0.008333333333333333 \cdot {im\_m}^{2} - 0.16666666666666666\right) - 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)) < -1.00000000000000005e26

    1. Initial program 100.0%

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

    if -1.00000000000000005e26 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 57.9%

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

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

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

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

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + -0.008333333333333333 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \color{blue}{\left(-\sin re\right)} \cdot im \]
      5. cancel-sign-sub-inv89.8%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.4% 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 -1 \cdot 10^{+26}:\\ \;\;\;\;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 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (- (exp (- im_m)) (exp im_m))))
   (*
    im_s
    (if (<= t_0 -1e+26)
      (* 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 <= -1e+26) {
		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 <= (-1d+26)) 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 <= -1e+26) {
		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 <= -1e+26:
		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 <= -1e+26)
		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 <= -1e+26)
		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, -1e+26], 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 -1 \cdot 10^{+26}:\\
\;\;\;\;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)) < -1.00000000000000005e26

    1. Initial program 100.0%

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

    if -1.00000000000000005e26 < (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))

    1. Initial program 57.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{-im} - e^{im} \leq -1 \cdot 10^{+26}:\\ \;\;\;\;\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 3: 91.5% 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 := \mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 10000000:\\ \;\;\;\;im\_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im\_m \leq 3.5 \cdot 10^{+24}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 1.3 \cdot 10^{+44}:\\ \;\;\;\;re \cdot \left(im\_m + -0.16666666666666666 \cdot \left(im\_m \cdot {re}^{2}\right)\right)\\ \mathbf{elif}\;im\_m \leq 4.5 \cdot 10^{+51}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im\_m}^{5}\right)\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (log1p (expm1 re))))
   (*
    im_s
    (if (<= im_m 10000000.0)
      (* im_m (- (sin re)))
      (if (<= im_m 3.5e+24)
        t_0
        (if (<= im_m 1.3e+44)
          (* re (+ im_m (* -0.16666666666666666 (* im_m (pow re 2.0)))))
          (if (<= im_m 4.5e+51)
            t_0
            (* -0.008333333333333333 (* (sin re) (pow im_m 5.0))))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = log1p(expm1(re));
	double tmp;
	if (im_m <= 10000000.0) {
		tmp = im_m * -sin(re);
	} else if (im_m <= 3.5e+24) {
		tmp = t_0;
	} else if (im_m <= 1.3e+44) {
		tmp = re * (im_m + (-0.16666666666666666 * (im_m * pow(re, 2.0))));
	} else if (im_m <= 4.5e+51) {
		tmp = t_0;
	} else {
		tmp = -0.008333333333333333 * (sin(re) * pow(im_m, 5.0));
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = Math.log1p(Math.expm1(re));
	double tmp;
	if (im_m <= 10000000.0) {
		tmp = im_m * -Math.sin(re);
	} else if (im_m <= 3.5e+24) {
		tmp = t_0;
	} else if (im_m <= 1.3e+44) {
		tmp = re * (im_m + (-0.16666666666666666 * (im_m * Math.pow(re, 2.0))));
	} else if (im_m <= 4.5e+51) {
		tmp = t_0;
	} else {
		tmp = -0.008333333333333333 * (Math.sin(re) * Math.pow(im_m, 5.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.log1p(math.expm1(re))
	tmp = 0
	if im_m <= 10000000.0:
		tmp = im_m * -math.sin(re)
	elif im_m <= 3.5e+24:
		tmp = t_0
	elif im_m <= 1.3e+44:
		tmp = re * (im_m + (-0.16666666666666666 * (im_m * math.pow(re, 2.0))))
	elif im_m <= 4.5e+51:
		tmp = t_0
	else:
		tmp = -0.008333333333333333 * (math.sin(re) * math.pow(im_m, 5.0))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = log1p(expm1(re))
	tmp = 0.0
	if (im_m <= 10000000.0)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif (im_m <= 3.5e+24)
		tmp = t_0;
	elseif (im_m <= 1.3e+44)
		tmp = Float64(re * Float64(im_m + Float64(-0.16666666666666666 * Float64(im_m * (re ^ 2.0)))));
	elseif (im_m <= 4.5e+51)
		tmp = t_0;
	else
		tmp = Float64(-0.008333333333333333 * Float64(sin(re) * (im_m ^ 5.0)));
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 10000000.0], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 3.5e+24], t$95$0, If[LessEqual[im$95$m, 1.3e+44], N[(re * N[(im$95$m + N[(-0.16666666666666666 * N[(im$95$m * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 4.5e+51], t$95$0, N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 10000000:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

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

\mathbf{elif}\;im\_m \leq 1.3 \cdot 10^{+44}:\\
\;\;\;\;re \cdot \left(im\_m + -0.16666666666666666 \cdot \left(im\_m \cdot {re}^{2}\right)\right)\\

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

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


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

    1. Initial program 58.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 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 1e7 < im < 3.5000000000000002e24 or 1.3e44 < im < 4.5e51

    1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]

    if 3.5000000000000002e24 < im < 1.3e44

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(\sin re \cdot \left(-im\right)\right)}}^{1} \]
      3. add-sqr-sqrt0.0%

        \[\leadsto {\left(\sin re \cdot \color{blue}{\left(\sqrt{-im} \cdot \sqrt{-im}\right)}\right)}^{1} \]
      4. sqrt-unprod0.6%

        \[\leadsto {\left(\sin re \cdot \color{blue}{\sqrt{\left(-im\right) \cdot \left(-im\right)}}\right)}^{1} \]
      5. sqr-neg0.6%

        \[\leadsto {\left(\sin re \cdot \sqrt{\color{blue}{im \cdot im}}\right)}^{1} \]
      6. sqrt-prod0.6%

        \[\leadsto {\left(\sin re \cdot \color{blue}{\left(\sqrt{im} \cdot \sqrt{im}\right)}\right)}^{1} \]
      7. add-sqr-sqrt0.6%

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

      \[\leadsto \color{blue}{{\left(\sin re \cdot im\right)}^{1}} \]
    8. Step-by-step derivation
      1. unpow10.6%

        \[\leadsto \color{blue}{\sin re \cdot im} \]
      2. *-commutative0.6%

        \[\leadsto \color{blue}{im \cdot \sin re} \]
    9. Simplified0.6%

      \[\leadsto \color{blue}{im \cdot \sin re} \]
    10. Taylor expanded in re around 0 55.0%

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

    if 4.5e51 < im

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + -0.008333333333333333 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \color{blue}{\left(-\sin re\right)} \cdot im \]
      5. cancel-sign-sub-inv90.3%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 10000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 3.5 \cdot 10^{+24}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 1.3 \cdot 10^{+44}:\\ \;\;\;\;re \cdot \left(im + -0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right)\\ \mathbf{elif}\;im \leq 4.5 \cdot 10^{+51}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 91.9% 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 := \mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 10000000:\\ \;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\ \mathbf{elif}\;im\_m \leq 6.1 \cdot 10^{+28}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 2.4 \cdot 10^{+44}:\\ \;\;\;\;re \cdot \left(im\_m + -0.16666666666666666 \cdot \left(im\_m \cdot {re}^{2}\right)\right)\\ \mathbf{elif}\;im\_m \leq 4.5 \cdot 10^{+51}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im\_m}^{5}\right)\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (log1p (expm1 re))))
   (*
    im_s
    (if (<= im_m 10000000.0)
      (* (sin re) (- (* (pow im_m 3.0) -0.16666666666666666) im_m))
      (if (<= im_m 6.1e+28)
        t_0
        (if (<= im_m 2.4e+44)
          (* re (+ im_m (* -0.16666666666666666 (* im_m (pow re 2.0)))))
          (if (<= im_m 4.5e+51)
            t_0
            (* -0.008333333333333333 (* (sin re) (pow im_m 5.0))))))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = log1p(expm1(re));
	double tmp;
	if (im_m <= 10000000.0) {
		tmp = sin(re) * ((pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	} else if (im_m <= 6.1e+28) {
		tmp = t_0;
	} else if (im_m <= 2.4e+44) {
		tmp = re * (im_m + (-0.16666666666666666 * (im_m * pow(re, 2.0))));
	} else if (im_m <= 4.5e+51) {
		tmp = t_0;
	} else {
		tmp = -0.008333333333333333 * (sin(re) * pow(im_m, 5.0));
	}
	return im_s * tmp;
}
im\_m = Math.abs(im);
im\_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double t_0 = Math.log1p(Math.expm1(re));
	double tmp;
	if (im_m <= 10000000.0) {
		tmp = Math.sin(re) * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	} else if (im_m <= 6.1e+28) {
		tmp = t_0;
	} else if (im_m <= 2.4e+44) {
		tmp = re * (im_m + (-0.16666666666666666 * (im_m * Math.pow(re, 2.0))));
	} else if (im_m <= 4.5e+51) {
		tmp = t_0;
	} else {
		tmp = -0.008333333333333333 * (Math.sin(re) * Math.pow(im_m, 5.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.log1p(math.expm1(re))
	tmp = 0
	if im_m <= 10000000.0:
		tmp = math.sin(re) * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m)
	elif im_m <= 6.1e+28:
		tmp = t_0
	elif im_m <= 2.4e+44:
		tmp = re * (im_m + (-0.16666666666666666 * (im_m * math.pow(re, 2.0))))
	elif im_m <= 4.5e+51:
		tmp = t_0
	else:
		tmp = -0.008333333333333333 * (math.sin(re) * math.pow(im_m, 5.0))
	return im_s * tmp
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = log1p(expm1(re))
	tmp = 0.0
	if (im_m <= 10000000.0)
		tmp = Float64(sin(re) * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - im_m));
	elseif (im_m <= 6.1e+28)
		tmp = t_0;
	elseif (im_m <= 2.4e+44)
		tmp = Float64(re * Float64(im_m + Float64(-0.16666666666666666 * Float64(im_m * (re ^ 2.0)))));
	elseif (im_m <= 4.5e+51)
		tmp = t_0;
	else
		tmp = Float64(-0.008333333333333333 * Float64(sin(re) * (im_m ^ 5.0)));
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 10000000.0], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 6.1e+28], t$95$0, If[LessEqual[im$95$m, 2.4e+44], N[(re * N[(im$95$m + N[(-0.16666666666666666 * N[(im$95$m * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 4.5e+51], t$95$0, N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 10000000:\\
\;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\

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

\mathbf{elif}\;im\_m \leq 2.4 \cdot 10^{+44}:\\
\;\;\;\;re \cdot \left(im\_m + -0.16666666666666666 \cdot \left(im\_m \cdot {re}^{2}\right)\right)\\

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

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


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

    1. Initial program 58.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e7 < im < 6.1000000000000002e28 or 2.40000000000000013e44 < im < 4.5e51

    1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]

    if 6.1000000000000002e28 < im < 2.40000000000000013e44

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(\sin re \cdot \left(-im\right)\right)}}^{1} \]
      3. add-sqr-sqrt0.0%

        \[\leadsto {\left(\sin re \cdot \color{blue}{\left(\sqrt{-im} \cdot \sqrt{-im}\right)}\right)}^{1} \]
      4. sqrt-unprod0.6%

        \[\leadsto {\left(\sin re \cdot \color{blue}{\sqrt{\left(-im\right) \cdot \left(-im\right)}}\right)}^{1} \]
      5. sqr-neg0.6%

        \[\leadsto {\left(\sin re \cdot \sqrt{\color{blue}{im \cdot im}}\right)}^{1} \]
      6. sqrt-prod0.6%

        \[\leadsto {\left(\sin re \cdot \color{blue}{\left(\sqrt{im} \cdot \sqrt{im}\right)}\right)}^{1} \]
      7. add-sqr-sqrt0.6%

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

      \[\leadsto \color{blue}{{\left(\sin re \cdot im\right)}^{1}} \]
    8. Step-by-step derivation
      1. unpow10.6%

        \[\leadsto \color{blue}{\sin re \cdot im} \]
      2. *-commutative0.6%

        \[\leadsto \color{blue}{im \cdot \sin re} \]
    9. Simplified0.6%

      \[\leadsto \color{blue}{im \cdot \sin re} \]
    10. Taylor expanded in re around 0 55.0%

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

    if 4.5e51 < im

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + -0.008333333333333333 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \color{blue}{\left(-\sin re\right)} \cdot im \]
      5. cancel-sign-sub-inv90.3%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 10000000:\\ \;\;\;\;\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \mathbf{elif}\;im \leq 6.1 \cdot 10^{+28}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 2.4 \cdot 10^{+44}:\\ \;\;\;\;re \cdot \left(im + -0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right)\\ \mathbf{elif}\;im \leq 4.5 \cdot 10^{+51}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im}^{5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 79.1% 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 := \mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 10000000:\\ \;\;\;\;im\_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im\_m \leq 6.5 \cdot 10^{+25}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 2.75 \cdot 10^{+45}:\\ \;\;\;\;re \cdot \left(im\_m + -0.16666666666666666 \cdot \left(im\_m \cdot {re}^{2}\right)\right)\\ \mathbf{elif}\;im\_m \leq 1.02 \cdot 10^{+90}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;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 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (log1p (expm1 re))))
   (*
    im_s
    (if (<= im_m 10000000.0)
      (* im_m (- (sin re)))
      (if (<= im_m 6.5e+25)
        t_0
        (if (<= im_m 2.75e+45)
          (* re (+ im_m (* -0.16666666666666666 (* im_m (pow re 2.0)))))
          (if (<= im_m 1.02e+90)
            t_0
            (* 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 = log1p(expm1(re));
	double tmp;
	if (im_m <= 10000000.0) {
		tmp = im_m * -sin(re);
	} else if (im_m <= 6.5e+25) {
		tmp = t_0;
	} else if (im_m <= 2.75e+45) {
		tmp = re * (im_m + (-0.16666666666666666 * (im_m * pow(re, 2.0))));
	} else if (im_m <= 1.02e+90) {
		tmp = t_0;
	} 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 t_0 = Math.log1p(Math.expm1(re));
	double tmp;
	if (im_m <= 10000000.0) {
		tmp = im_m * -Math.sin(re);
	} else if (im_m <= 6.5e+25) {
		tmp = t_0;
	} else if (im_m <= 2.75e+45) {
		tmp = re * (im_m + (-0.16666666666666666 * (im_m * Math.pow(re, 2.0))));
	} else if (im_m <= 1.02e+90) {
		tmp = t_0;
	} 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):
	t_0 = math.log1p(math.expm1(re))
	tmp = 0
	if im_m <= 10000000.0:
		tmp = im_m * -math.sin(re)
	elif im_m <= 6.5e+25:
		tmp = t_0
	elif im_m <= 2.75e+45:
		tmp = re * (im_m + (-0.16666666666666666 * (im_m * math.pow(re, 2.0))))
	elif im_m <= 1.02e+90:
		tmp = t_0
	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)
	t_0 = log1p(expm1(re))
	tmp = 0.0
	if (im_m <= 10000000.0)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif (im_m <= 6.5e+25)
		tmp = t_0;
	elseif (im_m <= 2.75e+45)
		tmp = Float64(re * Float64(im_m + Float64(-0.16666666666666666 * Float64(im_m * (re ^ 2.0)))));
	elseif (im_m <= 1.02e+90)
		tmp = t_0;
	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_] := Block[{t$95$0 = N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 10000000.0], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 6.5e+25], t$95$0, If[LessEqual[im$95$m, 2.75e+45], N[(re * N[(im$95$m + N[(-0.16666666666666666 * N[(im$95$m * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 1.02e+90], t$95$0, 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)

\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;im\_m \leq 10000000:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

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

\mathbf{elif}\;im\_m \leq 2.75 \cdot 10^{+45}:\\
\;\;\;\;re \cdot \left(im\_m + -0.16666666666666666 \cdot \left(im\_m \cdot {re}^{2}\right)\right)\\

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

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


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

    1. Initial program 58.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 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 1e7 < im < 6.50000000000000005e25 or 2.75e45 < im < 1.02000000000000005e90

    1. Initial program 100.0%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]

    if 6.50000000000000005e25 < im < 2.75e45

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(\sin re \cdot \left(-im\right)\right)}}^{1} \]
      3. add-sqr-sqrt0.0%

        \[\leadsto {\left(\sin re \cdot \color{blue}{\left(\sqrt{-im} \cdot \sqrt{-im}\right)}\right)}^{1} \]
      4. sqrt-unprod0.6%

        \[\leadsto {\left(\sin re \cdot \color{blue}{\sqrt{\left(-im\right) \cdot \left(-im\right)}}\right)}^{1} \]
      5. sqr-neg0.6%

        \[\leadsto {\left(\sin re \cdot \sqrt{\color{blue}{im \cdot im}}\right)}^{1} \]
      6. sqrt-prod0.6%

        \[\leadsto {\left(\sin re \cdot \color{blue}{\left(\sqrt{im} \cdot \sqrt{im}\right)}\right)}^{1} \]
      7. add-sqr-sqrt0.6%

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

      \[\leadsto \color{blue}{{\left(\sin re \cdot im\right)}^{1}} \]
    8. Step-by-step derivation
      1. unpow10.6%

        \[\leadsto \color{blue}{\sin re \cdot im} \]
      2. *-commutative0.6%

        \[\leadsto \color{blue}{im \cdot \sin re} \]
    9. Simplified0.6%

      \[\leadsto \color{blue}{im \cdot \sin re} \]
    10. Taylor expanded in re around 0 55.0%

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

    if 1.02000000000000005e90 < 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 88.6%

      \[\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. +-commutative88.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(-0.16666666666666666 \cdot {im}^{2}\right) - im\right)} \]
      12. unsub-neg98.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 10000000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+25}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 2.75 \cdot 10^{+45}:\\ \;\;\;\;re \cdot \left(im + -0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right)\right)\\ \mathbf{elif}\;im \leq 1.02 \cdot 10^{+90}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 97.0% accurate, 1.4× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 0.051:\\ \;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\ \mathbf{elif}\;im\_m \leq 4.5 \cdot 10^{+61}:\\ \;\;\;\;\left(e^{-im\_m} - e^{im\_m}\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;-0.008333333333333333 \cdot \left(\sin re \cdot {im\_m}^{5}\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 0.051)
    (* (sin re) (- (* (pow im_m 3.0) -0.16666666666666666) im_m))
    (if (<= im_m 4.5e+61)
      (* (- (exp (- im_m)) (exp im_m)) (* 0.5 re))
      (* -0.008333333333333333 (* (sin re) (pow im_m 5.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.051) {
		tmp = sin(re) * ((pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	} else if (im_m <= 4.5e+61) {
		tmp = (exp(-im_m) - exp(im_m)) * (0.5 * re);
	} else {
		tmp = -0.008333333333333333 * (sin(re) * pow(im_m, 5.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.051d0) then
        tmp = sin(re) * (((im_m ** 3.0d0) * (-0.16666666666666666d0)) - im_m)
    else if (im_m <= 4.5d+61) then
        tmp = (exp(-im_m) - exp(im_m)) * (0.5d0 * re)
    else
        tmp = (-0.008333333333333333d0) * (sin(re) * (im_m ** 5.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.051) {
		tmp = Math.sin(re) * ((Math.pow(im_m, 3.0) * -0.16666666666666666) - im_m);
	} else if (im_m <= 4.5e+61) {
		tmp = (Math.exp(-im_m) - Math.exp(im_m)) * (0.5 * re);
	} else {
		tmp = -0.008333333333333333 * (Math.sin(re) * Math.pow(im_m, 5.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.051:
		tmp = math.sin(re) * ((math.pow(im_m, 3.0) * -0.16666666666666666) - im_m)
	elif im_m <= 4.5e+61:
		tmp = (math.exp(-im_m) - math.exp(im_m)) * (0.5 * re)
	else:
		tmp = -0.008333333333333333 * (math.sin(re) * math.pow(im_m, 5.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.051)
		tmp = Float64(sin(re) * Float64(Float64((im_m ^ 3.0) * -0.16666666666666666) - im_m));
	elseif (im_m <= 4.5e+61)
		tmp = Float64(Float64(exp(Float64(-im_m)) - exp(im_m)) * Float64(0.5 * re));
	else
		tmp = Float64(-0.008333333333333333 * Float64(sin(re) * (im_m ^ 5.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.051)
		tmp = sin(re) * (((im_m ^ 3.0) * -0.16666666666666666) - im_m);
	elseif (im_m <= 4.5e+61)
		tmp = (exp(-im_m) - exp(im_m)) * (0.5 * re);
	else
		tmp = -0.008333333333333333 * (sin(re) * (im_m ^ 5.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.051], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[Power[im$95$m, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 4.5e+61], N[(N[(N[Exp[(-im$95$m)], $MachinePrecision] - N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(-0.008333333333333333 * N[(N[Sin[re], $MachinePrecision] * N[Power[im$95$m, 5.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.051:\\
\;\;\;\;\sin re \cdot \left({im\_m}^{3} \cdot -0.16666666666666666 - im\_m\right)\\

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

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


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

    1. Initial program 57.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0509999999999999967 < im < 4.5e61

    1. Initial program 100.0%

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

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

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

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

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

    if 4.5e61 < 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 95.0%

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

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

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

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

        \[\leadsto im \cdot \left({im}^{2} \cdot \left(-0.16666666666666666 \cdot \sin re + -0.008333333333333333 \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) + \color{blue}{\left(-\sin re\right)} \cdot im \]
      5. cancel-sign-sub-inv95.0%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 64.2% accurate, 2.6× 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 13200000:\\ \;\;\;\;im\_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im\_m \leq 3.8 \cdot 10^{+98}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im\_m \cdot {re}^{3}\right)\\ \mathbf{elif}\;im\_m \leq 1.12 \cdot 10^{+282}:\\ \;\;\;\;im\_m \cdot \frac{-2.4}{\sin re}\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \left(-re\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 13200000.0)
    (* im_m (- (sin re)))
    (if (<= im_m 3.8e+98)
      (* 0.16666666666666666 (* im_m (pow re 3.0)))
      (if (<= im_m 1.12e+282) (* im_m (/ -2.4 (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 <= 13200000.0) {
		tmp = im_m * -sin(re);
	} else if (im_m <= 3.8e+98) {
		tmp = 0.16666666666666666 * (im_m * pow(re, 3.0));
	} else if (im_m <= 1.12e+282) {
		tmp = im_m * (-2.4 / 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 <= 13200000.0d0) then
        tmp = im_m * -sin(re)
    else if (im_m <= 3.8d+98) then
        tmp = 0.16666666666666666d0 * (im_m * (re ** 3.0d0))
    else if (im_m <= 1.12d+282) then
        tmp = im_m * ((-2.4d0) / 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 <= 13200000.0) {
		tmp = im_m * -Math.sin(re);
	} else if (im_m <= 3.8e+98) {
		tmp = 0.16666666666666666 * (im_m * Math.pow(re, 3.0));
	} else if (im_m <= 1.12e+282) {
		tmp = im_m * (-2.4 / 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 <= 13200000.0:
		tmp = im_m * -math.sin(re)
	elif im_m <= 3.8e+98:
		tmp = 0.16666666666666666 * (im_m * math.pow(re, 3.0))
	elif im_m <= 1.12e+282:
		tmp = im_m * (-2.4 / 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 <= 13200000.0)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif (im_m <= 3.8e+98)
		tmp = Float64(0.16666666666666666 * Float64(im_m * (re ^ 3.0)));
	elseif (im_m <= 1.12e+282)
		tmp = Float64(im_m * Float64(-2.4 / sin(re)));
	else
		tmp = Float64(im_m * Float64(-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 <= 13200000.0)
		tmp = im_m * -sin(re);
	elseif (im_m <= 3.8e+98)
		tmp = 0.16666666666666666 * (im_m * (re ^ 3.0));
	elseif (im_m <= 1.12e+282)
		tmp = im_m * (-2.4 / 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, 13200000.0], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 3.8e+98], N[(0.16666666666666666 * N[(im$95$m * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 1.12e+282], N[(im$95$m * N[(-2.4 / N[Sin[re], $MachinePrecision]), $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 13200000:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im\_m \leq 3.8 \cdot 10^{+98}:\\
\;\;\;\;0.16666666666666666 \cdot \left(im\_m \cdot {re}^{3}\right)\\

\mathbf{elif}\;im\_m \leq 1.12 \cdot 10^{+282}:\\
\;\;\;\;im\_m \cdot \frac{-2.4}{\sin re}\\

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


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

    1. Initial program 58.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 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 1.32e7 < im < 3.7999999999999999e98

    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. Taylor expanded in re around 0 19.5%

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

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

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

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

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

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

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

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

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

    if 3.7999999999999999e98 < im < 1.12e282

    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 88.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*88.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-out88.0%

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

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

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

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

        \[\leadsto im \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \color{blue}{\left({im}^{2} \cdot -0.16666666666666666 + -1\right)}\right)\right) \]
      3. fma-define95.1%

        \[\leadsto im \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \color{blue}{\mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)}\right)\right) \]
    7. Applied egg-rr95.1%

      \[\leadsto im \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    8. Step-by-step derivation
      1. add-cbrt-cube95.1%

        \[\leadsto im \cdot \mathsf{log1p}\left(\color{blue}{\sqrt[3]{\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right) \cdot \mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right) \cdot \mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)}}\right) \]
      2. pow395.1%

        \[\leadsto im \cdot \mathsf{log1p}\left(\sqrt[3]{\color{blue}{{\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)}^{3}}}\right) \]
    9. Applied egg-rr95.1%

      \[\leadsto im \cdot \mathsf{log1p}\left(\color{blue}{\sqrt[3]{{\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)}^{3}}}\right) \]
    10. Applied egg-rr32.2%

      \[\leadsto im \cdot \color{blue}{\frac{-2}{0.8333333333333334 \cdot \sin re}} \]
    11. Step-by-step derivation
      1. associate-/r*32.2%

        \[\leadsto im \cdot \color{blue}{\frac{\frac{-2}{0.8333333333333334}}{\sin re}} \]
      2. metadata-eval32.2%

        \[\leadsto im \cdot \frac{\color{blue}{-2.4}}{\sin re} \]
    12. Simplified32.2%

      \[\leadsto im \cdot \color{blue}{\frac{-2.4}{\sin re}} \]

    if 1.12e282 < 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 10.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 13200000:\\ \;\;\;\;im \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im \leq 3.8 \cdot 10^{+98}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\ \mathbf{elif}\;im \leq 1.12 \cdot 10^{+282}:\\ \;\;\;\;im \cdot \frac{-2.4}{\sin re}\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-re\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 63.3% accurate, 2.7× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 280:\\ \;\;\;\;im\_m \cdot \left(-\sin re\right)\\ \mathbf{elif}\;im\_m \leq 9.2 \cdot 10^{+281}:\\ \;\;\;\;im\_m \cdot \frac{-2.4}{\sin re}\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \left(-re\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 280.0)
    (* im_m (- (sin re)))
    (if (<= im_m 9.2e+281) (* im_m (/ -2.4 (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 <= 280.0) {
		tmp = im_m * -sin(re);
	} else if (im_m <= 9.2e+281) {
		tmp = im_m * (-2.4 / 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 <= 280.0d0) then
        tmp = im_m * -sin(re)
    else if (im_m <= 9.2d+281) then
        tmp = im_m * ((-2.4d0) / 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 <= 280.0) {
		tmp = im_m * -Math.sin(re);
	} else if (im_m <= 9.2e+281) {
		tmp = im_m * (-2.4 / 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 <= 280.0:
		tmp = im_m * -math.sin(re)
	elif im_m <= 9.2e+281:
		tmp = im_m * (-2.4 / 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 <= 280.0)
		tmp = Float64(im_m * Float64(-sin(re)));
	elseif (im_m <= 9.2e+281)
		tmp = Float64(im_m * Float64(-2.4 / sin(re)));
	else
		tmp = Float64(im_m * Float64(-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 <= 280.0)
		tmp = im_m * -sin(re);
	elseif (im_m <= 9.2e+281)
		tmp = im_m * (-2.4 / 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, 280.0], N[(im$95$m * (-N[Sin[re], $MachinePrecision])), $MachinePrecision], If[LessEqual[im$95$m, 9.2e+281], N[(im$95$m * N[(-2.4 / N[Sin[re], $MachinePrecision]), $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 280:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

\mathbf{elif}\;im\_m \leq 9.2 \cdot 10^{+281}:\\
\;\;\;\;im\_m \cdot \frac{-2.4}{\sin re}\\

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


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

    1. Initial program 58.1%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 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 280 < im < 9.2000000000000003e281

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

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

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

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

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

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

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

        \[\leadsto im \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \color{blue}{\left({im}^{2} \cdot -0.16666666666666666 + -1\right)}\right)\right) \]
      3. fma-define91.4%

        \[\leadsto im \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \color{blue}{\mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)}\right)\right) \]
    7. Applied egg-rr91.4%

      \[\leadsto im \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
    8. Step-by-step derivation
      1. add-cbrt-cube91.3%

        \[\leadsto im \cdot \mathsf{log1p}\left(\color{blue}{\sqrt[3]{\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right) \cdot \mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right) \cdot \mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)}}\right) \]
      2. pow391.3%

        \[\leadsto im \cdot \mathsf{log1p}\left(\sqrt[3]{\color{blue}{{\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)}^{3}}}\right) \]
    9. Applied egg-rr91.3%

      \[\leadsto im \cdot \mathsf{log1p}\left(\color{blue}{\sqrt[3]{{\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)}^{3}}}\right) \]
    10. Applied egg-rr23.8%

      \[\leadsto im \cdot \color{blue}{\frac{-2}{0.8333333333333334 \cdot \sin re}} \]
    11. Step-by-step derivation
      1. associate-/r*23.8%

        \[\leadsto im \cdot \color{blue}{\frac{\frac{-2}{0.8333333333333334}}{\sin re}} \]
      2. metadata-eval23.8%

        \[\leadsto im \cdot \frac{\color{blue}{-2.4}}{\sin re} \]
    12. Simplified23.8%

      \[\leadsto im \cdot \color{blue}{\frac{-2.4}{\sin re}} \]

    if 9.2000000000000003e281 < 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 10.4%

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

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

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

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

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

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

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

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

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

Alternative 9: 77.4% accurate, 2.7× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 0.00068:\\ \;\;\;\;im\_m \cdot \left(-\sin re\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 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 0.00068)
    (* im_m (- (sin re)))
    (* 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 <= 0.00068) {
		tmp = im_m * -sin(re);
	} else {
		tmp = 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) :: tmp
    if (im_m <= 0.00068d0) then
        tmp = im_m * -sin(re)
    else
        tmp = 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 tmp;
	if (im_m <= 0.00068) {
		tmp = im_m * -Math.sin(re);
	} 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 <= 0.00068:
		tmp = im_m * -math.sin(re)
	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 <= 0.00068)
		tmp = Float64(im_m * Float64(-sin(re)));
	else
		tmp = Float64(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)
	tmp = 0.0;
	if (im_m <= 0.00068)
		tmp = im_m * -sin(re);
	else
		tmp = 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_] := N[(im$95$s * If[LessEqual[im$95$m, 0.00068], N[(im$95$m * (-N[Sin[re], $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 0.00068:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

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


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

    1. Initial program 57.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 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 6.8e-4 < 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 67.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. +-commutative67.0%

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \color{blue}{\left(\left(-0.16666666666666666 \cdot {im}^{2}\right) \cdot \sin re\right)} - im \cdot \sin re \]
      10. associate-*r*74.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--74.0%

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

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

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

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

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

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

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

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

Alternative 10: 33.9% 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}\;\sin re \leq -0.001:\\ \;\;\;\;im\_m \cdot re\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \left(-re\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= (sin re) -0.001) (* im_m 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 (sin(re) <= -0.001) {
		tmp = im_m * 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 (sin(re) <= (-0.001d0)) then
        tmp = im_m * 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 (Math.sin(re) <= -0.001) {
		tmp = im_m * 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 math.sin(re) <= -0.001:
		tmp = im_m * 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 (sin(re) <= -0.001)
		tmp = Float64(im_m * re);
	else
		tmp = Float64(im_m * Float64(-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 (sin(re) <= -0.001)
		tmp = im_m * 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[N[Sin[re], $MachinePrecision], -0.001], N[(im$95$m * re), $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}\;\sin re \leq -0.001:\\
\;\;\;\;im\_m \cdot re\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sin.f64 re) < -1e-3

    1. Initial program 63.1%

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(\sin re \cdot \left(-im\right)\right)}}^{1} \]
      3. add-sqr-sqrt21.1%

        \[\leadsto {\left(\sin re \cdot \color{blue}{\left(\sqrt{-im} \cdot \sqrt{-im}\right)}\right)}^{1} \]
      4. sqrt-unprod23.7%

        \[\leadsto {\left(\sin re \cdot \color{blue}{\sqrt{\left(-im\right) \cdot \left(-im\right)}}\right)}^{1} \]
      5. sqr-neg23.7%

        \[\leadsto {\left(\sin re \cdot \sqrt{\color{blue}{im \cdot im}}\right)}^{1} \]
      6. sqrt-prod0.9%

        \[\leadsto {\left(\sin re \cdot \color{blue}{\left(\sqrt{im} \cdot \sqrt{im}\right)}\right)}^{1} \]
      7. add-sqr-sqrt1.6%

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

      \[\leadsto \color{blue}{{\left(\sin re \cdot im\right)}^{1}} \]
    8. Step-by-step derivation
      1. unpow11.6%

        \[\leadsto \color{blue}{\sin re \cdot im} \]
      2. *-commutative1.6%

        \[\leadsto \color{blue}{im \cdot \sin re} \]
    9. Simplified1.6%

      \[\leadsto \color{blue}{im \cdot \sin re} \]
    10. Taylor expanded in re around 0 10.6%

      \[\leadsto \color{blue}{im \cdot re} \]
    11. Step-by-step derivation
      1. *-commutative10.6%

        \[\leadsto \color{blue}{re \cdot im} \]
    12. Simplified10.6%

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

    if -1e-3 < (sin.f64 re)

    1. Initial program 70.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 51.0%

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

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

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

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

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

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

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

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

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

Alternative 11: 57.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 60:\\ \;\;\;\;im\_m \cdot \left(-\sin re\right)\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \left(-re\right)\\ \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (* im_s (if (<= im_m 60.0) (* 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 <= 60.0) {
		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 <= 60.0d0) 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 <= 60.0) {
		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 <= 60.0:
		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 <= 60.0)
		tmp = Float64(im_m * Float64(-sin(re)));
	else
		tmp = Float64(im_m * Float64(-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 <= 60.0)
		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, 60.0], 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 60:\\
\;\;\;\;im\_m \cdot \left(-\sin re\right)\\

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


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

    1. Initial program 57.9%

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

Alternative 12: 5.5% accurate, 102.7× speedup?

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

\\
im\_s \cdot \left(im\_m \cdot -2.5\right)
\end{array}
Derivation
  1. Initial program 68.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 80.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*80.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-out80.1%

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

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

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

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

      \[\leadsto im \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \color{blue}{\left({im}^{2} \cdot -0.16666666666666666 + -1\right)}\right)\right) \]
    3. fma-define94.2%

      \[\leadsto im \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \color{blue}{\mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)}\right)\right) \]
  7. Applied egg-rr94.2%

    \[\leadsto im \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
  8. Step-by-step derivation
    1. add-cbrt-cube89.8%

      \[\leadsto im \cdot \mathsf{log1p}\left(\color{blue}{\sqrt[3]{\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right) \cdot \mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right) \cdot \mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)}}\right) \]
    2. pow389.8%

      \[\leadsto im \cdot \mathsf{log1p}\left(\sqrt[3]{\color{blue}{{\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)}^{3}}}\right) \]
  9. Applied egg-rr89.8%

    \[\leadsto im \cdot \mathsf{log1p}\left(\color{blue}{\sqrt[3]{{\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)}^{3}}}\right) \]
  10. Applied egg-rr5.9%

    \[\leadsto im \cdot \color{blue}{\left(\left(0.8333333333333334 \cdot \sin re\right) \cdot \frac{-2}{-0.16666666666666666 \cdot \sin re + 0.8333333333333334 \cdot \sin re}\right)} \]
  11. Step-by-step derivation
    1. associate-*r/5.9%

      \[\leadsto im \cdot \color{blue}{\frac{\left(0.8333333333333334 \cdot \sin re\right) \cdot -2}{-0.16666666666666666 \cdot \sin re + 0.8333333333333334 \cdot \sin re}} \]
    2. *-commutative5.9%

      \[\leadsto im \cdot \frac{\color{blue}{-2 \cdot \left(0.8333333333333334 \cdot \sin re\right)}}{-0.16666666666666666 \cdot \sin re + 0.8333333333333334 \cdot \sin re} \]
    3. associate-/l*5.9%

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

      \[\leadsto im \cdot \left(-2 \cdot \frac{\color{blue}{\sin re \cdot 0.8333333333333334}}{-0.16666666666666666 \cdot \sin re + 0.8333333333333334 \cdot \sin re}\right) \]
    5. distribute-rgt-out5.9%

      \[\leadsto im \cdot \left(-2 \cdot \frac{\sin re \cdot 0.8333333333333334}{\color{blue}{\sin re \cdot \left(-0.16666666666666666 + 0.8333333333333334\right)}}\right) \]
    6. times-frac5.9%

      \[\leadsto im \cdot \left(-2 \cdot \color{blue}{\left(\frac{\sin re}{\sin re} \cdot \frac{0.8333333333333334}{-0.16666666666666666 + 0.8333333333333334}\right)}\right) \]
    7. *-inverses5.9%

      \[\leadsto im \cdot \left(-2 \cdot \left(\color{blue}{1} \cdot \frac{0.8333333333333334}{-0.16666666666666666 + 0.8333333333333334}\right)\right) \]
    8. metadata-eval5.9%

      \[\leadsto im \cdot \left(-2 \cdot \left(1 \cdot \frac{0.8333333333333334}{\color{blue}{0.6666666666666666}}\right)\right) \]
    9. metadata-eval5.9%

      \[\leadsto im \cdot \left(-2 \cdot \left(1 \cdot \color{blue}{1.25}\right)\right) \]
    10. metadata-eval5.9%

      \[\leadsto im \cdot \left(-2 \cdot \color{blue}{1.25}\right) \]
    11. metadata-eval5.9%

      \[\leadsto im \cdot \color{blue}{-2.5} \]
  12. Simplified5.9%

    \[\leadsto im \cdot \color{blue}{-2.5} \]
  13. Final simplification5.9%

    \[\leadsto im \cdot -2.5 \]
  14. Add Preprocessing

Alternative 13: 5.7% accurate, 102.7× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \left(im\_m \cdot -1.4\right) \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m) :precision binary64 (* im_s (* im_m -1.4)))
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 * -1.4);
}
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 * (-1.4d0))
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 * -1.4);
}
im\_m = math.fabs(im)
im\_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	return im_s * (im_m * -1.4)
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	return Float64(im_s * Float64(im_m * -1.4))
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 * -1.4);
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 * -1.4), $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 -1.4\right)
\end{array}
Derivation
  1. Initial program 68.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 80.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*80.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-out80.1%

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

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

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

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

      \[\leadsto im \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \color{blue}{\left({im}^{2} \cdot -0.16666666666666666 + -1\right)}\right)\right) \]
    3. fma-define94.2%

      \[\leadsto im \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \color{blue}{\mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)}\right)\right) \]
  7. Applied egg-rr94.2%

    \[\leadsto im \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)} \]
  8. Step-by-step derivation
    1. add-cbrt-cube89.8%

      \[\leadsto im \cdot \mathsf{log1p}\left(\color{blue}{\sqrt[3]{\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right) \cdot \mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right) \cdot \mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)}}\right) \]
    2. pow389.8%

      \[\leadsto im \cdot \mathsf{log1p}\left(\sqrt[3]{\color{blue}{{\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)}^{3}}}\right) \]
  9. Applied egg-rr89.8%

    \[\leadsto im \cdot \mathsf{log1p}\left(\color{blue}{\sqrt[3]{{\left(\mathsf{expm1}\left(\sin re \cdot \mathsf{fma}\left({im}^{2}, -0.16666666666666666, -1\right)\right)\right)}^{3}}}\right) \]
  10. Applied egg-rr6.1%

    \[\leadsto im \cdot \color{blue}{\left(\frac{-0.16666666666666666 \cdot \sin re}{0.8333333333333334 \cdot \sin re} - \frac{\sin re}{0.8333333333333334 \cdot \sin re}\right)} \]
  11. Step-by-step derivation
    1. times-frac6.1%

      \[\leadsto im \cdot \left(\color{blue}{\frac{-0.16666666666666666}{0.8333333333333334} \cdot \frac{\sin re}{\sin re}} - \frac{\sin re}{0.8333333333333334 \cdot \sin re}\right) \]
    2. metadata-eval6.1%

      \[\leadsto im \cdot \left(\color{blue}{-0.2} \cdot \frac{\sin re}{\sin re} - \frac{\sin re}{0.8333333333333334 \cdot \sin re}\right) \]
    3. *-inverses6.1%

      \[\leadsto im \cdot \left(-0.2 \cdot \color{blue}{1} - \frac{\sin re}{0.8333333333333334 \cdot \sin re}\right) \]
    4. metadata-eval6.1%

      \[\leadsto im \cdot \left(\color{blue}{-0.2} - \frac{\sin re}{0.8333333333333334 \cdot \sin re}\right) \]
    5. *-commutative6.1%

      \[\leadsto im \cdot \left(-0.2 - \frac{\sin re}{\color{blue}{\sin re \cdot 0.8333333333333334}}\right) \]
    6. associate-/r*6.1%

      \[\leadsto im \cdot \left(-0.2 - \color{blue}{\frac{\frac{\sin re}{\sin re}}{0.8333333333333334}}\right) \]
    7. *-inverses6.1%

      \[\leadsto im \cdot \left(-0.2 - \frac{\color{blue}{1}}{0.8333333333333334}\right) \]
    8. metadata-eval6.1%

      \[\leadsto im \cdot \left(-0.2 - \color{blue}{1.2}\right) \]
    9. metadata-eval6.1%

      \[\leadsto im \cdot \color{blue}{-1.4} \]
  12. Simplified6.1%

    \[\leadsto im \cdot \color{blue}{-1.4} \]
  13. Final simplification6.1%

    \[\leadsto im \cdot -1.4 \]
  14. Add Preprocessing

Alternative 14: 20.3% accurate, 102.7× speedup?

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

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

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

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

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

    \[\leadsto \color{blue}{\left(-im\right) \cdot \sin re} \]
  6. Step-by-step derivation
    1. pow149.3%

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

      \[\leadsto {\color{blue}{\left(\sin re \cdot \left(-im\right)\right)}}^{1} \]
    3. add-sqr-sqrt24.8%

      \[\leadsto {\left(\sin re \cdot \color{blue}{\left(\sqrt{-im} \cdot \sqrt{-im}\right)}\right)}^{1} \]
    4. sqrt-unprod38.9%

      \[\leadsto {\left(\sin re \cdot \color{blue}{\sqrt{\left(-im\right) \cdot \left(-im\right)}}\right)}^{1} \]
    5. sqr-neg38.9%

      \[\leadsto {\left(\sin re \cdot \sqrt{\color{blue}{im \cdot im}}\right)}^{1} \]
    6. sqrt-prod6.7%

      \[\leadsto {\left(\sin re \cdot \color{blue}{\left(\sqrt{im} \cdot \sqrt{im}\right)}\right)}^{1} \]
    7. add-sqr-sqrt13.7%

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

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

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

      \[\leadsto \color{blue}{im \cdot \sin re} \]
  9. Simplified13.7%

    \[\leadsto \color{blue}{im \cdot \sin re} \]
  10. Taylor expanded in re around 0 18.2%

    \[\leadsto \color{blue}{im \cdot re} \]
  11. Step-by-step derivation
    1. *-commutative18.2%

      \[\leadsto \color{blue}{re \cdot im} \]
  12. Simplified18.2%

    \[\leadsto \color{blue}{re \cdot im} \]
  13. Final simplification18.2%

    \[\leadsto im \cdot re \]
  14. Add Preprocessing

Alternative 15: 2.9% accurate, 308.0× speedup?

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

\\
im\_s \cdot re
\end{array}
Derivation
  1. Initial program 68.7%

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

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

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

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

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

    \[\leadsto \color{blue}{\log \left(e^{re}\right)} \]
  7. Step-by-step derivation
    1. rem-log-exp3.3%

      \[\leadsto \color{blue}{re} \]
  8. Simplified3.3%

    \[\leadsto \color{blue}{re} \]
  9. Final simplification3.3%

    \[\leadsto re \]
  10. 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 2024089 
(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))))