math.cos on complex, imaginary part

Percentage Accurate: 65.9% → 90.5%
Time: 10.5s
Alternatives: 23
Speedup: 2.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 23 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: 90.5% accurate, 1.0× speedup?

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

\\
\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot -0.016666666666666666 - 0.3333333333333333\right) - 2\right)\right)
\end{array}
Derivation
  1. Initial program 61.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 90.3%

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left(-0.016666666666666666 \cdot {im}^{2} - 0.3333333333333333\right) - 2\right)\right)} \]
  4. Final simplification90.3%

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

Alternative 2: 70.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 3.3:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(-0.008333333333333333 \cdot {im}^{5}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 3.3)
   (* (sin re) (- im))
   (* (sin re) (* -0.008333333333333333 (pow im 5.0)))))
double code(double re, double im) {
	double tmp;
	if (im <= 3.3) {
		tmp = sin(re) * -im;
	} else {
		tmp = sin(re) * (-0.008333333333333333 * pow(im, 5.0));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 3.3d0) then
        tmp = sin(re) * -im
    else
        tmp = sin(re) * ((-0.008333333333333333d0) * (im ** 5.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 3.3) {
		tmp = Math.sin(re) * -im;
	} else {
		tmp = Math.sin(re) * (-0.008333333333333333 * Math.pow(im, 5.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 3.3:
		tmp = math.sin(re) * -im
	else:
		tmp = math.sin(re) * (-0.008333333333333333 * math.pow(im, 5.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 3.3)
		tmp = Float64(sin(re) * Float64(-im));
	else
		tmp = Float64(sin(re) * Float64(-0.008333333333333333 * (im ^ 5.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 3.3)
		tmp = sin(re) * -im;
	else
		tmp = sin(re) * (-0.008333333333333333 * (im ^ 5.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 3.3], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(-0.008333333333333333 * N[Power[im, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 50.7%

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

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

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

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

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

    if 3.2999999999999998 < 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 82.5%

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

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

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

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

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

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

Alternative 3: 70.6% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 3.3:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{5} \cdot \left(\sin re \cdot -0.008333333333333333\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 3.3)
   (* (sin re) (- im))
   (* (pow im 5.0) (* (sin re) -0.008333333333333333))))
double code(double re, double im) {
	double tmp;
	if (im <= 3.3) {
		tmp = sin(re) * -im;
	} else {
		tmp = pow(im, 5.0) * (sin(re) * -0.008333333333333333);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 3.3d0) then
        tmp = sin(re) * -im
    else
        tmp = (im ** 5.0d0) * (sin(re) * (-0.008333333333333333d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 3.3) {
		tmp = Math.sin(re) * -im;
	} else {
		tmp = Math.pow(im, 5.0) * (Math.sin(re) * -0.008333333333333333);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 3.3:
		tmp = math.sin(re) * -im
	else:
		tmp = math.pow(im, 5.0) * (math.sin(re) * -0.008333333333333333)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 3.3)
		tmp = Float64(sin(re) * Float64(-im));
	else
		tmp = Float64((im ^ 5.0) * Float64(sin(re) * -0.008333333333333333));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 3.3)
		tmp = sin(re) * -im;
	else
		tmp = (im ^ 5.0) * (sin(re) * -0.008333333333333333);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 3.3], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(N[Power[im, 5.0], $MachinePrecision] * N[(N[Sin[re], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 50.7%

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

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

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

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

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

    if 3.2999999999999998 < 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 82.5%

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

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

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

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

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

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

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

Alternative 4: 90.0% accurate, 1.5× speedup?

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

\\
\sin re \cdot \left(im \cdot \left(-1 + {im}^{4} \cdot -0.008333333333333333\right)\right)
\end{array}
Derivation
  1. Initial program 61.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 90.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(0.5 \cdot im\right) \cdot \left(-0.016666666666666666 \cdot {im}^{4} - 2\right)\right) \cdot \sin re} \]
    4. associate-*r*89.9%

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

      \[\leadsto \left(0.5 \cdot \color{blue}{\left(\left(-0.016666666666666666 \cdot {im}^{4} - 2\right) \cdot im\right)}\right) \cdot \sin re \]
    6. associate-*r*89.9%

      \[\leadsto \color{blue}{\left(\left(0.5 \cdot \left(-0.016666666666666666 \cdot {im}^{4} - 2\right)\right) \cdot im\right)} \cdot \sin re \]
    7. sub-neg89.9%

      \[\leadsto \left(\left(0.5 \cdot \color{blue}{\left(-0.016666666666666666 \cdot {im}^{4} + \left(-2\right)\right)}\right) \cdot im\right) \cdot \sin re \]
    8. metadata-eval89.9%

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

      \[\leadsto \left(\left(0.5 \cdot \color{blue}{\left(-2 + -0.016666666666666666 \cdot {im}^{4}\right)}\right) \cdot im\right) \cdot \sin re \]
    10. distribute-rgt-in89.9%

      \[\leadsto \left(\color{blue}{\left(-2 \cdot 0.5 + \left(-0.016666666666666666 \cdot {im}^{4}\right) \cdot 0.5\right)} \cdot im\right) \cdot \sin re \]
    11. metadata-eval89.9%

      \[\leadsto \left(\left(\color{blue}{-1} + \left(-0.016666666666666666 \cdot {im}^{4}\right) \cdot 0.5\right) \cdot im\right) \cdot \sin re \]
    12. *-commutative89.9%

      \[\leadsto \left(\left(-1 + \color{blue}{\left({im}^{4} \cdot -0.016666666666666666\right)} \cdot 0.5\right) \cdot im\right) \cdot \sin re \]
    13. associate-*l*89.9%

      \[\leadsto \left(\left(-1 + \color{blue}{{im}^{4} \cdot \left(-0.016666666666666666 \cdot 0.5\right)}\right) \cdot im\right) \cdot \sin re \]
    14. metadata-eval89.9%

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

    \[\leadsto \color{blue}{\left(\left(-1 + {im}^{4} \cdot -0.008333333333333333\right) \cdot im\right) \cdot \sin re} \]
  8. Final simplification89.9%

    \[\leadsto \sin re \cdot \left(im \cdot \left(-1 + {im}^{4} \cdot -0.008333333333333333\right)\right) \]
  9. Add Preprocessing

Alternative 5: 83.7% accurate, 1.5× speedup?

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

\\
\sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right)
\end{array}
Derivation
  1. Initial program 61.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 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sin re \cdot \left({im}^{3} \cdot -0.16666666666666666 - im\right) \]
  7. Add Preprocessing

Alternative 6: 65.9% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 1.35 \cdot 10^{+14}:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot \left(-0.016666666666666666 \cdot {im}^{4} - 2\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 1.35e+14)
   (* (sin re) (- im))
   (* 0.5 (* im (* re (- (* -0.016666666666666666 (pow im 4.0)) 2.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 1.35e+14) {
		tmp = sin(re) * -im;
	} else {
		tmp = 0.5 * (im * (re * ((-0.016666666666666666 * pow(im, 4.0)) - 2.0)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 1.35d+14) then
        tmp = sin(re) * -im
    else
        tmp = 0.5d0 * (im * (re * (((-0.016666666666666666d0) * (im ** 4.0d0)) - 2.0d0)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 1.35e+14) {
		tmp = Math.sin(re) * -im;
	} else {
		tmp = 0.5 * (im * (re * ((-0.016666666666666666 * Math.pow(im, 4.0)) - 2.0)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 1.35e+14:
		tmp = math.sin(re) * -im
	else:
		tmp = 0.5 * (im * (re * ((-0.016666666666666666 * math.pow(im, 4.0)) - 2.0)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 1.35e+14)
		tmp = Float64(sin(re) * Float64(-im));
	else
		tmp = Float64(0.5 * Float64(im * Float64(re * Float64(Float64(-0.016666666666666666 * (im ^ 4.0)) - 2.0))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 1.35e+14)
		tmp = sin(re) * -im;
	else
		tmp = 0.5 * (im * (re * ((-0.016666666666666666 * (im ^ 4.0)) - 2.0)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 1.35e+14], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(0.5 * N[(im * N[(re * N[(N[(-0.016666666666666666 * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.35 \cdot 10^{+14}:\\
\;\;\;\;\sin re \cdot \left(-im\right)\\

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


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

    1. Initial program 51.4%

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

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

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

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

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

    if 1.35e14 < 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 86.8%

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

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

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

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

Alternative 7: 64.1% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 5.5 \cdot 10^{-7}:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot \left({im}^{2} \cdot -0.3333333333333333 - 2\right)\right) \cdot \left(0.5 \cdot re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 5.5e-7)
   (* (sin re) (- im))
   (* (* im (- (* (pow im 2.0) -0.3333333333333333) 2.0)) (* 0.5 re))))
double code(double re, double im) {
	double tmp;
	if (im <= 5.5e-7) {
		tmp = sin(re) * -im;
	} else {
		tmp = (im * ((pow(im, 2.0) * -0.3333333333333333) - 2.0)) * (0.5 * re);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 5.5d-7) then
        tmp = sin(re) * -im
    else
        tmp = (im * (((im ** 2.0d0) * (-0.3333333333333333d0)) - 2.0d0)) * (0.5d0 * re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 5.5e-7) {
		tmp = Math.sin(re) * -im;
	} else {
		tmp = (im * ((Math.pow(im, 2.0) * -0.3333333333333333) - 2.0)) * (0.5 * re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 5.5e-7:
		tmp = math.sin(re) * -im
	else:
		tmp = (im * ((math.pow(im, 2.0) * -0.3333333333333333) - 2.0)) * (0.5 * re)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 5.5e-7)
		tmp = Float64(sin(re) * Float64(-im));
	else
		tmp = Float64(Float64(im * Float64(Float64((im ^ 2.0) * -0.3333333333333333) - 2.0)) * Float64(0.5 * re));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 5.5e-7)
		tmp = sin(re) * -im;
	else
		tmp = (im * (((im ^ 2.0) * -0.3333333333333333) - 2.0)) * (0.5 * re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 5.5e-7], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(N[(im * N[(N[(N[Power[im, 2.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.5 \cdot 10^{-7}:\\
\;\;\;\;\sin re \cdot \left(-im\right)\\

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


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

    1. Initial program 50.4%

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

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

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

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

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

    if 5.5000000000000003e-7 < im

    1. Initial program 99.4%

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

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

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

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

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

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

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

Alternative 8: 62.4% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 5.5 \cdot 10^{-7}:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(re \cdot \left(-1 + {im}^{2} \cdot -0.16666666666666666\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 5.5e-7)
   (* (sin re) (- im))
   (* im (* re (+ -1.0 (* (pow im 2.0) -0.16666666666666666))))))
double code(double re, double im) {
	double tmp;
	if (im <= 5.5e-7) {
		tmp = sin(re) * -im;
	} else {
		tmp = im * (re * (-1.0 + (pow(im, 2.0) * -0.16666666666666666)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 5.5d-7) then
        tmp = sin(re) * -im
    else
        tmp = im * (re * ((-1.0d0) + ((im ** 2.0d0) * (-0.16666666666666666d0))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 5.5e-7) {
		tmp = Math.sin(re) * -im;
	} else {
		tmp = im * (re * (-1.0 + (Math.pow(im, 2.0) * -0.16666666666666666)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 5.5e-7:
		tmp = math.sin(re) * -im
	else:
		tmp = im * (re * (-1.0 + (math.pow(im, 2.0) * -0.16666666666666666)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 5.5e-7)
		tmp = Float64(sin(re) * Float64(-im));
	else
		tmp = Float64(im * Float64(re * Float64(-1.0 + Float64((im ^ 2.0) * -0.16666666666666666))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 5.5e-7)
		tmp = sin(re) * -im;
	else
		tmp = im * (re * (-1.0 + ((im ^ 2.0) * -0.16666666666666666)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 5.5e-7], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(im * N[(re * N[(-1.0 + N[(N[Power[im, 2.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.5 \cdot 10^{-7}:\\
\;\;\;\;\sin re \cdot \left(-im\right)\\

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


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

    1. Initial program 50.4%

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

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

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

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

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

    if 5.5000000000000003e-7 < im

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

Alternative 9: 65.9% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 4.3 \cdot 10^{+14}:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(re \cdot \left(-1 + {im}^{4} \cdot -0.008333333333333333\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 4.3e+14)
   (* (sin re) (- im))
   (* im (* re (+ -1.0 (* (pow im 4.0) -0.008333333333333333))))))
double code(double re, double im) {
	double tmp;
	if (im <= 4.3e+14) {
		tmp = sin(re) * -im;
	} else {
		tmp = im * (re * (-1.0 + (pow(im, 4.0) * -0.008333333333333333)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 4.3d+14) then
        tmp = sin(re) * -im
    else
        tmp = im * (re * ((-1.0d0) + ((im ** 4.0d0) * (-0.008333333333333333d0))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 4.3e+14) {
		tmp = Math.sin(re) * -im;
	} else {
		tmp = im * (re * (-1.0 + (Math.pow(im, 4.0) * -0.008333333333333333)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 4.3e+14:
		tmp = math.sin(re) * -im
	else:
		tmp = im * (re * (-1.0 + (math.pow(im, 4.0) * -0.008333333333333333)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 4.3e+14)
		tmp = Float64(sin(re) * Float64(-im));
	else
		tmp = Float64(im * Float64(re * Float64(-1.0 + Float64((im ^ 4.0) * -0.008333333333333333))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 4.3e+14)
		tmp = sin(re) * -im;
	else
		tmp = im * (re * (-1.0 + ((im ^ 4.0) * -0.008333333333333333)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 4.3e+14], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(im * N[(re * N[(-1.0 + N[(N[Power[im, 4.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.3 \cdot 10^{+14}:\\
\;\;\;\;\sin re \cdot \left(-im\right)\\

\mathbf{else}:\\
\;\;\;\;im \cdot \left(re \cdot \left(-1 + {im}^{4} \cdot -0.008333333333333333\right)\right)\\


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

    1. Initial program 51.4%

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

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

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

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

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

    if 4.3e14 < 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 86.8%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(0.5 \cdot im\right) \cdot \left(-0.016666666666666666 \cdot {im}^{4} - 2\right)\right) \cdot \sin re} \]
      4. associate-*r*86.8%

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

        \[\leadsto \left(0.5 \cdot \color{blue}{\left(\left(-0.016666666666666666 \cdot {im}^{4} - 2\right) \cdot im\right)}\right) \cdot \sin re \]
      6. associate-*r*86.8%

        \[\leadsto \color{blue}{\left(\left(0.5 \cdot \left(-0.016666666666666666 \cdot {im}^{4} - 2\right)\right) \cdot im\right)} \cdot \sin re \]
      7. sub-neg86.8%

        \[\leadsto \left(\left(0.5 \cdot \color{blue}{\left(-0.016666666666666666 \cdot {im}^{4} + \left(-2\right)\right)}\right) \cdot im\right) \cdot \sin re \]
      8. metadata-eval86.8%

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

        \[\leadsto \left(\left(0.5 \cdot \color{blue}{\left(-2 + -0.016666666666666666 \cdot {im}^{4}\right)}\right) \cdot im\right) \cdot \sin re \]
      10. distribute-rgt-in86.8%

        \[\leadsto \left(\color{blue}{\left(-2 \cdot 0.5 + \left(-0.016666666666666666 \cdot {im}^{4}\right) \cdot 0.5\right)} \cdot im\right) \cdot \sin re \]
      11. metadata-eval86.8%

        \[\leadsto \left(\left(\color{blue}{-1} + \left(-0.016666666666666666 \cdot {im}^{4}\right) \cdot 0.5\right) \cdot im\right) \cdot \sin re \]
      12. *-commutative86.8%

        \[\leadsto \left(\left(-1 + \color{blue}{\left({im}^{4} \cdot -0.016666666666666666\right)} \cdot 0.5\right) \cdot im\right) \cdot \sin re \]
      13. associate-*l*86.8%

        \[\leadsto \left(\left(-1 + \color{blue}{{im}^{4} \cdot \left(-0.016666666666666666 \cdot 0.5\right)}\right) \cdot im\right) \cdot \sin re \]
      14. metadata-eval86.8%

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

      \[\leadsto \color{blue}{\left(\left(-1 + {im}^{4} \cdot -0.008333333333333333\right) \cdot im\right) \cdot \sin re} \]
    8. Taylor expanded in re around 0 65.2%

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

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

Alternative 10: 66.3% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 1.75 \cdot 10^{+15}:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(im \cdot \left(-1 + {im}^{4} \cdot -0.008333333333333333\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 1.75e+15)
   (* (sin re) (- im))
   (* re (* im (+ -1.0 (* (pow im 4.0) -0.008333333333333333))))))
double code(double re, double im) {
	double tmp;
	if (im <= 1.75e+15) {
		tmp = sin(re) * -im;
	} else {
		tmp = re * (im * (-1.0 + (pow(im, 4.0) * -0.008333333333333333)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 1.75d+15) then
        tmp = sin(re) * -im
    else
        tmp = re * (im * ((-1.0d0) + ((im ** 4.0d0) * (-0.008333333333333333d0))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 1.75e+15) {
		tmp = Math.sin(re) * -im;
	} else {
		tmp = re * (im * (-1.0 + (Math.pow(im, 4.0) * -0.008333333333333333)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 1.75e+15:
		tmp = math.sin(re) * -im
	else:
		tmp = re * (im * (-1.0 + (math.pow(im, 4.0) * -0.008333333333333333)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 1.75e+15)
		tmp = Float64(sin(re) * Float64(-im));
	else
		tmp = Float64(re * Float64(im * Float64(-1.0 + Float64((im ^ 4.0) * -0.008333333333333333))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 1.75e+15)
		tmp = sin(re) * -im;
	else
		tmp = re * (im * (-1.0 + ((im ^ 4.0) * -0.008333333333333333)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 1.75e+15], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(re * N[(im * N[(-1.0 + N[(N[Power[im, 4.0], $MachinePrecision] * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;re \cdot \left(im \cdot \left(-1 + {im}^{4} \cdot -0.008333333333333333\right)\right)\\


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

    1. Initial program 51.4%

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

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

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

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

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

    if 1.75e15 < 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 86.8%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(0.5 \cdot im\right) \cdot \left(-0.016666666666666666 \cdot {im}^{4} - 2\right)\right) \cdot re} \]
      4. associate-*r*67.1%

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

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

        \[\leadsto re \cdot \left(0.5 \cdot \color{blue}{\left(\left(-0.016666666666666666 \cdot {im}^{4} - 2\right) \cdot im\right)}\right) \]
      7. associate-*r*67.1%

        \[\leadsto re \cdot \color{blue}{\left(\left(0.5 \cdot \left(-0.016666666666666666 \cdot {im}^{4} - 2\right)\right) \cdot im\right)} \]
      8. sub-neg67.1%

        \[\leadsto re \cdot \left(\left(0.5 \cdot \color{blue}{\left(-0.016666666666666666 \cdot {im}^{4} + \left(-2\right)\right)}\right) \cdot im\right) \]
      9. metadata-eval67.1%

        \[\leadsto re \cdot \left(\left(0.5 \cdot \left(-0.016666666666666666 \cdot {im}^{4} + \color{blue}{-2}\right)\right) \cdot im\right) \]
      10. +-commutative67.1%

        \[\leadsto re \cdot \left(\left(0.5 \cdot \color{blue}{\left(-2 + -0.016666666666666666 \cdot {im}^{4}\right)}\right) \cdot im\right) \]
      11. distribute-rgt-in67.1%

        \[\leadsto re \cdot \left(\color{blue}{\left(-2 \cdot 0.5 + \left(-0.016666666666666666 \cdot {im}^{4}\right) \cdot 0.5\right)} \cdot im\right) \]
      12. metadata-eval67.1%

        \[\leadsto re \cdot \left(\left(\color{blue}{-1} + \left(-0.016666666666666666 \cdot {im}^{4}\right) \cdot 0.5\right) \cdot im\right) \]
      13. *-commutative67.1%

        \[\leadsto re \cdot \left(\left(-1 + \color{blue}{\left({im}^{4} \cdot -0.016666666666666666\right)} \cdot 0.5\right) \cdot im\right) \]
      14. associate-*l*67.1%

        \[\leadsto re \cdot \left(\left(-1 + \color{blue}{{im}^{4} \cdot \left(-0.016666666666666666 \cdot 0.5\right)}\right) \cdot im\right) \]
      15. metadata-eval67.1%

        \[\leadsto re \cdot \left(\left(-1 + {im}^{4} \cdot \color{blue}{-0.008333333333333333}\right) \cdot im\right) \]
    7. Simplified67.1%

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

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

Alternative 11: 56.1% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 5800:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(im \cdot \left(0.16666666666666666 \cdot {re}^{2}\right) - im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 5800.0)
   (* (sin re) (- im))
   (* re (- (* im (* 0.16666666666666666 (pow re 2.0))) im))))
double code(double re, double im) {
	double tmp;
	if (im <= 5800.0) {
		tmp = sin(re) * -im;
	} else {
		tmp = re * ((im * (0.16666666666666666 * pow(re, 2.0))) - im);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 5800.0d0) then
        tmp = sin(re) * -im
    else
        tmp = re * ((im * (0.16666666666666666d0 * (re ** 2.0d0))) - im)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 5800.0) {
		tmp = Math.sin(re) * -im;
	} else {
		tmp = re * ((im * (0.16666666666666666 * Math.pow(re, 2.0))) - im);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 5800.0:
		tmp = math.sin(re) * -im
	else:
		tmp = re * ((im * (0.16666666666666666 * math.pow(re, 2.0))) - im)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 5800.0)
		tmp = Float64(sin(re) * Float64(-im));
	else
		tmp = Float64(re * Float64(Float64(im * Float64(0.16666666666666666 * (re ^ 2.0))) - im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 5800.0)
		tmp = sin(re) * -im;
	else
		tmp = re * ((im * (0.16666666666666666 * (re ^ 2.0))) - im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 5800.0], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(re * N[(N[(im * N[(0.16666666666666666 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 50.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 69.3%

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

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

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

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

    if 5800 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 62.4% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 5.5 \cdot 10^{-7}:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(-0.16666666666666666 \cdot \left(re \cdot {im}^{2}\right) - re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 5.5e-7)
   (* (sin re) (- im))
   (* im (- (* -0.16666666666666666 (* re (pow im 2.0))) re))))
double code(double re, double im) {
	double tmp;
	if (im <= 5.5e-7) {
		tmp = sin(re) * -im;
	} else {
		tmp = im * ((-0.16666666666666666 * (re * pow(im, 2.0))) - re);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 5.5d-7) then
        tmp = sin(re) * -im
    else
        tmp = im * (((-0.16666666666666666d0) * (re * (im ** 2.0d0))) - re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 5.5e-7) {
		tmp = Math.sin(re) * -im;
	} else {
		tmp = im * ((-0.16666666666666666 * (re * Math.pow(im, 2.0))) - re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 5.5e-7:
		tmp = math.sin(re) * -im
	else:
		tmp = im * ((-0.16666666666666666 * (re * math.pow(im, 2.0))) - re)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 5.5e-7)
		tmp = Float64(sin(re) * Float64(-im));
	else
		tmp = Float64(im * Float64(Float64(-0.16666666666666666 * Float64(re * (im ^ 2.0))) - re));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 5.5e-7)
		tmp = sin(re) * -im;
	else
		tmp = im * ((-0.16666666666666666 * (re * (im ^ 2.0))) - re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 5.5e-7], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(im * N[(N[(-0.16666666666666666 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.5 \cdot 10^{-7}:\\
\;\;\;\;\sin re \cdot \left(-im\right)\\

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


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

    1. Initial program 50.4%

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

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

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

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

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

    if 5.5000000000000003e-7 < im

    1. Initial program 99.4%

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

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

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

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

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

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

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

Alternative 13: 56.1% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 5800:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.16666666666666666 \cdot \left(im \cdot {re}^{2}\right) - im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 5800.0)
   (* (sin re) (- im))
   (* re (- (* 0.16666666666666666 (* im (pow re 2.0))) im))))
double code(double re, double im) {
	double tmp;
	if (im <= 5800.0) {
		tmp = sin(re) * -im;
	} else {
		tmp = re * ((0.16666666666666666 * (im * pow(re, 2.0))) - im);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 5800.0d0) then
        tmp = sin(re) * -im
    else
        tmp = re * ((0.16666666666666666d0 * (im * (re ** 2.0d0))) - im)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 5800.0) {
		tmp = Math.sin(re) * -im;
	} else {
		tmp = re * ((0.16666666666666666 * (im * Math.pow(re, 2.0))) - im);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 5800.0:
		tmp = math.sin(re) * -im
	else:
		tmp = re * ((0.16666666666666666 * (im * math.pow(re, 2.0))) - im)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 5800.0)
		tmp = Float64(sin(re) * Float64(-im));
	else
		tmp = Float64(re * Float64(Float64(0.16666666666666666 * Float64(im * (re ^ 2.0))) - im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 5800.0)
		tmp = sin(re) * -im;
	else
		tmp = re * ((0.16666666666666666 * (im * (re ^ 2.0))) - im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 5800.0], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(re * N[(N[(0.16666666666666666 * N[(im * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 50.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 69.3%

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

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

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

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

    if 5800 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 14: 62.5% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 9.5 \cdot 10^{+14}:\\
\;\;\;\;\sin re \cdot \left(-im\right)\\

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


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

    1. Initial program 51.4%

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

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

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

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

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

    if 9.5e14 < 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 59.1%

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

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

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

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

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

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

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

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

Alternative 15: 64.1% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.5 \cdot 10^{-7}:\\
\;\;\;\;\sin re \cdot \left(-im\right)\\

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


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

    1. Initial program 50.4%

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

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

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

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

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

    if 5.5000000000000003e-7 < im

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 64.2% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.15 \cdot 10^{+16}:\\
\;\;\;\;\sin re \cdot \left(-im\right)\\

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


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

    1. Initial program 51.4%

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

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

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

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

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

    if 1.15e16 < 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 59.1%

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

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

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

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

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

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

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

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

Alternative 17: 64.2% accurate, 2.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 9.8 \cdot 10^{+14}:\\
\;\;\;\;\sin re \cdot \left(-im\right)\\

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


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

    1. Initial program 51.4%

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

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

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

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

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

    if 9.8e14 < 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 59.1%

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

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

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

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

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

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

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

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

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

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

Alternative 18: 55.8% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 5800:\\ \;\;\;\;\sin re \cdot \left(-im\right)\\ \mathbf{else}:\\ \;\;\;\;{re}^{3} \cdot \left(im \cdot 0.16666666666666666\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 5800.0)
   (* (sin re) (- im))
   (* (pow re 3.0) (* im 0.16666666666666666))))
double code(double re, double im) {
	double tmp;
	if (im <= 5800.0) {
		tmp = sin(re) * -im;
	} else {
		tmp = pow(re, 3.0) * (im * 0.16666666666666666);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 5800.0d0) then
        tmp = sin(re) * -im
    else
        tmp = (re ** 3.0d0) * (im * 0.16666666666666666d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 5800.0) {
		tmp = Math.sin(re) * -im;
	} else {
		tmp = Math.pow(re, 3.0) * (im * 0.16666666666666666);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 5800.0:
		tmp = math.sin(re) * -im
	else:
		tmp = math.pow(re, 3.0) * (im * 0.16666666666666666)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 5800.0)
		tmp = Float64(sin(re) * Float64(-im));
	else
		tmp = Float64((re ^ 3.0) * Float64(im * 0.16666666666666666));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 5800.0)
		tmp = sin(re) * -im;
	else
		tmp = (re ^ 3.0) * (im * 0.16666666666666666);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 5800.0], N[(N[Sin[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(N[Power[re, 3.0], $MachinePrecision] * N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 50.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 69.3%

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

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

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

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

    if 5800 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 19: 51.6% accurate, 3.0× speedup?

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

\\
\sin re \cdot \left(-im\right)
\end{array}
Derivation
  1. Initial program 61.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 55.8%

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

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

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

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

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

Alternative 20: 32.7% accurate, 77.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 21: 2.7% accurate, 308.0× speedup?

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

\\
-512
\end{array}
Derivation
  1. Initial program 61.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 90.3%

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

    \[\leadsto \color{blue}{-512} \]
  5. Final simplification2.7%

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

Alternative 22: 2.8% accurate, 308.0× speedup?

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

\\
-4.6296296296296296 \cdot 10^{-6}
\end{array}
Derivation
  1. Initial program 61.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 90.3%

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

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

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

Alternative 23: 15.0% accurate, 308.0× speedup?

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

\\
0
\end{array}
Derivation
  1. Initial program 61.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 90.3%

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

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

    \[\leadsto 0 \]
  6. Add Preprocessing

Developer target: 99.7% 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 2024066 
(FPCore (re im)
  :name "math.cos on complex, imaginary part"
  :precision binary64

  :alt
  (if (< (fabs im) 1.0) (- (* (sin re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))

  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))