math.cos on complex, imaginary part

Percentage Accurate: 65.9% → 99.8%
Time: 11.7s
Alternatives: 17
Speedup: 2.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 alternatives:

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

Initial Program: 65.9% 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.8% accurate, 0.5× 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 -5:\\ \;\;\;\;t\_0 \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(\left(\left(-0.008333333333333333 \cdot {im\_m}^{5} + -0.0001984126984126984 \cdot {im\_m}^{7}\right) + -0.16666666666666666 \cdot {im\_m}^{3}\right) - im\_m\right)\\ \end{array} \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (- (exp (- im_m)) (exp im_m))))
   (*
    im_s
    (if (<= t_0 -5.0)
      (* t_0 (* 0.5 (sin re)))
      (*
       (sin re)
       (-
        (+
         (+
          (* -0.008333333333333333 (pow im_m 5.0))
          (* -0.0001984126984126984 (pow im_m 7.0)))
         (* -0.16666666666666666 (pow im_m 3.0)))
        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 <= -5.0) {
		tmp = t_0 * (0.5 * sin(re));
	} else {
		tmp = sin(re) * ((((-0.008333333333333333 * pow(im_m, 5.0)) + (-0.0001984126984126984 * pow(im_m, 7.0))) + (-0.16666666666666666 * pow(im_m, 3.0))) - 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 <= (-5.0d0)) then
        tmp = t_0 * (0.5d0 * sin(re))
    else
        tmp = sin(re) * (((((-0.008333333333333333d0) * (im_m ** 5.0d0)) + ((-0.0001984126984126984d0) * (im_m ** 7.0d0))) + ((-0.16666666666666666d0) * (im_m ** 3.0d0))) - 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 <= -5.0) {
		tmp = t_0 * (0.5 * Math.sin(re));
	} else {
		tmp = Math.sin(re) * ((((-0.008333333333333333 * Math.pow(im_m, 5.0)) + (-0.0001984126984126984 * Math.pow(im_m, 7.0))) + (-0.16666666666666666 * Math.pow(im_m, 3.0))) - 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 <= -5.0:
		tmp = t_0 * (0.5 * math.sin(re))
	else:
		tmp = math.sin(re) * ((((-0.008333333333333333 * math.pow(im_m, 5.0)) + (-0.0001984126984126984 * math.pow(im_m, 7.0))) + (-0.16666666666666666 * math.pow(im_m, 3.0))) - 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 <= -5.0)
		tmp = Float64(t_0 * Float64(0.5 * sin(re)));
	else
		tmp = Float64(sin(re) * Float64(Float64(Float64(Float64(-0.008333333333333333 * (im_m ^ 5.0)) + Float64(-0.0001984126984126984 * (im_m ^ 7.0))) + Float64(-0.16666666666666666 * (im_m ^ 3.0))) - 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 <= -5.0)
		tmp = t_0 * (0.5 * sin(re));
	else
		tmp = sin(re) * ((((-0.008333333333333333 * (im_m ^ 5.0)) + (-0.0001984126984126984 * (im_m ^ 7.0))) + (-0.16666666666666666 * (im_m ^ 3.0))) - 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, -5.0], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[(N[(-0.008333333333333333 * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision] + N[(-0.0001984126984126984 * N[Power[im$95$m, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.16666666666666666 * N[Power[im$95$m, 3.0], $MachinePrecision]), $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 -5:\\
\;\;\;\;t\_0 \cdot \left(0.5 \cdot \sin re\right)\\

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

    1. Initial program 100.0%

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

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

    1. Initial program 57.3%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    4. Taylor expanded in im around 0 95.8%

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

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

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

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

        \[\leadsto \left(\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \sin re + \color{blue}{\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re}\right) + \left(-1 \cdot \left(im \cdot \sin re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \sin re\right)\right) \]
      5. distribute-rgt-out95.8%

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

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

        \[\leadsto \sin re \cdot \left(-0.008333333333333333 \cdot {im}^{5} + -0.0001984126984126984 \cdot {im}^{7}\right) + \left(-0.16666666666666666 \cdot \left({im}^{3} \cdot \sin re\right) + \color{blue}{\left(-im \cdot \sin re\right)}\right) \]
      8. unsub-neg95.8%

        \[\leadsto \sin re \cdot \left(-0.008333333333333333 \cdot {im}^{5} + -0.0001984126984126984 \cdot {im}^{7}\right) + \color{blue}{\left(-0.16666666666666666 \cdot \left({im}^{3} \cdot \sin re\right) - im \cdot \sin re\right)} \]
      9. associate-*r*95.8%

        \[\leadsto \sin re \cdot \left(-0.008333333333333333 \cdot {im}^{5} + -0.0001984126984126984 \cdot {im}^{7}\right) + \left(\color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \sin re} - im \cdot \sin re\right) \]
      10. distribute-rgt-out--95.8%

        \[\leadsto \sin re \cdot \left(-0.008333333333333333 \cdot {im}^{5} + -0.0001984126984126984 \cdot {im}^{7}\right) + \color{blue}{\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      11. distribute-lft-out95.8%

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

      \[\leadsto \color{blue}{\sin re \cdot \left(\left({im}^{5} \cdot -0.008333333333333333 + {im}^{7} \cdot -0.0001984126984126984\right) + \left({im}^{3} \cdot -0.16666666666666666 - im\right)\right)} \]
    7. Taylor expanded in re around inf 95.8%

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

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

Alternative 2: 99.8% accurate, 0.5× 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 -5:\\ \;\;\;\;t\_0 \cdot \left(0.5 \cdot \sin re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(\left(-0.008333333333333333 \cdot {im\_m}^{5} + -0.0001984126984126984 \cdot {im\_m}^{7}\right) + \left(-0.16666666666666666 \cdot {im\_m}^{3} - im\_m\right)\right)\\ \end{array} \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (- (exp (- im_m)) (exp im_m))))
   (*
    im_s
    (if (<= t_0 -5.0)
      (* t_0 (* 0.5 (sin re)))
      (*
       (sin re)
       (+
        (+
         (* -0.008333333333333333 (pow im_m 5.0))
         (* -0.0001984126984126984 (pow im_m 7.0)))
        (- (* -0.16666666666666666 (pow im_m 3.0)) 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 <= -5.0) {
		tmp = t_0 * (0.5 * sin(re));
	} else {
		tmp = sin(re) * (((-0.008333333333333333 * pow(im_m, 5.0)) + (-0.0001984126984126984 * pow(im_m, 7.0))) + ((-0.16666666666666666 * pow(im_m, 3.0)) - 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 <= (-5.0d0)) then
        tmp = t_0 * (0.5d0 * sin(re))
    else
        tmp = sin(re) * ((((-0.008333333333333333d0) * (im_m ** 5.0d0)) + ((-0.0001984126984126984d0) * (im_m ** 7.0d0))) + (((-0.16666666666666666d0) * (im_m ** 3.0d0)) - 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 <= -5.0) {
		tmp = t_0 * (0.5 * Math.sin(re));
	} else {
		tmp = Math.sin(re) * (((-0.008333333333333333 * Math.pow(im_m, 5.0)) + (-0.0001984126984126984 * Math.pow(im_m, 7.0))) + ((-0.16666666666666666 * Math.pow(im_m, 3.0)) - 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 <= -5.0:
		tmp = t_0 * (0.5 * math.sin(re))
	else:
		tmp = math.sin(re) * (((-0.008333333333333333 * math.pow(im_m, 5.0)) + (-0.0001984126984126984 * math.pow(im_m, 7.0))) + ((-0.16666666666666666 * math.pow(im_m, 3.0)) - 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 <= -5.0)
		tmp = Float64(t_0 * Float64(0.5 * sin(re)));
	else
		tmp = Float64(sin(re) * Float64(Float64(Float64(-0.008333333333333333 * (im_m ^ 5.0)) + Float64(-0.0001984126984126984 * (im_m ^ 7.0))) + Float64(Float64(-0.16666666666666666 * (im_m ^ 3.0)) - 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 <= -5.0)
		tmp = t_0 * (0.5 * sin(re));
	else
		tmp = sin(re) * (((-0.008333333333333333 * (im_m ^ 5.0)) + (-0.0001984126984126984 * (im_m ^ 7.0))) + ((-0.16666666666666666 * (im_m ^ 3.0)) - 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, -5.0], N[(t$95$0 * N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(N[(-0.008333333333333333 * N[Power[im$95$m, 5.0], $MachinePrecision]), $MachinePrecision] + N[(-0.0001984126984126984 * N[Power[im$95$m, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.16666666666666666 * N[Power[im$95$m, 3.0], $MachinePrecision]), $MachinePrecision] - im$95$m), $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 := e^{-im\_m} - e^{im\_m}\\
im\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -5:\\
\;\;\;\;t\_0 \cdot \left(0.5 \cdot \sin re\right)\\

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

    1. Initial program 100.0%

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

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

    1. Initial program 57.3%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    4. Taylor expanded in im around 0 95.8%

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

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

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

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

        \[\leadsto \left(\left(-0.008333333333333333 \cdot {im}^{5}\right) \cdot \sin re + \color{blue}{\left(-0.0001984126984126984 \cdot {im}^{7}\right) \cdot \sin re}\right) + \left(-1 \cdot \left(im \cdot \sin re\right) + -0.16666666666666666 \cdot \left({im}^{3} \cdot \sin re\right)\right) \]
      5. distribute-rgt-out95.8%

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

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

        \[\leadsto \sin re \cdot \left(-0.008333333333333333 \cdot {im}^{5} + -0.0001984126984126984 \cdot {im}^{7}\right) + \left(-0.16666666666666666 \cdot \left({im}^{3} \cdot \sin re\right) + \color{blue}{\left(-im \cdot \sin re\right)}\right) \]
      8. unsub-neg95.8%

        \[\leadsto \sin re \cdot \left(-0.008333333333333333 \cdot {im}^{5} + -0.0001984126984126984 \cdot {im}^{7}\right) + \color{blue}{\left(-0.16666666666666666 \cdot \left({im}^{3} \cdot \sin re\right) - im \cdot \sin re\right)} \]
      9. associate-*r*95.8%

        \[\leadsto \sin re \cdot \left(-0.008333333333333333 \cdot {im}^{5} + -0.0001984126984126984 \cdot {im}^{7}\right) + \left(\color{blue}{\left(-0.16666666666666666 \cdot {im}^{3}\right) \cdot \sin re} - im \cdot \sin re\right) \]
      10. distribute-rgt-out--95.8%

        \[\leadsto \sin re \cdot \left(-0.008333333333333333 \cdot {im}^{5} + -0.0001984126984126984 \cdot {im}^{7}\right) + \color{blue}{\sin re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)} \]
      11. distribute-lft-out95.8%

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

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

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

Alternative 3: 99.9% accurate, 0.6× speedup?

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

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


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

    1. Initial program 99.9%

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

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

    1. Initial program 57.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 95.8%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    4. Taylor expanded in im around 0 92.6%

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

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

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

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

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

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

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

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

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

Alternative 4: 97.8% accurate, 1.4× speedup?

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

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

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

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


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

    1. Initial program 57.3%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    4. Taylor expanded in im around 0 92.5%

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

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

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

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

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

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

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

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

    if 0.115000000000000005 < im < 1.09999999999999998e44

    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 80.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*80.0%

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

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

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

    if 1.09999999999999998e44 < 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 100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    4. Taylor expanded in im around inf 100.0%

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

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

Alternative 5: 76.2% accurate, 1.4× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 650:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 4.05 \cdot 10^{+99}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot re\right)\right)\\ \mathbf{elif}\;im\_m \leq 2.9 \cdot 10^{+197} \lor \neg \left(im\_m \leq 2.45 \cdot 10^{+230}\right):\\ \;\;\;\;re \cdot \left(-0.16666666666666666 \cdot {im\_m}^{3} - im\_m\right)\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \left({re}^{3} \cdot 0.16666666666666666 - re\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 650.0)
    (* (- im_m) (sin re))
    (if (<= im_m 4.05e+99)
      (log1p (expm1 (* im_m re)))
      (if (or (<= im_m 2.9e+197) (not (<= im_m 2.45e+230)))
        (* re (- (* -0.16666666666666666 (pow im_m 3.0)) im_m))
        (* im_m (- (* (pow re 3.0) 0.16666666666666666) 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 <= 650.0) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 4.05e+99) {
		tmp = log1p(expm1((im_m * re)));
	} else if ((im_m <= 2.9e+197) || !(im_m <= 2.45e+230)) {
		tmp = re * ((-0.16666666666666666 * pow(im_m, 3.0)) - im_m);
	} else {
		tmp = im_m * ((pow(re, 3.0) * 0.16666666666666666) - re);
	}
	return im_s * tmp;
}
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 650.0) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 4.05e+99) {
		tmp = Math.log1p(Math.expm1((im_m * re)));
	} else if ((im_m <= 2.9e+197) || !(im_m <= 2.45e+230)) {
		tmp = re * ((-0.16666666666666666 * Math.pow(im_m, 3.0)) - im_m);
	} else {
		tmp = im_m * ((Math.pow(re, 3.0) * 0.16666666666666666) - 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 <= 650.0:
		tmp = -im_m * math.sin(re)
	elif im_m <= 4.05e+99:
		tmp = math.log1p(math.expm1((im_m * re)))
	elif (im_m <= 2.9e+197) or not (im_m <= 2.45e+230):
		tmp = re * ((-0.16666666666666666 * math.pow(im_m, 3.0)) - im_m)
	else:
		tmp = im_m * ((math.pow(re, 3.0) * 0.16666666666666666) - 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 <= 650.0)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 4.05e+99)
		tmp = log1p(expm1(Float64(im_m * re)));
	elseif ((im_m <= 2.9e+197) || !(im_m <= 2.45e+230))
		tmp = Float64(re * Float64(Float64(-0.16666666666666666 * (im_m ^ 3.0)) - im_m));
	else
		tmp = Float64(im_m * Float64(Float64((re ^ 3.0) * 0.16666666666666666) - re));
	end
	return Float64(im_s * tmp)
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 650.0], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 4.05e+99], N[Log[1 + N[(Exp[N[(im$95$m * re), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[im$95$m, 2.9e+197], N[Not[LessEqual[im$95$m, 2.45e+230]], $MachinePrecision]], N[(re * N[(N[(-0.16666666666666666 * N[Power[im$95$m, 3.0], $MachinePrecision]), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision], N[(im$95$m * N[(N[(N[Power[re, 3.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - re), $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 650:\\
\;\;\;\;\left(-im\_m\right) \cdot \sin re\\

\mathbf{elif}\;im\_m \leq 4.05 \cdot 10^{+99}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\_m \cdot re\right)\right)\\

\mathbf{elif}\;im\_m \leq 2.9 \cdot 10^{+197} \lor \neg \left(im\_m \leq 2.45 \cdot 10^{+230}\right):\\
\;\;\;\;re \cdot \left(-0.16666666666666666 \cdot {im\_m}^{3} - im\_m\right)\\

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


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

    1. Initial program 57.3%

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

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

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

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

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

    if 650 < im < 4.05000000000000007e99

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right)} \cdot re \]
      6. associate-*r*1.8%

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

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

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

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

        \[\leadsto \sqrt{\left(-im \cdot re\right) \cdot \color{blue}{\left(-im \cdot re\right)}} \]
      11. sqr-neg11.8%

        \[\leadsto \sqrt{\color{blue}{\left(im \cdot re\right) \cdot \left(im \cdot re\right)}} \]
      12. sqrt-unprod6.0%

        \[\leadsto \color{blue}{\sqrt{im \cdot re} \cdot \sqrt{im \cdot re}} \]
      13. log1p-expm1-u15.9%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{im \cdot re} \cdot \sqrt{im \cdot re}\right)\right)} \]
      14. add-sqr-sqrt42.4%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{im \cdot re}\right)\right) \]
      15. *-commutative42.4%

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

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

    if 4.05000000000000007e99 < im < 2.90000000000000002e197 or 2.44999999999999985e230 < 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 re around 0 81.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.90000000000000002e197 < im < 2.44999999999999985e230

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 650:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 4.05 \cdot 10^{+99}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im \cdot re\right)\right)\\ \mathbf{elif}\;im \leq 2.9 \cdot 10^{+197} \lor \neg \left(im \leq 2.45 \cdot 10^{+230}\right):\\ \;\;\;\;re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left({re}^{3} \cdot 0.16666666666666666 - re\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 93.3% 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 5.5:\\ \;\;\;\;\sin re \cdot \left(-0.16666666666666666 \cdot {im\_m}^{3} - im\_m\right)\\ \mathbf{else}:\\ \;\;\;\;-0.0001984126984126984 \cdot \left(\sin re \cdot {im\_m}^{7}\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 5.5)
    (* (sin re) (- (* -0.16666666666666666 (pow im_m 3.0)) im_m))
    (* -0.0001984126984126984 (* (sin re) (pow im_m 7.0))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 5.5) {
		tmp = sin(re) * ((-0.16666666666666666 * pow(im_m, 3.0)) - im_m);
	} else {
		tmp = -0.0001984126984126984 * (sin(re) * pow(im_m, 7.0));
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 5.5d0) then
        tmp = sin(re) * (((-0.16666666666666666d0) * (im_m ** 3.0d0)) - im_m)
    else
        tmp = (-0.0001984126984126984d0) * (sin(re) * (im_m ** 7.0d0))
    end if
    code = im_s * tmp
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 5.5) {
		tmp = Math.sin(re) * ((-0.16666666666666666 * Math.pow(im_m, 3.0)) - im_m);
	} else {
		tmp = -0.0001984126984126984 * (Math.sin(re) * Math.pow(im_m, 7.0));
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	tmp = 0
	if im_m <= 5.5:
		tmp = math.sin(re) * ((-0.16666666666666666 * math.pow(im_m, 3.0)) - im_m)
	else:
		tmp = -0.0001984126984126984 * (math.sin(re) * math.pow(im_m, 7.0))
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	tmp = 0.0
	if (im_m <= 5.5)
		tmp = Float64(sin(re) * Float64(Float64(-0.16666666666666666 * (im_m ^ 3.0)) - im_m));
	else
		tmp = Float64(-0.0001984126984126984 * Float64(sin(re) * (im_m ^ 7.0)));
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if (im_m <= 5.5)
		tmp = sin(re) * ((-0.16666666666666666 * (im_m ^ 3.0)) - im_m);
	else
		tmp = -0.0001984126984126984 * (sin(re) * (im_m ^ 7.0));
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 5.5], N[(N[Sin[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * N[Power[im$95$m, 3.0], $MachinePrecision]), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision], N[(-0.0001984126984126984 * N[(N[Sin[re], $MachinePrecision] * N[Power[im$95$m, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

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

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


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

    1. Initial program 57.3%

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    4. Taylor expanded in im around 0 92.5%

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

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

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

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

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

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

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

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

    if 5.5 < 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 93.4%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    4. Taylor expanded in im around inf 93.4%

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

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

Alternative 7: 93.1% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 57.3%

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

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

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

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

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

    if 4.20000000000000018 < 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 93.4%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
    4. Taylor expanded in im around inf 93.4%

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

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

Alternative 8: 75.3% accurate, 2.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 4100:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 5.8 \cdot 10^{+99} \lor \neg \left(im\_m \leq 2.05 \cdot 10^{+197}\right) \land im\_m \leq 2.45 \cdot 10^{+230}:\\ \;\;\;\;im\_m \cdot \left({re}^{3} \cdot 0.16666666666666666 - re\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(-0.16666666666666666 \cdot {im\_m}^{3} - im\_m\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= im_m 4100.0)
    (* (- im_m) (sin re))
    (if (or (<= im_m 5.8e+99)
            (and (not (<= im_m 2.05e+197)) (<= im_m 2.45e+230)))
      (* im_m (- (* (pow re 3.0) 0.16666666666666666) re))
      (* re (- (* -0.16666666666666666 (pow im_m 3.0)) im_m))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double tmp;
	if (im_m <= 4100.0) {
		tmp = -im_m * sin(re);
	} else if ((im_m <= 5.8e+99) || (!(im_m <= 2.05e+197) && (im_m <= 2.45e+230))) {
		tmp = im_m * ((pow(re, 3.0) * 0.16666666666666666) - re);
	} else {
		tmp = re * ((-0.16666666666666666 * pow(im_m, 3.0)) - 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 <= 4100.0d0) then
        tmp = -im_m * sin(re)
    else if ((im_m <= 5.8d+99) .or. (.not. (im_m <= 2.05d+197)) .and. (im_m <= 2.45d+230)) then
        tmp = im_m * (((re ** 3.0d0) * 0.16666666666666666d0) - re)
    else
        tmp = re * (((-0.16666666666666666d0) * (im_m ** 3.0d0)) - 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 <= 4100.0) {
		tmp = -im_m * Math.sin(re);
	} else if ((im_m <= 5.8e+99) || (!(im_m <= 2.05e+197) && (im_m <= 2.45e+230))) {
		tmp = im_m * ((Math.pow(re, 3.0) * 0.16666666666666666) - re);
	} else {
		tmp = re * ((-0.16666666666666666 * Math.pow(im_m, 3.0)) - 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 <= 4100.0:
		tmp = -im_m * math.sin(re)
	elif (im_m <= 5.8e+99) or (not (im_m <= 2.05e+197) and (im_m <= 2.45e+230)):
		tmp = im_m * ((math.pow(re, 3.0) * 0.16666666666666666) - re)
	else:
		tmp = re * ((-0.16666666666666666 * math.pow(im_m, 3.0)) - 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 <= 4100.0)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif ((im_m <= 5.8e+99) || (!(im_m <= 2.05e+197) && (im_m <= 2.45e+230)))
		tmp = Float64(im_m * Float64(Float64((re ^ 3.0) * 0.16666666666666666) - re));
	else
		tmp = Float64(re * Float64(Float64(-0.16666666666666666 * (im_m ^ 3.0)) - 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 <= 4100.0)
		tmp = -im_m * sin(re);
	elseif ((im_m <= 5.8e+99) || (~((im_m <= 2.05e+197)) && (im_m <= 2.45e+230)))
		tmp = im_m * (((re ^ 3.0) * 0.16666666666666666) - re);
	else
		tmp = re * ((-0.16666666666666666 * (im_m ^ 3.0)) - 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, 4100.0], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im$95$m, 5.8e+99], And[N[Not[LessEqual[im$95$m, 2.05e+197]], $MachinePrecision], LessEqual[im$95$m, 2.45e+230]]], N[(im$95$m * N[(N[(N[Power[re, 3.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision], N[(re * N[(N[(-0.16666666666666666 * N[Power[im$95$m, 3.0], $MachinePrecision]), $MachinePrecision] - im$95$m), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

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

\mathbf{elif}\;im\_m \leq 5.8 \cdot 10^{+99} \lor \neg \left(im\_m \leq 2.05 \cdot 10^{+197}\right) \land im\_m \leq 2.45 \cdot 10^{+230}:\\
\;\;\;\;im\_m \cdot \left({re}^{3} \cdot 0.16666666666666666 - re\right)\\

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


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

    1. Initial program 57.3%

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

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

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

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

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

    if 4100 < im < 5.8000000000000004e99 or 2.05000000000000015e197 < im < 2.44999999999999985e230

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.8000000000000004e99 < im < 2.05000000000000015e197 or 2.44999999999999985e230 < 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 re around 0 81.8%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4100:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 5.8 \cdot 10^{+99} \lor \neg \left(im \leq 2.05 \cdot 10^{+197}\right) \land im \leq 2.45 \cdot 10^{+230}:\\ \;\;\;\;im \cdot \left({re}^{3} \cdot 0.16666666666666666 - re\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(-0.16666666666666666 \cdot {im}^{3} - im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 60.6% accurate, 2.4× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := im\_m \cdot \left({re}^{3} \cdot 0.16666666666666666 - re\right)\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 600:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 1.4 \cdot 10^{+162}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 1.14 \cdot 10^{+195}:\\ \;\;\;\;im\_m \cdot \left(-re\right)\\ \mathbf{elif}\;im\_m \leq 1.05 \cdot 10^{+244}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im\_m \cdot -2\right)\\ \end{array} \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* im_m (- (* (pow re 3.0) 0.16666666666666666) re))))
   (*
    im_s
    (if (<= im_m 600.0)
      (* (- im_m) (sin re))
      (if (<= im_m 1.4e+162)
        t_0
        (if (<= im_m 1.14e+195)
          (* im_m (- re))
          (if (<= im_m 1.05e+244) t_0 (* (* 0.5 re) (* im_m -2.0)))))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = im_m * ((pow(re, 3.0) * 0.16666666666666666) - re);
	double tmp;
	if (im_m <= 600.0) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 1.4e+162) {
		tmp = t_0;
	} else if (im_m <= 1.14e+195) {
		tmp = im_m * -re;
	} else if (im_m <= 1.05e+244) {
		tmp = t_0;
	} else {
		tmp = (0.5 * re) * (im_m * -2.0);
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = im_m * (((re ** 3.0d0) * 0.16666666666666666d0) - re)
    if (im_m <= 600.0d0) then
        tmp = -im_m * sin(re)
    else if (im_m <= 1.4d+162) then
        tmp = t_0
    else if (im_m <= 1.14d+195) then
        tmp = im_m * -re
    else if (im_m <= 1.05d+244) then
        tmp = t_0
    else
        tmp = (0.5d0 * re) * (im_m * (-2.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 t_0 = im_m * ((Math.pow(re, 3.0) * 0.16666666666666666) - re);
	double tmp;
	if (im_m <= 600.0) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 1.4e+162) {
		tmp = t_0;
	} else if (im_m <= 1.14e+195) {
		tmp = im_m * -re;
	} else if (im_m <= 1.05e+244) {
		tmp = t_0;
	} else {
		tmp = (0.5 * re) * (im_m * -2.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 = im_m * ((math.pow(re, 3.0) * 0.16666666666666666) - re)
	tmp = 0
	if im_m <= 600.0:
		tmp = -im_m * math.sin(re)
	elif im_m <= 1.4e+162:
		tmp = t_0
	elif im_m <= 1.14e+195:
		tmp = im_m * -re
	elif im_m <= 1.05e+244:
		tmp = t_0
	else:
		tmp = (0.5 * re) * (im_m * -2.0)
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(im_m * Float64(Float64((re ^ 3.0) * 0.16666666666666666) - re))
	tmp = 0.0
	if (im_m <= 600.0)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 1.4e+162)
		tmp = t_0;
	elseif (im_m <= 1.14e+195)
		tmp = Float64(im_m * Float64(-re));
	elseif (im_m <= 1.05e+244)
		tmp = t_0;
	else
		tmp = Float64(Float64(0.5 * re) * Float64(im_m * -2.0));
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	t_0 = im_m * (((re ^ 3.0) * 0.16666666666666666) - re);
	tmp = 0.0;
	if (im_m <= 600.0)
		tmp = -im_m * sin(re);
	elseif (im_m <= 1.4e+162)
		tmp = t_0;
	elseif (im_m <= 1.14e+195)
		tmp = im_m * -re;
	elseif (im_m <= 1.05e+244)
		tmp = t_0;
	else
		tmp = (0.5 * re) * (im_m * -2.0);
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(im$95$m * N[(N[(N[Power[re, 3.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 600.0], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 1.4e+162], t$95$0, If[LessEqual[im$95$m, 1.14e+195], N[(im$95$m * (-re)), $MachinePrecision], If[LessEqual[im$95$m, 1.05e+244], t$95$0, N[(N[(0.5 * re), $MachinePrecision] * N[(im$95$m * -2.0), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

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

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

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

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

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


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

    1. Initial program 57.3%

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

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

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

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

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

    if 600 < im < 1.39999999999999995e162 or 1.13999999999999997e195 < im < 1.05e244

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.39999999999999995e162 < im < 1.13999999999999997e195

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 1.05e244 < 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 re around 0 81.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 600:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 1.4 \cdot 10^{+162}:\\ \;\;\;\;im \cdot \left({re}^{3} \cdot 0.16666666666666666 - re\right)\\ \mathbf{elif}\;im \leq 1.14 \cdot 10^{+195}:\\ \;\;\;\;im \cdot \left(-re\right)\\ \mathbf{elif}\;im \leq 1.05 \cdot 10^{+244}:\\ \;\;\;\;im \cdot \left({re}^{3} \cdot 0.16666666666666666 - re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im \cdot -2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 60.3% accurate, 2.4× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := 0.16666666666666666 \cdot \left(im\_m \cdot {re}^{3}\right)\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 650:\\ \;\;\;\;\left(-im\_m\right) \cdot \sin re\\ \mathbf{elif}\;im\_m \leq 8.8 \cdot 10^{+162}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 4.3 \cdot 10^{+196}:\\ \;\;\;\;im\_m \cdot \left(-re\right)\\ \mathbf{elif}\;im\_m \leq 2.1 \cdot 10^{+243}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im\_m \cdot -2\right)\\ \end{array} \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* 0.16666666666666666 (* im_m (pow re 3.0)))))
   (*
    im_s
    (if (<= im_m 650.0)
      (* (- im_m) (sin re))
      (if (<= im_m 8.8e+162)
        t_0
        (if (<= im_m 4.3e+196)
          (* im_m (- re))
          (if (<= im_m 2.1e+243) t_0 (* (* 0.5 re) (* im_m -2.0)))))))))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = 0.16666666666666666 * (im_m * pow(re, 3.0));
	double tmp;
	if (im_m <= 650.0) {
		tmp = -im_m * sin(re);
	} else if (im_m <= 8.8e+162) {
		tmp = t_0;
	} else if (im_m <= 4.3e+196) {
		tmp = im_m * -re;
	} else if (im_m <= 2.1e+243) {
		tmp = t_0;
	} else {
		tmp = (0.5 * re) * (im_m * -2.0);
	}
	return im_s * tmp;
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 0.16666666666666666d0 * (im_m * (re ** 3.0d0))
    if (im_m <= 650.0d0) then
        tmp = -im_m * sin(re)
    else if (im_m <= 8.8d+162) then
        tmp = t_0
    else if (im_m <= 4.3d+196) then
        tmp = im_m * -re
    else if (im_m <= 2.1d+243) then
        tmp = t_0
    else
        tmp = (0.5d0 * re) * (im_m * (-2.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 t_0 = 0.16666666666666666 * (im_m * Math.pow(re, 3.0));
	double tmp;
	if (im_m <= 650.0) {
		tmp = -im_m * Math.sin(re);
	} else if (im_m <= 8.8e+162) {
		tmp = t_0;
	} else if (im_m <= 4.3e+196) {
		tmp = im_m * -re;
	} else if (im_m <= 2.1e+243) {
		tmp = t_0;
	} else {
		tmp = (0.5 * re) * (im_m * -2.0);
	}
	return im_s * tmp;
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	t_0 = 0.16666666666666666 * (im_m * math.pow(re, 3.0))
	tmp = 0
	if im_m <= 650.0:
		tmp = -im_m * math.sin(re)
	elif im_m <= 8.8e+162:
		tmp = t_0
	elif im_m <= 4.3e+196:
		tmp = im_m * -re
	elif im_m <= 2.1e+243:
		tmp = t_0
	else:
		tmp = (0.5 * re) * (im_m * -2.0)
	return im_s * tmp
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(0.16666666666666666 * Float64(im_m * (re ^ 3.0)))
	tmp = 0.0
	if (im_m <= 650.0)
		tmp = Float64(Float64(-im_m) * sin(re));
	elseif (im_m <= 8.8e+162)
		tmp = t_0;
	elseif (im_m <= 4.3e+196)
		tmp = Float64(im_m * Float64(-re));
	elseif (im_m <= 2.1e+243)
		tmp = t_0;
	else
		tmp = Float64(Float64(0.5 * re) * Float64(im_m * -2.0));
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	t_0 = 0.16666666666666666 * (im_m * (re ^ 3.0));
	tmp = 0.0;
	if (im_m <= 650.0)
		tmp = -im_m * sin(re);
	elseif (im_m <= 8.8e+162)
		tmp = t_0;
	elseif (im_m <= 4.3e+196)
		tmp = im_m * -re;
	elseif (im_m <= 2.1e+243)
		tmp = t_0;
	else
		tmp = (0.5 * re) * (im_m * -2.0);
	end
	tmp_2 = im_s * tmp;
end
im_m = N[Abs[im], $MachinePrecision]
im_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(0.16666666666666666 * N[(im$95$m * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[im$95$m, 650.0], N[((-im$95$m) * N[Sin[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 8.8e+162], t$95$0, If[LessEqual[im$95$m, 4.3e+196], N[(im$95$m * (-re)), $MachinePrecision], If[LessEqual[im$95$m, 2.1e+243], t$95$0, N[(N[(0.5 * re), $MachinePrecision] * N[(im$95$m * -2.0), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
im_m = \left|im\right|
\\
im_s = \mathsf{copysign}\left(1, im\right)

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

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

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

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

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


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

    1. Initial program 57.3%

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

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

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

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

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

    if 650 < im < 8.8000000000000007e162 or 4.30000000000000012e196 < im < 2.0999999999999999e243

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

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

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

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

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

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

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

    if 8.8000000000000007e162 < im < 4.30000000000000012e196

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 2.0999999999999999e243 < 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 re around 0 81.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 650:\\ \;\;\;\;\left(-im\right) \cdot \sin re\\ \mathbf{elif}\;im \leq 8.8 \cdot 10^{+162}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\ \mathbf{elif}\;im \leq 4.3 \cdot 10^{+196}:\\ \;\;\;\;im \cdot \left(-re\right)\\ \mathbf{elif}\;im \leq 2.1 \cdot 10^{+243}:\\ \;\;\;\;0.16666666666666666 \cdot \left(im \cdot {re}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im \cdot -2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 56.5% accurate, 2.8× speedup?

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

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

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


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

    1. Initial program 61.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 63.4%

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

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

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

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

    if 1.7499999999999999e106 < 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 re around 0 72.5%

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

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

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

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

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

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

Alternative 12: 33.5% accurate, 21.9× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 1.08 \cdot 10^{+167} \lor \neg \left(re \leq 6.4 \cdot 10^{+291}\right):\\ \;\;\;\;im\_m \cdot \left(-re\right)\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot re\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
im_s = (copysign.f64 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (or (<= re 1.08e+167) (not (<= re 6.4e+291)))
    (* 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 ((re <= 1.08e+167) || !(re <= 6.4e+291)) {
		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 ((re <= 1.08d+167) .or. (.not. (re <= 6.4d+291))) 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 ((re <= 1.08e+167) || !(re <= 6.4e+291)) {
		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 (re <= 1.08e+167) or not (re <= 6.4e+291):
		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 ((re <= 1.08e+167) || !(re <= 6.4e+291))
		tmp = Float64(im_m * Float64(-re));
	else
		tmp = Float64(im_m * re);
	end
	return Float64(im_s * tmp)
end
im_m = abs(im);
im_s = sign(im) * abs(1.0);
function tmp_2 = code(im_s, re, im_m)
	tmp = 0.0;
	if ((re <= 1.08e+167) || ~((re <= 6.4e+291)))
		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[Or[LessEqual[re, 1.08e+167], N[Not[LessEqual[re, 6.4e+291]], $MachinePrecision]], 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}\;re \leq 1.08 \cdot 10^{+167} \lor \neg \left(re \leq 6.4 \cdot 10^{+291}\right):\\
\;\;\;\;im\_m \cdot \left(-re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 1.08000000000000005e167 or 6.4000000000000004e291 < re

    1. Initial program 71.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 52.1%

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

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

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

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

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

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

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

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

    if 1.08000000000000005e167 < re < 6.4000000000000004e291

    1. Initial program 57.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right)} \cdot re \]
      6. associate-*r*15.7%

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(-im \cdot re\right)} \cdot \left(-1 \cdot \left(im \cdot re\right)\right)} \]
      10. mul-1-neg25.9%

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

        \[\leadsto \sqrt{\color{blue}{\left(im \cdot re\right) \cdot \left(im \cdot re\right)}} \]
      12. sqrt-unprod14.9%

        \[\leadsto \color{blue}{\sqrt{im \cdot re} \cdot \sqrt{im \cdot re}} \]
      13. add-sqr-sqrt29.6%

        \[\leadsto \color{blue}{im \cdot re} \]
      14. expm1-log1p-u15.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(im \cdot re\right)\right)} \]
      15. expm1-udef15.7%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(im \cdot re\right)} - 1} \]
      16. *-commutative15.7%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{re \cdot im}\right)} - 1 \]
    8. Applied egg-rr15.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re \cdot im\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def15.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot im\right)\right)} \]
      2. expm1-log1p29.6%

        \[\leadsto \color{blue}{re \cdot im} \]
    10. Simplified29.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.08 \cdot 10^{+167} \lor \neg \left(re \leq 6.4 \cdot 10^{+291}\right):\\ \;\;\;\;im \cdot \left(-re\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot re\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 33.5% accurate, 22.0× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ im_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;re \leq 1.08 \cdot 10^{+167}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im\_m \cdot -2\right)\\ \mathbf{elif}\;re \leq 6.4 \cdot 10^{+291}:\\ \;\;\;\;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 1 im)
(FPCore (im_s re im_m)
 :precision binary64
 (*
  im_s
  (if (<= re 1.08e+167)
    (* (* 0.5 re) (* im_m -2.0))
    (if (<= re 6.4e+291) (* 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 (re <= 1.08e+167) {
		tmp = (0.5 * re) * (im_m * -2.0);
	} else if (re <= 6.4e+291) {
		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 (re <= 1.08d+167) then
        tmp = (0.5d0 * re) * (im_m * (-2.0d0))
    else if (re <= 6.4d+291) 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 (re <= 1.08e+167) {
		tmp = (0.5 * re) * (im_m * -2.0);
	} else if (re <= 6.4e+291) {
		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 re <= 1.08e+167:
		tmp = (0.5 * re) * (im_m * -2.0)
	elif re <= 6.4e+291:
		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 (re <= 1.08e+167)
		tmp = Float64(Float64(0.5 * re) * Float64(im_m * -2.0));
	elseif (re <= 6.4e+291)
		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 (re <= 1.08e+167)
		tmp = (0.5 * re) * (im_m * -2.0);
	elseif (re <= 6.4e+291)
		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[re, 1.08e+167], N[(N[(0.5 * re), $MachinePrecision] * N[(im$95$m * -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 6.4e+291], 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}\;re \leq 1.08 \cdot 10^{+167}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im\_m \cdot -2\right)\\

\mathbf{elif}\;re \leq 6.4 \cdot 10^{+291}:\\
\;\;\;\;im\_m \cdot re\\

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


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

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

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

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

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

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

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

    if 1.08000000000000005e167 < re < 6.4000000000000004e291

    1. Initial program 57.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot im\right)} \cdot re \]
      6. associate-*r*15.7%

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(-im \cdot re\right)} \cdot \left(-1 \cdot \left(im \cdot re\right)\right)} \]
      10. mul-1-neg25.9%

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

        \[\leadsto \sqrt{\color{blue}{\left(im \cdot re\right) \cdot \left(im \cdot re\right)}} \]
      12. sqrt-unprod14.9%

        \[\leadsto \color{blue}{\sqrt{im \cdot re} \cdot \sqrt{im \cdot re}} \]
      13. add-sqr-sqrt29.6%

        \[\leadsto \color{blue}{im \cdot re} \]
      14. expm1-log1p-u15.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(im \cdot re\right)\right)} \]
      15. expm1-udef15.7%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(im \cdot re\right)} - 1} \]
      16. *-commutative15.7%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{re \cdot im}\right)} - 1 \]
    8. Applied egg-rr15.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re \cdot im\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def15.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot im\right)\right)} \]
      2. expm1-log1p29.6%

        \[\leadsto \color{blue}{re \cdot im} \]
    10. Simplified29.6%

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

    if 6.4000000000000004e291 < re

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.08 \cdot 10^{+167}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(im \cdot -2\right)\\ \mathbf{elif}\;re \leq 6.4 \cdot 10^{+291}:\\ \;\;\;\;im \cdot re\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-re\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 21.1% 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 1 im)
(FPCore (im_s re im_m) :precision binary64 (* im_s (* im_m re)))
im_m = fabs(im);
im_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	return im_s * (im_m * re);
}
im_m = abs(im)
im_s = copysign(1.0d0, im)
real(8) function code(im_s, re, im_m)
    real(8), intent (in) :: im_s
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = im_s * (im_m * re)
end function
im_m = Math.abs(im);
im_s = Math.copySign(1.0, im);
public static double code(double im_s, double re, double im_m) {
	return im_s * (im_m * re);
}
im_m = math.fabs(im)
im_s = math.copysign(1.0, im)
def code(im_s, re, im_m):
	return im_s * (im_m * re)
im_m = abs(im)
im_s = copysign(1.0, im)
function code(im_s, re, im_m)
	return Float64(im_s * Float64(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 69.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(im \cdot \left(-2 \cdot 0.5\right)\right)} \cdot re \]
    4. metadata-eval34.1%

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

      \[\leadsto \color{blue}{\left(-1 \cdot im\right)} \cdot re \]
    6. associate-*r*34.1%

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

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

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

      \[\leadsto \sqrt{\color{blue}{\left(-im \cdot re\right)} \cdot \left(-1 \cdot \left(im \cdot re\right)\right)} \]
    10. mul-1-neg33.1%

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

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

      \[\leadsto \color{blue}{\sqrt{im \cdot re} \cdot \sqrt{im \cdot re}} \]
    13. add-sqr-sqrt25.2%

      \[\leadsto \color{blue}{im \cdot re} \]
    14. expm1-log1p-u20.5%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(im \cdot re\right)\right)} \]
    15. expm1-udef20.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(im \cdot re\right)} - 1} \]
    16. *-commutative20.8%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{re \cdot im}\right)} - 1 \]
  8. Applied egg-rr20.8%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re \cdot im\right)} - 1} \]
  9. Step-by-step derivation
    1. expm1-def20.5%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot im\right)\right)} \]
    2. expm1-log1p25.2%

      \[\leadsto \color{blue}{re \cdot im} \]
  10. Simplified25.2%

    \[\leadsto \color{blue}{re \cdot im} \]
  11. Final simplification25.2%

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

Alternative 15: 2.7% accurate, 308.0× speedup?

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

\\
im\_s \cdot -8
\end{array}
Derivation
  1. Initial program 69.5%

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

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
  4. Applied egg-rr2.6%

    \[\leadsto \color{blue}{-8} \]
  5. Final simplification2.6%

    \[\leadsto -8 \]
  6. Add Preprocessing

Alternative 16: 2.8% accurate, 308.0× speedup?

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

\\
im\_s \cdot -6.248825220858479 \cdot 10^{-11}
\end{array}
Derivation
  1. Initial program 69.5%

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

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
  4. Applied egg-rr2.7%

    \[\leadsto \color{blue}{-6.248825220858479 \cdot 10^{-11}} \]
  5. Final simplification2.7%

    \[\leadsto -6.248825220858479 \cdot 10^{-11} \]
  6. Add Preprocessing

Alternative 17: 15.5% accurate, 308.0× speedup?

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

\\
im\_s \cdot 0
\end{array}
Derivation
  1. Initial program 69.5%

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

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(-2 \cdot im + \left(-0.3333333333333333 \cdot {im}^{3} + \left(-0.016666666666666666 \cdot {im}^{5} + -0.0003968253968253968 \cdot {im}^{7}\right)\right)\right)} \]
  4. Applied egg-rr18.7%

    \[\leadsto \color{blue}{0} \]
  5. Final simplification18.7%

    \[\leadsto 0 \]
  6. 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 2024031 
(FPCore (re im)
  :name "math.cos on complex, imaginary part"
  :precision binary64

  :herbie-target
  (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))))