math.cos on complex, imaginary part

Percentage Accurate: 67.0% → 99.9%
Time: 10.0s
Alternatives: 19
Speedup: 1.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

Alternative 1: 99.9% accurate, 1.5× speedup?

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

\\
\sinh \left(-im\right) \cdot \sin re
\end{array}
Derivation
  1. Initial program 66.5%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \sin re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    3. associate-*l*N/A

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(\sin re \cdot \left(e^{-im} - e^{im}\right)\right)} \]
    4. *-commutativeN/A

      \[\leadsto \color{blue}{\left(\sin re \cdot \left(e^{-im} - e^{im}\right)\right) \cdot \frac{1}{2}} \]
    5. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(\sin re \cdot \left(e^{-im} - e^{im}\right)\right) \cdot \frac{1}{2}} \]
    6. lower-*.f6466.5

      \[\leadsto \color{blue}{\left(\sin re \cdot \left(e^{-im} - e^{im}\right)\right)} \cdot 0.5 \]
    7. lift--.f64N/A

      \[\leadsto \left(\sin re \cdot \color{blue}{\left(e^{-im} - e^{im}\right)}\right) \cdot \frac{1}{2} \]
    8. lift-exp.f64N/A

      \[\leadsto \left(\sin re \cdot \left(\color{blue}{e^{-im}} - e^{im}\right)\right) \cdot \frac{1}{2} \]
    9. lift-exp.f64N/A

      \[\leadsto \left(\sin re \cdot \left(e^{-im} - \color{blue}{e^{im}}\right)\right) \cdot \frac{1}{2} \]
    10. remove-double-negN/A

      \[\leadsto \left(\sin re \cdot \left(e^{-im} - e^{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(im\right)\right)\right)}}\right)\right) \cdot \frac{1}{2} \]
    11. lift-neg.f64N/A

      \[\leadsto \left(\sin re \cdot \left(e^{-im} - e^{\mathsf{neg}\left(\color{blue}{\left(-im\right)}\right)}\right)\right) \cdot \frac{1}{2} \]
    12. sinh-undefN/A

      \[\leadsto \left(\sin re \cdot \color{blue}{\left(2 \cdot \sinh \left(-im\right)\right)}\right) \cdot \frac{1}{2} \]
    13. lower-*.f64N/A

      \[\leadsto \left(\sin re \cdot \color{blue}{\left(2 \cdot \sinh \left(-im\right)\right)}\right) \cdot \frac{1}{2} \]
    14. lower-sinh.f6499.9

      \[\leadsto \left(\sin re \cdot \left(2 \cdot \color{blue}{\sinh \left(-im\right)}\right)\right) \cdot 0.5 \]
  4. Applied rewrites99.9%

    \[\leadsto \color{blue}{\left(\sin re \cdot \left(2 \cdot \sinh \left(-im\right)\right)\right) \cdot 0.5} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(\sin re \cdot \left(2 \cdot \sinh \left(-im\right)\right)\right) \cdot \frac{1}{2}} \]
    2. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(\sin re \cdot \left(2 \cdot \sinh \left(-im\right)\right)\right)} \cdot \frac{1}{2} \]
    3. associate-*l*N/A

      \[\leadsto \color{blue}{\sin re \cdot \left(\left(2 \cdot \sinh \left(-im\right)\right) \cdot \frac{1}{2}\right)} \]
    4. lift-*.f64N/A

      \[\leadsto \sin re \cdot \left(\color{blue}{\left(2 \cdot \sinh \left(-im\right)\right)} \cdot \frac{1}{2}\right) \]
    5. *-commutativeN/A

      \[\leadsto \sin re \cdot \left(\color{blue}{\left(\sinh \left(-im\right) \cdot 2\right)} \cdot \frac{1}{2}\right) \]
    6. associate-*l*N/A

      \[\leadsto \sin re \cdot \color{blue}{\left(\sinh \left(-im\right) \cdot \left(2 \cdot \frac{1}{2}\right)\right)} \]
    7. metadata-evalN/A

      \[\leadsto \sin re \cdot \left(\sinh \left(-im\right) \cdot \color{blue}{1}\right) \]
    8. metadata-evalN/A

      \[\leadsto \sin re \cdot \left(\sinh \left(-im\right) \cdot \color{blue}{\frac{2}{2}}\right) \]
    9. associate-/l*N/A

      \[\leadsto \sin re \cdot \color{blue}{\frac{\sinh \left(-im\right) \cdot 2}{2}} \]
    10. *-commutativeN/A

      \[\leadsto \sin re \cdot \frac{\color{blue}{2 \cdot \sinh \left(-im\right)}}{2} \]
    11. lift-sinh.f64N/A

      \[\leadsto \sin re \cdot \frac{2 \cdot \color{blue}{\sinh \left(-im\right)}}{2} \]
    12. sinh-undef-revN/A

      \[\leadsto \sin re \cdot \frac{\color{blue}{e^{-im} - e^{\mathsf{neg}\left(\left(-im\right)\right)}}}{2} \]
    13. sinh-defN/A

      \[\leadsto \sin re \cdot \color{blue}{\sinh \left(-im\right)} \]
    14. lift-sinh.f64N/A

      \[\leadsto \sin re \cdot \color{blue}{\sinh \left(-im\right)} \]
    15. *-commutativeN/A

      \[\leadsto \color{blue}{\sinh \left(-im\right) \cdot \sin re} \]
    16. lower-*.f6499.9

      \[\leadsto \color{blue}{\sinh \left(-im\right) \cdot \sin re} \]
  6. Applied rewrites99.9%

    \[\leadsto \color{blue}{\sinh \left(-im\right) \cdot \sin re} \]
  7. Add Preprocessing

Alternative 2: 84.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-306}:\\ \;\;\;\;\left(\sinh im \cdot -2\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;t\_0 \leq 10^{-7}:\\ \;\;\;\;\left(\sin re \cdot im\right) \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot im, im, -1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
   (if (<= t_0 -5e-306)
     (* (* (sinh im) -2.0) (* 0.5 re))
     (if (<= t_0 1e-7)
       (* (* (sin re) im) (fma (* -0.16666666666666666 im) im -1.0))
       (*
        (* (fma (* re re) -0.08333333333333333 0.5) re)
        (*
         (-
          (*
           (-
            (*
             (*
              (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666)
              im)
             im)
            0.3333333333333333)
           (* im im))
          2.0)
         im))))))
double code(double re, double im) {
	double t_0 = (0.5 * sin(re)) * (exp(-im) - exp(im));
	double tmp;
	if (t_0 <= -5e-306) {
		tmp = (sinh(im) * -2.0) * (0.5 * re);
	} else if (t_0 <= 1e-7) {
		tmp = (sin(re) * im) * fma((-0.16666666666666666 * im), im, -1.0);
	} else {
		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im)))
	tmp = 0.0
	if (t_0 <= -5e-306)
		tmp = Float64(Float64(sinh(im) * -2.0) * Float64(0.5 * re));
	elseif (t_0 <= 1e-7)
		tmp = Float64(Float64(sin(re) * im) * fma(Float64(-0.16666666666666666 * im), im, -1.0));
	else
		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-306], N[(N[(N[Sinh[im], $MachinePrecision] * -2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-7], N[(N[(N[Sin[re], $MachinePrecision] * im), $MachinePrecision] * N[(N[(-0.16666666666666666 * im), $MachinePrecision] * im + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-306}:\\
\;\;\;\;\left(\sinh im \cdot -2\right) \cdot \left(0.5 \cdot re\right)\\

\mathbf{elif}\;t\_0 \leq 10^{-7}:\\
\;\;\;\;\left(\sin re \cdot im\right) \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot im, im, -1\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -4.99999999999999998e-306

    1. Initial program 97.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

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    4. Step-by-step derivation
      1. lower-*.f6474.8

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \color{blue}{\left(e^{-im} - e^{im}\right)} \]
      3. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(\color{blue}{e^{-im}} - e^{im}\right) \]
      4. lift-neg.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\color{blue}{\mathsf{neg}\left(im\right)}} - e^{im}\right) \]
      5. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\mathsf{neg}\left(im\right)} - \color{blue}{e^{im}}\right) \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
      8. lift-neg.f64N/A

        \[\leadsto \left(e^{\color{blue}{-im}} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      9. remove-double-negN/A

        \[\leadsto \left(e^{-im} - e^{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(im\right)\right)\right)}}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      10. lift-neg.f64N/A

        \[\leadsto \left(e^{-im} - e^{\mathsf{neg}\left(\color{blue}{\left(-im\right)}\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      11. sinh-undef-revN/A

        \[\leadsto \color{blue}{\left(2 \cdot \sinh \left(-im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \left(2 \cdot \sinh \color{blue}{\left(\mathsf{neg}\left(im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      13. sinh-negN/A

        \[\leadsto \left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      14. distribute-rgt-neg-outN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      15. lower-neg.f64N/A

        \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      16. lower-*.f64N/A

        \[\leadsto \left(-\color{blue}{2 \cdot \sinh im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      17. lower-sinh.f6476.8

        \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot \left(0.5 \cdot re\right) \]
    7. Applied rewrites76.8%

      \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \left(0.5 \cdot re\right)} \]
    8. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      2. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{2 \cdot \sinh im}\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      3. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\sinh im \cdot 2}\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{\left(\sinh im \cdot \left(\mathsf{neg}\left(2\right)\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\sinh im \cdot \left(\mathsf{neg}\left(2\right)\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      6. metadata-eval76.8

        \[\leadsto \left(\sinh im \cdot \color{blue}{-2}\right) \cdot \left(0.5 \cdot re\right) \]
    9. Applied rewrites76.8%

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

    if -4.99999999999999998e-306 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 9.9999999999999995e-8

    1. Initial program 32.2%

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

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

        \[\leadsto im \cdot \color{blue}{\left(\frac{-1}{6} \cdot \left({im}^{2} \cdot \sin re\right) + -1 \cdot \sin re\right)} \]
      2. *-commutativeN/A

        \[\leadsto im \cdot \left(\frac{-1}{6} \cdot \color{blue}{\left(\sin re \cdot {im}^{2}\right)} + -1 \cdot \sin re\right) \]
      3. associate-*r*N/A

        \[\leadsto im \cdot \left(\color{blue}{\left(\frac{-1}{6} \cdot \sin re\right) \cdot {im}^{2}} + -1 \cdot \sin re\right) \]
      4. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\left(\left(\frac{-1}{6} \cdot \sin re\right) \cdot {im}^{2}\right) \cdot im + \left(-1 \cdot \sin re\right) \cdot im} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re\right)\right)} \cdot im + \left(-1 \cdot \sin re\right) \cdot im \]
      6. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left({im}^{2} \cdot \frac{-1}{6}\right) \cdot \sin re\right)} \cdot im + \left(-1 \cdot \sin re\right) \cdot im \]
      7. unpow2N/A

        \[\leadsto \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{-1}{6}\right) \cdot \sin re\right) \cdot im + \left(-1 \cdot \sin re\right) \cdot im \]
      8. associate-*r*N/A

        \[\leadsto \left(\color{blue}{\left(im \cdot \left(im \cdot \frac{-1}{6}\right)\right)} \cdot \sin re\right) \cdot im + \left(-1 \cdot \sin re\right) \cdot im \]
      9. *-commutativeN/A

        \[\leadsto \left(\left(im \cdot \color{blue}{\left(\frac{-1}{6} \cdot im\right)}\right) \cdot \sin re\right) \cdot im + \left(-1 \cdot \sin re\right) \cdot im \]
      10. associate-*l*N/A

        \[\leadsto \color{blue}{\left(im \cdot \left(\frac{-1}{6} \cdot im\right)\right) \cdot \left(\sin re \cdot im\right)} + \left(-1 \cdot \sin re\right) \cdot im \]
      11. *-commutativeN/A

        \[\leadsto \left(im \cdot \left(\frac{-1}{6} \cdot im\right)\right) \cdot \color{blue}{\left(im \cdot \sin re\right)} + \left(-1 \cdot \sin re\right) \cdot im \]
      12. associate-*r*N/A

        \[\leadsto \left(im \cdot \left(\frac{-1}{6} \cdot im\right)\right) \cdot \left(im \cdot \sin re\right) + \color{blue}{-1 \cdot \left(\sin re \cdot im\right)} \]
      13. *-commutativeN/A

        \[\leadsto \left(im \cdot \left(\frac{-1}{6} \cdot im\right)\right) \cdot \left(im \cdot \sin re\right) + -1 \cdot \color{blue}{\left(im \cdot \sin re\right)} \]
      14. distribute-rgt-outN/A

        \[\leadsto \color{blue}{\left(im \cdot \sin re\right) \cdot \left(im \cdot \left(\frac{-1}{6} \cdot im\right) + -1\right)} \]
    5. Applied rewrites99.8%

      \[\leadsto \color{blue}{\left(\sin re \cdot im\right) \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot im, im, -1\right)} \]

    if 9.9999999999999995e-8 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
      3. lower--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left(\frac{-1}{3} \cdot {im}^{2} - 2\right)} \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
      5. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
      6. unpow2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. lower-*.f6478.5

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

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

      \[\leadsto \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right)\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      3. +-commutativeN/A

        \[\leadsto \left(\color{blue}{\left(\frac{-1}{12} \cdot {re}^{2} + \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left({re}^{2}, \frac{-1}{12}, \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      6. unpow2N/A

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. lower-*.f6467.7

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    8. Applied rewrites67.7%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    9. Taylor expanded in im around 0

      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
    11. Applied rewrites77.7%

      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 84.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-306}:\\ \;\;\;\;\left(\sinh im \cdot -2\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;t\_0 \leq 10^{-7}:\\ \;\;\;\;\left(-\sin re\right) \cdot im\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
   (if (<= t_0 -5e-306)
     (* (* (sinh im) -2.0) (* 0.5 re))
     (if (<= t_0 1e-7)
       (* (- (sin re)) im)
       (*
        (* (fma (* re re) -0.08333333333333333 0.5) re)
        (*
         (-
          (*
           (-
            (*
             (*
              (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666)
              im)
             im)
            0.3333333333333333)
           (* im im))
          2.0)
         im))))))
double code(double re, double im) {
	double t_0 = (0.5 * sin(re)) * (exp(-im) - exp(im));
	double tmp;
	if (t_0 <= -5e-306) {
		tmp = (sinh(im) * -2.0) * (0.5 * re);
	} else if (t_0 <= 1e-7) {
		tmp = -sin(re) * im;
	} else {
		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im)))
	tmp = 0.0
	if (t_0 <= -5e-306)
		tmp = Float64(Float64(sinh(im) * -2.0) * Float64(0.5 * re));
	elseif (t_0 <= 1e-7)
		tmp = Float64(Float64(-sin(re)) * im);
	else
		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-306], N[(N[(N[Sinh[im], $MachinePrecision] * -2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-7], N[((-N[Sin[re], $MachinePrecision]) * im), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-306}:\\
\;\;\;\;\left(\sinh im \cdot -2\right) \cdot \left(0.5 \cdot re\right)\\

\mathbf{elif}\;t\_0 \leq 10^{-7}:\\
\;\;\;\;\left(-\sin re\right) \cdot im\\

\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -4.99999999999999998e-306

    1. Initial program 97.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

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    4. Step-by-step derivation
      1. lower-*.f6474.8

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \color{blue}{\left(e^{-im} - e^{im}\right)} \]
      3. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(\color{blue}{e^{-im}} - e^{im}\right) \]
      4. lift-neg.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\color{blue}{\mathsf{neg}\left(im\right)}} - e^{im}\right) \]
      5. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\mathsf{neg}\left(im\right)} - \color{blue}{e^{im}}\right) \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
      8. lift-neg.f64N/A

        \[\leadsto \left(e^{\color{blue}{-im}} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      9. remove-double-negN/A

        \[\leadsto \left(e^{-im} - e^{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(im\right)\right)\right)}}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      10. lift-neg.f64N/A

        \[\leadsto \left(e^{-im} - e^{\mathsf{neg}\left(\color{blue}{\left(-im\right)}\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      11. sinh-undef-revN/A

        \[\leadsto \color{blue}{\left(2 \cdot \sinh \left(-im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \left(2 \cdot \sinh \color{blue}{\left(\mathsf{neg}\left(im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      13. sinh-negN/A

        \[\leadsto \left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      14. distribute-rgt-neg-outN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      15. lower-neg.f64N/A

        \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      16. lower-*.f64N/A

        \[\leadsto \left(-\color{blue}{2 \cdot \sinh im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      17. lower-sinh.f6476.8

        \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot \left(0.5 \cdot re\right) \]
    7. Applied rewrites76.8%

      \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \left(0.5 \cdot re\right)} \]
    8. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      2. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{2 \cdot \sinh im}\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      3. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\sinh im \cdot 2}\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{\left(\sinh im \cdot \left(\mathsf{neg}\left(2\right)\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\sinh im \cdot \left(\mathsf{neg}\left(2\right)\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      6. metadata-eval76.8

        \[\leadsto \left(\sinh im \cdot \color{blue}{-2}\right) \cdot \left(0.5 \cdot re\right) \]
    9. Applied rewrites76.8%

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

    if -4.99999999999999998e-306 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 9.9999999999999995e-8

    1. Initial program 32.2%

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

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
      2. associate-*r*N/A

        \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
      3. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
      4. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
      5. lower-neg.f64N/A

        \[\leadsto \color{blue}{\left(-\sin re\right)} \cdot im \]
      6. lower-sin.f6499.3

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

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

    if 9.9999999999999995e-8 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
      3. lower--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left(\frac{-1}{3} \cdot {im}^{2} - 2\right)} \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
      5. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
      6. unpow2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. lower-*.f6478.5

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

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

      \[\leadsto \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right)\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      3. +-commutativeN/A

        \[\leadsto \left(\color{blue}{\left(\frac{-1}{12} \cdot {re}^{2} + \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left({re}^{2}, \frac{-1}{12}, \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      6. unpow2N/A

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. lower-*.f6467.7

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    8. Applied rewrites67.7%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    9. Taylor expanded in im around 0

      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
    11. Applied rewrites77.7%

      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 82.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-306}:\\ \;\;\;\;\left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, im \cdot im, 0.016666666666666666\right), im \cdot im, 0.3333333333333333\right), im \cdot im, 2\right) \cdot im\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;t\_0 \leq 10^{-7}:\\ \;\;\;\;\left(-\sin re\right) \cdot im\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
   (if (<= t_0 -5e-306)
     (*
      (-
       (*
        (fma
         (fma
          (fma 0.0003968253968253968 (* im im) 0.016666666666666666)
          (* im im)
          0.3333333333333333)
         (* im im)
         2.0)
        im))
      (* 0.5 re))
     (if (<= t_0 1e-7)
       (* (- (sin re)) im)
       (*
        (* (fma (* re re) -0.08333333333333333 0.5) re)
        (*
         (-
          (*
           (-
            (*
             (*
              (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666)
              im)
             im)
            0.3333333333333333)
           (* im im))
          2.0)
         im))))))
double code(double re, double im) {
	double t_0 = (0.5 * sin(re)) * (exp(-im) - exp(im));
	double tmp;
	if (t_0 <= -5e-306) {
		tmp = -(fma(fma(fma(0.0003968253968253968, (im * im), 0.016666666666666666), (im * im), 0.3333333333333333), (im * im), 2.0) * im) * (0.5 * re);
	} else if (t_0 <= 1e-7) {
		tmp = -sin(re) * im;
	} else {
		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im)))
	tmp = 0.0
	if (t_0 <= -5e-306)
		tmp = Float64(Float64(-Float64(fma(fma(fma(0.0003968253968253968, Float64(im * im), 0.016666666666666666), Float64(im * im), 0.3333333333333333), Float64(im * im), 2.0) * im)) * Float64(0.5 * re));
	elseif (t_0 <= 1e-7)
		tmp = Float64(Float64(-sin(re)) * im);
	else
		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-306], N[((-N[(N[(N[(N[(0.0003968253968253968 * N[(im * im), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] * N[(im * im), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision] + 2.0), $MachinePrecision] * im), $MachinePrecision]) * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-7], N[((-N[Sin[re], $MachinePrecision]) * im), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-306}:\\
\;\;\;\;\left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, im \cdot im, 0.016666666666666666\right), im \cdot im, 0.3333333333333333\right), im \cdot im, 2\right) \cdot im\right) \cdot \left(0.5 \cdot re\right)\\

\mathbf{elif}\;t\_0 \leq 10^{-7}:\\
\;\;\;\;\left(-\sin re\right) \cdot im\\

\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -4.99999999999999998e-306

    1. Initial program 97.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

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    4. Step-by-step derivation
      1. lower-*.f6474.8

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \color{blue}{\left(e^{-im} - e^{im}\right)} \]
      3. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(\color{blue}{e^{-im}} - e^{im}\right) \]
      4. lift-neg.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\color{blue}{\mathsf{neg}\left(im\right)}} - e^{im}\right) \]
      5. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\mathsf{neg}\left(im\right)} - \color{blue}{e^{im}}\right) \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
      8. lift-neg.f64N/A

        \[\leadsto \left(e^{\color{blue}{-im}} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      9. remove-double-negN/A

        \[\leadsto \left(e^{-im} - e^{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(im\right)\right)\right)}}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      10. lift-neg.f64N/A

        \[\leadsto \left(e^{-im} - e^{\mathsf{neg}\left(\color{blue}{\left(-im\right)}\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      11. sinh-undef-revN/A

        \[\leadsto \color{blue}{\left(2 \cdot \sinh \left(-im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \left(2 \cdot \sinh \color{blue}{\left(\mathsf{neg}\left(im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      13. sinh-negN/A

        \[\leadsto \left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      14. distribute-rgt-neg-outN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      15. lower-neg.f64N/A

        \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      16. lower-*.f64N/A

        \[\leadsto \left(-\color{blue}{2 \cdot \sinh im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      17. lower-sinh.f6476.8

        \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot \left(0.5 \cdot re\right) \]
    7. Applied rewrites76.8%

      \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \left(0.5 \cdot re\right)} \]
    8. Taylor expanded in im around 0

      \[\leadsto \left(-\color{blue}{im \cdot \left(2 + {im}^{2} \cdot \left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(-\color{blue}{\left(2 + {im}^{2} \cdot \left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right)\right) \cdot im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      2. lower-*.f64N/A

        \[\leadsto \left(-\color{blue}{\left(2 + {im}^{2} \cdot \left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right)\right) \cdot im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      3. +-commutativeN/A

        \[\leadsto \left(-\color{blue}{\left({im}^{2} \cdot \left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right) + 2\right)} \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(-\left(\color{blue}{\left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right) \cdot {im}^{2}} + 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \left(-\color{blue}{\mathsf{fma}\left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right), {im}^{2}, 2\right)} \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      6. +-commutativeN/A

        \[\leadsto \left(-\mathsf{fma}\left(\color{blue}{{im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right) + \frac{1}{3}}, {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      7. *-commutativeN/A

        \[\leadsto \left(-\mathsf{fma}\left(\color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right) \cdot {im}^{2}} + \frac{1}{3}, {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      8. lower-fma.f64N/A

        \[\leadsto \left(-\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}, {im}^{2}, \frac{1}{3}\right)}, {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      9. +-commutativeN/A

        \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\frac{1}{2520} \cdot {im}^{2} + \frac{1}{60}}, {im}^{2}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      10. lower-fma.f64N/A

        \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{2520}, {im}^{2}, \frac{1}{60}\right)}, {im}^{2}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      11. unpow2N/A

        \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \color{blue}{im \cdot im}, \frac{1}{60}\right), {im}^{2}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      12. lower-*.f64N/A

        \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \color{blue}{im \cdot im}, \frac{1}{60}\right), {im}^{2}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      13. unpow2N/A

        \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, im \cdot im, \frac{1}{60}\right), \color{blue}{im \cdot im}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      14. lower-*.f64N/A

        \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, im \cdot im, \frac{1}{60}\right), \color{blue}{im \cdot im}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      15. unpow2N/A

        \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, im \cdot im, \frac{1}{60}\right), im \cdot im, \frac{1}{3}\right), \color{blue}{im \cdot im}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      16. lower-*.f6465.2

        \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, im \cdot im, 0.016666666666666666\right), im \cdot im, 0.3333333333333333\right), \color{blue}{im \cdot im}, 2\right) \cdot im\right) \cdot \left(0.5 \cdot re\right) \]
    10. Applied rewrites65.2%

      \[\leadsto \left(-\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, im \cdot im, 0.016666666666666666\right), im \cdot im, 0.3333333333333333\right), im \cdot im, 2\right) \cdot im}\right) \cdot \left(0.5 \cdot re\right) \]

    if -4.99999999999999998e-306 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 9.9999999999999995e-8

    1. Initial program 32.2%

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

      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
      2. associate-*r*N/A

        \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
      3. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
      4. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
      5. lower-neg.f64N/A

        \[\leadsto \color{blue}{\left(-\sin re\right)} \cdot im \]
      6. lower-sin.f6499.3

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

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

    if 9.9999999999999995e-8 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
      3. lower--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left(\frac{-1}{3} \cdot {im}^{2} - 2\right)} \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
      5. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
      6. unpow2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. lower-*.f6478.5

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

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

      \[\leadsto \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right)\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      3. +-commutativeN/A

        \[\leadsto \left(\color{blue}{\left(\frac{-1}{12} \cdot {re}^{2} + \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left({re}^{2}, \frac{-1}{12}, \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      6. unpow2N/A

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. lower-*.f6467.7

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    8. Applied rewrites67.7%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    9. Taylor expanded in im around 0

      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
    11. Applied rewrites77.7%

      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 89.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ \mathbf{if}\;t\_0 \cdot \left(e^{-im} - e^{im}\right) \leq -5 \cdot 10^{-306}:\\ \;\;\;\;\left(\sinh im \cdot -2\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (sin re))))
   (if (<= (* t_0 (- (exp (- im)) (exp im))) -5e-306)
     (* (* (sinh im) -2.0) (* 0.5 re))
     (*
      t_0
      (*
       (-
        (*
         (-
          (*
           (* (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666) im)
           im)
          0.3333333333333333)
         (* im im))
        2.0)
       im)))))
double code(double re, double im) {
	double t_0 = 0.5 * sin(re);
	double tmp;
	if ((t_0 * (exp(-im) - exp(im))) <= -5e-306) {
		tmp = (sinh(im) * -2.0) * (0.5 * re);
	} else {
		tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 0.5d0 * sin(re)
    if ((t_0 * (exp(-im) - exp(im))) <= (-5d-306)) then
        tmp = (sinh(im) * (-2.0d0)) * (0.5d0 * re)
    else
        tmp = t_0 * (((((((((-0.0003968253968253968d0) * (im * im)) - 0.016666666666666666d0) * im) * im) - 0.3333333333333333d0) * (im * im)) - 2.0d0) * im)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = 0.5 * Math.sin(re);
	double tmp;
	if ((t_0 * (Math.exp(-im) - Math.exp(im))) <= -5e-306) {
		tmp = (Math.sinh(im) * -2.0) * (0.5 * re);
	} else {
		tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
	}
	return tmp;
}
def code(re, im):
	t_0 = 0.5 * math.sin(re)
	tmp = 0
	if (t_0 * (math.exp(-im) - math.exp(im))) <= -5e-306:
		tmp = (math.sinh(im) * -2.0) * (0.5 * re)
	else:
		tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im)
	return tmp
function code(re, im)
	t_0 = Float64(0.5 * sin(re))
	tmp = 0.0
	if (Float64(t_0 * Float64(exp(Float64(-im)) - exp(im))) <= -5e-306)
		tmp = Float64(Float64(sinh(im) * -2.0) * Float64(0.5 * re));
	else
		tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = 0.5 * sin(re);
	tmp = 0.0;
	if ((t_0 * (exp(-im) - exp(im))) <= -5e-306)
		tmp = (sinh(im) * -2.0) * (0.5 * re);
	else
		tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-306], N[(N[(N[Sinh[im], $MachinePrecision] * -2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;t\_0 \cdot \left(e^{-im} - e^{im}\right) \leq -5 \cdot 10^{-306}:\\
\;\;\;\;\left(\sinh im \cdot -2\right) \cdot \left(0.5 \cdot re\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -4.99999999999999998e-306

    1. Initial program 97.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

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    4. Step-by-step derivation
      1. lower-*.f6474.8

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \color{blue}{\left(e^{-im} - e^{im}\right)} \]
      3. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(\color{blue}{e^{-im}} - e^{im}\right) \]
      4. lift-neg.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\color{blue}{\mathsf{neg}\left(im\right)}} - e^{im}\right) \]
      5. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\mathsf{neg}\left(im\right)} - \color{blue}{e^{im}}\right) \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
      8. lift-neg.f64N/A

        \[\leadsto \left(e^{\color{blue}{-im}} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      9. remove-double-negN/A

        \[\leadsto \left(e^{-im} - e^{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(im\right)\right)\right)}}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      10. lift-neg.f64N/A

        \[\leadsto \left(e^{-im} - e^{\mathsf{neg}\left(\color{blue}{\left(-im\right)}\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      11. sinh-undef-revN/A

        \[\leadsto \color{blue}{\left(2 \cdot \sinh \left(-im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \left(2 \cdot \sinh \color{blue}{\left(\mathsf{neg}\left(im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      13. sinh-negN/A

        \[\leadsto \left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      14. distribute-rgt-neg-outN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      15. lower-neg.f64N/A

        \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      16. lower-*.f64N/A

        \[\leadsto \left(-\color{blue}{2 \cdot \sinh im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      17. lower-sinh.f6476.8

        \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot \left(0.5 \cdot re\right) \]
    7. Applied rewrites76.8%

      \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \left(0.5 \cdot re\right)} \]
    8. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      2. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{2 \cdot \sinh im}\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      3. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\sinh im \cdot 2}\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{\left(\sinh im \cdot \left(\mathsf{neg}\left(2\right)\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\sinh im \cdot \left(\mathsf{neg}\left(2\right)\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      6. metadata-eval76.8

        \[\leadsto \left(\sinh im \cdot \color{blue}{-2}\right) \cdot \left(0.5 \cdot re\right) \]
    9. Applied rewrites76.8%

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

    if -4.99999999999999998e-306 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)))

    1. Initial program 56.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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
    5. Applied rewrites96.9%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 88.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \leq -\infty:\\ \;\;\;\;\left(\sinh im \cdot -2\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(-0.008333333333333333, im \cdot im, -0.16666666666666666\right), -1\right)\right) \cdot im\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))) (- INFINITY))
   (* (* (sinh im) -2.0) (* 0.5 re))
   (*
    (*
     (sin re)
     (fma
      (* im im)
      (fma -0.008333333333333333 (* im im) -0.16666666666666666)
      -1.0))
    im)))
double code(double re, double im) {
	double tmp;
	if (((0.5 * sin(re)) * (exp(-im) - exp(im))) <= -((double) INFINITY)) {
		tmp = (sinh(im) * -2.0) * (0.5 * re);
	} else {
		tmp = (sin(re) * fma((im * im), fma(-0.008333333333333333, (im * im), -0.16666666666666666), -1.0)) * im;
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) <= Float64(-Inf))
		tmp = Float64(Float64(sinh(im) * -2.0) * Float64(0.5 * re));
	else
		tmp = Float64(Float64(sin(re) * fma(Float64(im * im), fma(-0.008333333333333333, Float64(im * im), -0.16666666666666666), -1.0)) * im);
	end
	return tmp
end
code[re_, im_] := If[LessEqual[N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(N[Sinh[im], $MachinePrecision] * -2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[re], $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * N[(-0.008333333333333333 * N[(im * im), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] * im), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \leq -\infty:\\
\;\;\;\;\left(\sinh im \cdot -2\right) \cdot \left(0.5 \cdot re\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(-0.008333333333333333, im \cdot im, -0.16666666666666666\right), -1\right)\right) \cdot im\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -inf.0

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    4. Step-by-step derivation
      1. lower-*.f6476.3

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \color{blue}{\left(e^{-im} - e^{im}\right)} \]
      3. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(\color{blue}{e^{-im}} - e^{im}\right) \]
      4. lift-neg.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\color{blue}{\mathsf{neg}\left(im\right)}} - e^{im}\right) \]
      5. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\mathsf{neg}\left(im\right)} - \color{blue}{e^{im}}\right) \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
      8. lift-neg.f64N/A

        \[\leadsto \left(e^{\color{blue}{-im}} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      9. remove-double-negN/A

        \[\leadsto \left(e^{-im} - e^{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(im\right)\right)\right)}}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      10. lift-neg.f64N/A

        \[\leadsto \left(e^{-im} - e^{\mathsf{neg}\left(\color{blue}{\left(-im\right)}\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      11. sinh-undef-revN/A

        \[\leadsto \color{blue}{\left(2 \cdot \sinh \left(-im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \left(2 \cdot \sinh \color{blue}{\left(\mathsf{neg}\left(im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      13. sinh-negN/A

        \[\leadsto \left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      14. distribute-rgt-neg-outN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      15. lower-neg.f64N/A

        \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      16. lower-*.f64N/A

        \[\leadsto \left(-\color{blue}{2 \cdot \sinh im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      17. lower-sinh.f6476.3

        \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot \left(0.5 \cdot re\right) \]
    7. Applied rewrites76.3%

      \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \left(0.5 \cdot re\right)} \]
    8. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      2. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{2 \cdot \sinh im}\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      3. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\sinh im \cdot 2}\right)\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{\left(\sinh im \cdot \left(\mathsf{neg}\left(2\right)\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\sinh im \cdot \left(\mathsf{neg}\left(2\right)\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      6. metadata-eval76.3

        \[\leadsto \left(\sinh im \cdot \color{blue}{-2}\right) \cdot \left(0.5 \cdot re\right) \]
    9. Applied rewrites76.3%

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

    if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im)))

    1. Initial program 56.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

      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
    5. Applied rewrites95.0%

      \[\leadsto \color{blue}{\left(\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(-0.008333333333333333, im \cdot im, -0.16666666666666666\right), -1\right)\right) \cdot im} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 59.5% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq 5 \cdot 10^{-15}:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(0.004166666666666667 \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= (sin re) 5e-15)
   (*
    (* (fma (* re re) -0.08333333333333333 0.5) re)
    (*
     (-
      (*
       (-
        (*
         (* (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666) im)
         im)
        0.3333333333333333)
       (* im im))
      2.0)
     im))
   (*
    (*
     (fma
      (- (* 0.004166666666666667 (* re re)) 0.08333333333333333)
      (* re re)
      0.5)
     re)
    (*
     (-
      (* (* (- (* -0.016666666666666666 (* im im)) 0.3333333333333333) im) im)
      2.0)
     im))))
double code(double re, double im) {
	double tmp;
	if (sin(re) <= 5e-15) {
		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
	} else {
		tmp = (fma(((0.004166666666666667 * (re * re)) - 0.08333333333333333), (re * re), 0.5) * re) * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (sin(re) <= 5e-15)
		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im));
	else
		tmp = Float64(Float64(fma(Float64(Float64(0.004166666666666667 * Float64(re * re)) - 0.08333333333333333), Float64(re * re), 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(-0.016666666666666666 * Float64(im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], 5e-15], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(0.004166666666666667 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.08333333333333333), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(-0.016666666666666666 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\sin re \leq 5 \cdot 10^{-15}:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.004166666666666667 \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)\\


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

    1. Initial program 70.8%

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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
      3. lower--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left(\frac{-1}{3} \cdot {im}^{2} - 2\right)} \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
      5. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
      6. unpow2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. lower-*.f6486.3

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    5. Applied rewrites86.3%

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

      \[\leadsto \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right)\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      3. +-commutativeN/A

        \[\leadsto \left(\color{blue}{\left(\frac{-1}{12} \cdot {re}^{2} + \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left({re}^{2}, \frac{-1}{12}, \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      6. unpow2N/A

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. lower-*.f6469.9

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    8. Applied rewrites69.9%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    9. Taylor expanded in im around 0

      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
    11. Applied rewrites75.2%

      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \]

    if 4.99999999999999999e-15 < (sin.f64 re)

    1. Initial program 48.2%

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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) - 2\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
      3. lower--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) - 2\right)} \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) \cdot {im}^{2}} - 2\right) \cdot im\right) \]
      5. unpow2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) \cdot \color{blue}{\left(im \cdot im\right)} - 2\right) \cdot im\right) \]
      6. associate-*r*N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) \cdot im\right) \cdot im} - 2\right) \cdot im\right) \]
      7. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) \cdot im\right) \cdot im} - 2\right) \cdot im\right) \]
      8. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) \cdot im\right)} \cdot im - 2\right) \cdot im\right) \]
      9. lower--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\color{blue}{\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right)} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      10. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\left(\color{blue}{\frac{-1}{60} \cdot {im}^{2}} - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      11. unpow2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \color{blue}{\left(im \cdot im\right)} - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      12. lower-*.f6490.2

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

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

      \[\leadsto \color{blue}{\left(re \cdot \left(\frac{1}{2} + {re}^{2} \cdot \left(\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}\right)\right)\right)} \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + {re}^{2} \cdot \left(\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}\right)\right) \cdot re\right)} \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + {re}^{2} \cdot \left(\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}\right)\right) \cdot re\right)} \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      3. +-commutativeN/A

        \[\leadsto \left(\color{blue}{\left({re}^{2} \cdot \left(\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}\right) + \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\left(\color{blue}{\left(\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}\right) \cdot {re}^{2}} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left(\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}, {re}^{2}, \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      6. lower--.f64N/A

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}}, {re}^{2}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      7. lower-*.f64N/A

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{\frac{1}{240} \cdot {re}^{2}} - \frac{1}{12}, {re}^{2}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      8. unpow2N/A

        \[\leadsto \left(\mathsf{fma}\left(\frac{1}{240} \cdot \color{blue}{\left(re \cdot re\right)} - \frac{1}{12}, {re}^{2}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      9. lower-*.f64N/A

        \[\leadsto \left(\mathsf{fma}\left(\frac{1}{240} \cdot \color{blue}{\left(re \cdot re\right)} - \frac{1}{12}, {re}^{2}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      10. unpow2N/A

        \[\leadsto \left(\mathsf{fma}\left(\frac{1}{240} \cdot \left(re \cdot re\right) - \frac{1}{12}, \color{blue}{re \cdot re}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      11. lower-*.f6425.3

        \[\leadsto \left(\mathsf{fma}\left(0.004166666666666667 \cdot \left(re \cdot re\right) - 0.08333333333333333, \color{blue}{re \cdot re}, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
    8. Applied rewrites25.3%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(0.004166666666666667 \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 59.4% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq 5 \cdot 10^{-15}:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\mathsf{fma}\left(0.004166666666666667 \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \cdot \left(\left(\left(-0.3333333333333333 \cdot im\right) \cdot im - 2\right) \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= (sin re) 5e-15)
   (*
    (* (fma (* re re) -0.08333333333333333 0.5) re)
    (*
     (-
      (*
       (-
        (*
         (* (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666) im)
         im)
        0.3333333333333333)
       (* im im))
      2.0)
     im))
   (*
    (*
     (fma
      (- (* 0.004166666666666667 (* re re)) 0.08333333333333333)
      (* re re)
      0.5)
     re)
    (* (- (* (* -0.3333333333333333 im) im) 2.0) im))))
double code(double re, double im) {
	double tmp;
	if (sin(re) <= 5e-15) {
		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
	} else {
		tmp = (fma(((0.004166666666666667 * (re * re)) - 0.08333333333333333), (re * re), 0.5) * re) * ((((-0.3333333333333333 * im) * im) - 2.0) * im);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (sin(re) <= 5e-15)
		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im));
	else
		tmp = Float64(Float64(fma(Float64(Float64(0.004166666666666667 * Float64(re * re)) - 0.08333333333333333), Float64(re * re), 0.5) * re) * Float64(Float64(Float64(Float64(-0.3333333333333333 * im) * im) - 2.0) * im));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], 5e-15], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(0.004166666666666667 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.08333333333333333), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(-0.3333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\sin re \leq 5 \cdot 10^{-15}:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.004166666666666667 \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \cdot \left(\left(\left(-0.3333333333333333 \cdot im\right) \cdot im - 2\right) \cdot im\right)\\


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

    1. Initial program 70.8%

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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
      3. lower--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left(\frac{-1}{3} \cdot {im}^{2} - 2\right)} \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
      5. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
      6. unpow2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. lower-*.f6486.3

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    5. Applied rewrites86.3%

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

      \[\leadsto \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right)\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      3. +-commutativeN/A

        \[\leadsto \left(\color{blue}{\left(\frac{-1}{12} \cdot {re}^{2} + \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left({re}^{2}, \frac{-1}{12}, \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      6. unpow2N/A

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. lower-*.f6469.9

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    8. Applied rewrites69.9%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    9. Taylor expanded in im around 0

      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right)\right)} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{-1}{2520} \cdot {im}^{2} - \frac{1}{60}\right) - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
    11. Applied rewrites75.2%

      \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \color{blue}{\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)} \]

    if 4.99999999999999999e-15 < (sin.f64 re)

    1. Initial program 48.2%

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

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
      3. lower--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left(\frac{-1}{3} \cdot {im}^{2} - 2\right)} \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
      5. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
      6. unpow2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. lower-*.f6488.1

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    5. Applied rewrites88.1%

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

      \[\leadsto \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right)\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      3. +-commutativeN/A

        \[\leadsto \left(\color{blue}{\left(\frac{-1}{12} \cdot {re}^{2} + \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left({re}^{2}, \frac{-1}{12}, \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      6. unpow2N/A

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. lower-*.f6432.0

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    8. Applied rewrites32.0%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
    9. Step-by-step derivation
      1. Applied rewrites32.0%

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(-0.3333333333333333 \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      2. Taylor expanded in re around 0

        \[\leadsto \color{blue}{\left(re \cdot \left(\frac{1}{2} + {re}^{2} \cdot \left(\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}\right)\right)\right)} \cdot \left(\left(\left(\frac{-1}{3} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      3. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + {re}^{2} \cdot \left(\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}\right)\right) \cdot re\right)} \cdot \left(\left(\left(\frac{-1}{3} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        2. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + {re}^{2} \cdot \left(\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}\right)\right) \cdot re\right)} \cdot \left(\left(\left(\frac{-1}{3} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        3. +-commutativeN/A

          \[\leadsto \left(\color{blue}{\left({re}^{2} \cdot \left(\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}\right) + \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(\frac{-1}{3} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        4. *-commutativeN/A

          \[\leadsto \left(\left(\color{blue}{\left(\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}\right) \cdot {re}^{2}} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\frac{-1}{3} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        5. lower-fma.f64N/A

          \[\leadsto \left(\color{blue}{\mathsf{fma}\left(\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}, {re}^{2}, \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(\frac{-1}{3} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        6. lower--.f64N/A

          \[\leadsto \left(\mathsf{fma}\left(\color{blue}{\frac{1}{240} \cdot {re}^{2} - \frac{1}{12}}, {re}^{2}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\frac{-1}{3} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        7. lower-*.f64N/A

          \[\leadsto \left(\mathsf{fma}\left(\color{blue}{\frac{1}{240} \cdot {re}^{2}} - \frac{1}{12}, {re}^{2}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\frac{-1}{3} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        8. unpow2N/A

          \[\leadsto \left(\mathsf{fma}\left(\frac{1}{240} \cdot \color{blue}{\left(re \cdot re\right)} - \frac{1}{12}, {re}^{2}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\frac{-1}{3} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        9. lower-*.f64N/A

          \[\leadsto \left(\mathsf{fma}\left(\frac{1}{240} \cdot \color{blue}{\left(re \cdot re\right)} - \frac{1}{12}, {re}^{2}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\frac{-1}{3} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        10. unpow2N/A

          \[\leadsto \left(\mathsf{fma}\left(\frac{1}{240} \cdot \left(re \cdot re\right) - \frac{1}{12}, \color{blue}{re \cdot re}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\frac{-1}{3} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        11. lower-*.f6425.3

          \[\leadsto \left(\mathsf{fma}\left(0.004166666666666667 \cdot \left(re \cdot re\right) - 0.08333333333333333, \color{blue}{re \cdot re}, 0.5\right) \cdot re\right) \cdot \left(\left(\left(-0.3333333333333333 \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      4. Applied rewrites25.3%

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(0.004166666666666667 \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(-0.3333333333333333 \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
    10. Recombined 2 regimes into one program.
    11. Add Preprocessing

    Alternative 9: 59.3% accurate, 2.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq -0.0005:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, im \cdot im, 0.016666666666666666\right), im \cdot im, 0.3333333333333333\right), im \cdot im, 2\right) \cdot im\right) \cdot \left(0.5 \cdot re\right)\\ \end{array} \end{array} \]
    (FPCore (re im)
     :precision binary64
     (if (<= (sin re) -0.0005)
       (*
        (* (fma (* re re) -0.08333333333333333 0.5) re)
        (*
         (-
          (* (* (- (* -0.016666666666666666 (* im im)) 0.3333333333333333) im) im)
          2.0)
         im))
       (*
        (-
         (*
          (fma
           (fma
            (fma 0.0003968253968253968 (* im im) 0.016666666666666666)
            (* im im)
            0.3333333333333333)
           (* im im)
           2.0)
          im))
        (* 0.5 re))))
    double code(double re, double im) {
    	double tmp;
    	if (sin(re) <= -0.0005) {
    		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im);
    	} else {
    		tmp = -(fma(fma(fma(0.0003968253968253968, (im * im), 0.016666666666666666), (im * im), 0.3333333333333333), (im * im), 2.0) * im) * (0.5 * re);
    	}
    	return tmp;
    }
    
    function code(re, im)
    	tmp = 0.0
    	if (sin(re) <= -0.0005)
    		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(-0.016666666666666666 * Float64(im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im));
    	else
    		tmp = Float64(Float64(-Float64(fma(fma(fma(0.0003968253968253968, Float64(im * im), 0.016666666666666666), Float64(im * im), 0.3333333333333333), Float64(im * im), 2.0) * im)) * Float64(0.5 * re));
    	end
    	return tmp
    end
    
    code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], -0.0005], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(-0.016666666666666666 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[((-N[(N[(N[(N[(0.0003968253968253968 * N[(im * im), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] * N[(im * im), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision] + 2.0), $MachinePrecision] * im), $MachinePrecision]) * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\sin re \leq -0.0005:\\
    \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, im \cdot im, 0.016666666666666666\right), im \cdot im, 0.3333333333333333\right), im \cdot im, 2\right) \cdot im\right) \cdot \left(0.5 \cdot re\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (sin.f64 re) < -5.0000000000000001e-4

      1. Initial program 62.6%

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) - 2\right)\right)} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
        2. lower-*.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) - 2\right) \cdot im\right)} \]
        3. lower--.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left({im}^{2} \cdot \left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) - 2\right)} \cdot im\right) \]
        4. *-commutativeN/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) \cdot {im}^{2}} - 2\right) \cdot im\right) \]
        5. unpow2N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) \cdot \color{blue}{\left(im \cdot im\right)} - 2\right) \cdot im\right) \]
        6. associate-*r*N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) \cdot im\right) \cdot im} - 2\right) \cdot im\right) \]
        7. lower-*.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) \cdot im\right) \cdot im} - 2\right) \cdot im\right) \]
        8. lower-*.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right) \cdot im\right)} \cdot im - 2\right) \cdot im\right) \]
        9. lower--.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\color{blue}{\left(\frac{-1}{60} \cdot {im}^{2} - \frac{1}{3}\right)} \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        10. lower-*.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\left(\color{blue}{\frac{-1}{60} \cdot {im}^{2}} - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        11. unpow2N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \color{blue}{\left(im \cdot im\right)} - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        12. lower-*.f6485.4

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

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

        \[\leadsto \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right)\right)} \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      7. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        2. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        3. +-commutativeN/A

          \[\leadsto \left(\color{blue}{\left(\frac{-1}{12} \cdot {re}^{2} + \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        4. *-commutativeN/A

          \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        5. lower-fma.f64N/A

          \[\leadsto \left(\color{blue}{\mathsf{fma}\left({re}^{2}, \frac{-1}{12}, \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        6. unpow2N/A

          \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(\left(\frac{-1}{60} \cdot \left(im \cdot im\right) - \frac{1}{3}\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
        7. lower-*.f6429.8

          \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]
      8. Applied rewrites29.8%

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right) \]

      if -5.0000000000000001e-4 < (sin.f64 re)

      1. Initial program 67.8%

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

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
      4. Step-by-step derivation
        1. lower-*.f6461.0

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

        \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
      6. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
        2. lift--.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \color{blue}{\left(e^{-im} - e^{im}\right)} \]
        3. lift-exp.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(\color{blue}{e^{-im}} - e^{im}\right) \]
        4. lift-neg.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\color{blue}{\mathsf{neg}\left(im\right)}} - e^{im}\right) \]
        5. lift-exp.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\mathsf{neg}\left(im\right)} - \color{blue}{e^{im}}\right) \]
        6. *-commutativeN/A

          \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
        7. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
        8. lift-neg.f64N/A

          \[\leadsto \left(e^{\color{blue}{-im}} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        9. remove-double-negN/A

          \[\leadsto \left(e^{-im} - e^{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(im\right)\right)\right)}}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        10. lift-neg.f64N/A

          \[\leadsto \left(e^{-im} - e^{\mathsf{neg}\left(\color{blue}{\left(-im\right)}\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        11. sinh-undef-revN/A

          \[\leadsto \color{blue}{\left(2 \cdot \sinh \left(-im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
        12. lift-neg.f64N/A

          \[\leadsto \left(2 \cdot \sinh \color{blue}{\left(\mathsf{neg}\left(im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        13. sinh-negN/A

          \[\leadsto \left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        14. distribute-rgt-neg-outN/A

          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
        15. lower-neg.f64N/A

          \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
        16. lower-*.f64N/A

          \[\leadsto \left(-\color{blue}{2 \cdot \sinh im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        17. lower-sinh.f6480.8

          \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot \left(0.5 \cdot re\right) \]
      7. Applied rewrites80.8%

        \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \left(0.5 \cdot re\right)} \]
      8. Taylor expanded in im around 0

        \[\leadsto \left(-\color{blue}{im \cdot \left(2 + {im}^{2} \cdot \left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
      9. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \left(-\color{blue}{\left(2 + {im}^{2} \cdot \left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right)\right) \cdot im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        2. lower-*.f64N/A

          \[\leadsto \left(-\color{blue}{\left(2 + {im}^{2} \cdot \left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right)\right) \cdot im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        3. +-commutativeN/A

          \[\leadsto \left(-\color{blue}{\left({im}^{2} \cdot \left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right) + 2\right)} \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        4. *-commutativeN/A

          \[\leadsto \left(-\left(\color{blue}{\left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right) \cdot {im}^{2}} + 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        5. lower-fma.f64N/A

          \[\leadsto \left(-\color{blue}{\mathsf{fma}\left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right), {im}^{2}, 2\right)} \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        6. +-commutativeN/A

          \[\leadsto \left(-\mathsf{fma}\left(\color{blue}{{im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right) + \frac{1}{3}}, {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        7. *-commutativeN/A

          \[\leadsto \left(-\mathsf{fma}\left(\color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right) \cdot {im}^{2}} + \frac{1}{3}, {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        8. lower-fma.f64N/A

          \[\leadsto \left(-\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}, {im}^{2}, \frac{1}{3}\right)}, {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        9. +-commutativeN/A

          \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\frac{1}{2520} \cdot {im}^{2} + \frac{1}{60}}, {im}^{2}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        10. lower-fma.f64N/A

          \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{2520}, {im}^{2}, \frac{1}{60}\right)}, {im}^{2}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        11. unpow2N/A

          \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \color{blue}{im \cdot im}, \frac{1}{60}\right), {im}^{2}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        12. lower-*.f64N/A

          \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \color{blue}{im \cdot im}, \frac{1}{60}\right), {im}^{2}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        13. unpow2N/A

          \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, im \cdot im, \frac{1}{60}\right), \color{blue}{im \cdot im}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        14. lower-*.f64N/A

          \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, im \cdot im, \frac{1}{60}\right), \color{blue}{im \cdot im}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        15. unpow2N/A

          \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, im \cdot im, \frac{1}{60}\right), im \cdot im, \frac{1}{3}\right), \color{blue}{im \cdot im}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        16. lower-*.f6477.7

          \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, im \cdot im, 0.016666666666666666\right), im \cdot im, 0.3333333333333333\right), \color{blue}{im \cdot im}, 2\right) \cdot im\right) \cdot \left(0.5 \cdot re\right) \]
      10. Applied rewrites77.7%

        \[\leadsto \left(-\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, im \cdot im, 0.016666666666666666\right), im \cdot im, 0.3333333333333333\right), im \cdot im, 2\right) \cdot im}\right) \cdot \left(0.5 \cdot re\right) \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 10: 59.2% accurate, 2.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq -0.0005:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(-0.3333333333333333 \cdot im\right) \cdot im - 2\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, im \cdot im, 0.016666666666666666\right), im \cdot im, 0.3333333333333333\right), im \cdot im, 2\right) \cdot im\right) \cdot \left(0.5 \cdot re\right)\\ \end{array} \end{array} \]
    (FPCore (re im)
     :precision binary64
     (if (<= (sin re) -0.0005)
       (*
        (* (fma (* re re) -0.08333333333333333 0.5) re)
        (* (- (* (* -0.3333333333333333 im) im) 2.0) im))
       (*
        (-
         (*
          (fma
           (fma
            (fma 0.0003968253968253968 (* im im) 0.016666666666666666)
            (* im im)
            0.3333333333333333)
           (* im im)
           2.0)
          im))
        (* 0.5 re))))
    double code(double re, double im) {
    	double tmp;
    	if (sin(re) <= -0.0005) {
    		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((-0.3333333333333333 * im) * im) - 2.0) * im);
    	} else {
    		tmp = -(fma(fma(fma(0.0003968253968253968, (im * im), 0.016666666666666666), (im * im), 0.3333333333333333), (im * im), 2.0) * im) * (0.5 * re);
    	}
    	return tmp;
    }
    
    function code(re, im)
    	tmp = 0.0
    	if (sin(re) <= -0.0005)
    		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(-0.3333333333333333 * im) * im) - 2.0) * im));
    	else
    		tmp = Float64(Float64(-Float64(fma(fma(fma(0.0003968253968253968, Float64(im * im), 0.016666666666666666), Float64(im * im), 0.3333333333333333), Float64(im * im), 2.0) * im)) * Float64(0.5 * re));
    	end
    	return tmp
    end
    
    code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], -0.0005], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(-0.3333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[((-N[(N[(N[(N[(0.0003968253968253968 * N[(im * im), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] * N[(im * im), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision] + 2.0), $MachinePrecision] * im), $MachinePrecision]) * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\sin re \leq -0.0005:\\
    \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(-0.3333333333333333 \cdot im\right) \cdot im - 2\right) \cdot im\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, im \cdot im, 0.016666666666666666\right), im \cdot im, 0.3333333333333333\right), im \cdot im, 2\right) \cdot im\right) \cdot \left(0.5 \cdot re\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (sin.f64 re) < -5.0000000000000001e-4

      1. Initial program 62.6%

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

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right)} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
        2. lower-*.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
        3. lower--.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left(\frac{-1}{3} \cdot {im}^{2} - 2\right)} \cdot im\right) \]
        4. *-commutativeN/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
        5. lower-*.f64N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
        6. unpow2N/A

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
        7. lower-*.f6481.1

          \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
      5. Applied rewrites81.1%

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

        \[\leadsto \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right)\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
      7. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
        2. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
        3. +-commutativeN/A

          \[\leadsto \left(\color{blue}{\left(\frac{-1}{12} \cdot {re}^{2} + \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
        4. *-commutativeN/A

          \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
        5. lower-fma.f64N/A

          \[\leadsto \left(\color{blue}{\mathsf{fma}\left({re}^{2}, \frac{-1}{12}, \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
        6. unpow2N/A

          \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
        7. lower-*.f6429.8

          \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
      8. Applied rewrites29.8%

        \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
      9. Step-by-step derivation
        1. Applied rewrites29.8%

          \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(-0.3333333333333333 \cdot im\right) \cdot im - 2\right) \cdot im\right) \]

        if -5.0000000000000001e-4 < (sin.f64 re)

        1. Initial program 67.8%

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

          \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
        4. Step-by-step derivation
          1. lower-*.f6461.0

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

          \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} - e^{im}\right) \]
        6. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right) \cdot \left(e^{-im} - e^{im}\right)} \]
          2. lift--.f64N/A

            \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \color{blue}{\left(e^{-im} - e^{im}\right)} \]
          3. lift-exp.f64N/A

            \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(\color{blue}{e^{-im}} - e^{im}\right) \]
          4. lift-neg.f64N/A

            \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\color{blue}{\mathsf{neg}\left(im\right)}} - e^{im}\right) \]
          5. lift-exp.f64N/A

            \[\leadsto \left(\frac{1}{2} \cdot re\right) \cdot \left(e^{\mathsf{neg}\left(im\right)} - \color{blue}{e^{im}}\right) \]
          6. *-commutativeN/A

            \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
          7. lower-*.f64N/A

            \[\leadsto \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right)} \]
          8. lift-neg.f64N/A

            \[\leadsto \left(e^{\color{blue}{-im}} - e^{im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          9. remove-double-negN/A

            \[\leadsto \left(e^{-im} - e^{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(im\right)\right)\right)}}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          10. lift-neg.f64N/A

            \[\leadsto \left(e^{-im} - e^{\mathsf{neg}\left(\color{blue}{\left(-im\right)}\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          11. sinh-undef-revN/A

            \[\leadsto \color{blue}{\left(2 \cdot \sinh \left(-im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
          12. lift-neg.f64N/A

            \[\leadsto \left(2 \cdot \sinh \color{blue}{\left(\mathsf{neg}\left(im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          13. sinh-negN/A

            \[\leadsto \left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\sinh im\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          14. distribute-rgt-neg-outN/A

            \[\leadsto \color{blue}{\left(\mathsf{neg}\left(2 \cdot \sinh im\right)\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
          15. lower-neg.f64N/A

            \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
          16. lower-*.f64N/A

            \[\leadsto \left(-\color{blue}{2 \cdot \sinh im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          17. lower-sinh.f6480.8

            \[\leadsto \left(-2 \cdot \color{blue}{\sinh im}\right) \cdot \left(0.5 \cdot re\right) \]
        7. Applied rewrites80.8%

          \[\leadsto \color{blue}{\left(-2 \cdot \sinh im\right) \cdot \left(0.5 \cdot re\right)} \]
        8. Taylor expanded in im around 0

          \[\leadsto \left(-\color{blue}{im \cdot \left(2 + {im}^{2} \cdot \left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right)\right)}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
        9. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \left(-\color{blue}{\left(2 + {im}^{2} \cdot \left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right)\right) \cdot im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          2. lower-*.f64N/A

            \[\leadsto \left(-\color{blue}{\left(2 + {im}^{2} \cdot \left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right)\right) \cdot im}\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          3. +-commutativeN/A

            \[\leadsto \left(-\color{blue}{\left({im}^{2} \cdot \left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right) + 2\right)} \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          4. *-commutativeN/A

            \[\leadsto \left(-\left(\color{blue}{\left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right)\right) \cdot {im}^{2}} + 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          5. lower-fma.f64N/A

            \[\leadsto \left(-\color{blue}{\mathsf{fma}\left(\frac{1}{3} + {im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right), {im}^{2}, 2\right)} \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          6. +-commutativeN/A

            \[\leadsto \left(-\mathsf{fma}\left(\color{blue}{{im}^{2} \cdot \left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right) + \frac{1}{3}}, {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          7. *-commutativeN/A

            \[\leadsto \left(-\mathsf{fma}\left(\color{blue}{\left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}\right) \cdot {im}^{2}} + \frac{1}{3}, {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          8. lower-fma.f64N/A

            \[\leadsto \left(-\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{60} + \frac{1}{2520} \cdot {im}^{2}, {im}^{2}, \frac{1}{3}\right)}, {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          9. +-commutativeN/A

            \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\frac{1}{2520} \cdot {im}^{2} + \frac{1}{60}}, {im}^{2}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          10. lower-fma.f64N/A

            \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{2520}, {im}^{2}, \frac{1}{60}\right)}, {im}^{2}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          11. unpow2N/A

            \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \color{blue}{im \cdot im}, \frac{1}{60}\right), {im}^{2}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          12. lower-*.f64N/A

            \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, \color{blue}{im \cdot im}, \frac{1}{60}\right), {im}^{2}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          13. unpow2N/A

            \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, im \cdot im, \frac{1}{60}\right), \color{blue}{im \cdot im}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          14. lower-*.f64N/A

            \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, im \cdot im, \frac{1}{60}\right), \color{blue}{im \cdot im}, \frac{1}{3}\right), {im}^{2}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          15. unpow2N/A

            \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{2520}, im \cdot im, \frac{1}{60}\right), im \cdot im, \frac{1}{3}\right), \color{blue}{im \cdot im}, 2\right) \cdot im\right) \cdot \left(\frac{1}{2} \cdot re\right) \]
          16. lower-*.f6477.7

            \[\leadsto \left(-\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, im \cdot im, 0.016666666666666666\right), im \cdot im, 0.3333333333333333\right), \color{blue}{im \cdot im}, 2\right) \cdot im\right) \cdot \left(0.5 \cdot re\right) \]
        10. Applied rewrites77.7%

          \[\leadsto \left(-\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, im \cdot im, 0.016666666666666666\right), im \cdot im, 0.3333333333333333\right), im \cdot im, 2\right) \cdot im}\right) \cdot \left(0.5 \cdot re\right) \]
      10. Recombined 2 regimes into one program.
      11. Add Preprocessing

      Alternative 11: 55.3% accurate, 2.2× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq 10^{-239}:\\ \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(-0.3333333333333333 \cdot im\right) \cdot im - 2\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right) \cdot re\right) \cdot im\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (<= (sin re) 1e-239)
         (*
          (* (fma (* re re) -0.08333333333333333 0.5) re)
          (* (- (* (* -0.3333333333333333 im) im) 2.0) im))
         (*
          (*
           (-
            (* (- (* (* -0.008333333333333333 im) im) 0.16666666666666666) (* im im))
            1.0)
           re)
          im)))
      double code(double re, double im) {
      	double tmp;
      	if (sin(re) <= 1e-239) {
      		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((-0.3333333333333333 * im) * im) - 2.0) * im);
      	} else {
      		tmp = ((((((-0.008333333333333333 * im) * im) - 0.16666666666666666) * (im * im)) - 1.0) * re) * im;
      	}
      	return tmp;
      }
      
      function code(re, im)
      	tmp = 0.0
      	if (sin(re) <= 1e-239)
      		tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(-0.3333333333333333 * im) * im) - 2.0) * im));
      	else
      		tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.008333333333333333 * im) * im) - 0.16666666666666666) * Float64(im * im)) - 1.0) * re) * im);
      	end
      	return tmp
      end
      
      code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], 1e-239], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(-0.3333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(-0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * re), $MachinePrecision] * im), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\sin re \leq 10^{-239}:\\
      \;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(-0.3333333333333333 \cdot im\right) \cdot im - 2\right) \cdot im\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right) \cdot re\right) \cdot im\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (sin.f64 re) < 1.0000000000000001e-239

        1. Initial program 70.7%

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

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right)} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
          2. lower-*.f64N/A

            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
          3. lower--.f64N/A

            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left(\frac{-1}{3} \cdot {im}^{2} - 2\right)} \cdot im\right) \]
          4. *-commutativeN/A

            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
          5. lower-*.f64N/A

            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
          6. unpow2N/A

            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
          7. lower-*.f6484.1

            \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
        5. Applied rewrites84.1%

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

          \[\leadsto \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right)\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
        7. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
          2. lower-*.f64N/A

            \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
          3. +-commutativeN/A

            \[\leadsto \left(\color{blue}{\left(\frac{-1}{12} \cdot {re}^{2} + \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
          4. *-commutativeN/A

            \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
          5. lower-fma.f64N/A

            \[\leadsto \left(\color{blue}{\mathsf{fma}\left({re}^{2}, \frac{-1}{12}, \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
          6. unpow2N/A

            \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
          7. lower-*.f6462.8

            \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
        8. Applied rewrites62.8%

          \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
        9. Step-by-step derivation
          1. Applied rewrites62.8%

            \[\leadsto \left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(-0.3333333333333333 \cdot im\right) \cdot im - 2\right) \cdot im\right) \]

          if 1.0000000000000001e-239 < (sin.f64 re)

          1. Initial program 59.5%

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

            \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
            2. lower-*.f64N/A

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

            \[\leadsto \color{blue}{\left(\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(-0.008333333333333333, im \cdot im, -0.16666666666666666\right), -1\right)\right) \cdot im} \]
          6. Taylor expanded in re around 0

            \[\leadsto \left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right) \cdot im \]
          7. Step-by-step derivation
            1. Applied rewrites60.4%

              \[\leadsto \left(\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right) \cdot re\right) \cdot im \]
          8. Recombined 2 regimes into one program.
          9. Add Preprocessing

          Alternative 12: 56.2% accurate, 2.2× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq -0.0005:\\ \;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot re\right) \cdot \left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right)\\ \end{array} \end{array} \]
          (FPCore (re im)
           :precision binary64
           (if (<= (sin re) -0.0005)
             (*
              (* (* (* re re) -0.08333333333333333) re)
              (* (- (* (* im im) -0.3333333333333333) 2.0) im))
             (*
              (* im re)
              (-
               (* (- (* (* -0.008333333333333333 im) im) 0.16666666666666666) (* im im))
               1.0))))
          double code(double re, double im) {
          	double tmp;
          	if (sin(re) <= -0.0005) {
          		tmp = (((re * re) * -0.08333333333333333) * re) * ((((im * im) * -0.3333333333333333) - 2.0) * im);
          	} else {
          		tmp = (im * re) * (((((-0.008333333333333333 * im) * im) - 0.16666666666666666) * (im * im)) - 1.0);
          	}
          	return tmp;
          }
          
          real(8) function code(re, im)
              real(8), intent (in) :: re
              real(8), intent (in) :: im
              real(8) :: tmp
              if (sin(re) <= (-0.0005d0)) then
                  tmp = (((re * re) * (-0.08333333333333333d0)) * re) * ((((im * im) * (-0.3333333333333333d0)) - 2.0d0) * im)
              else
                  tmp = (im * re) * ((((((-0.008333333333333333d0) * im) * im) - 0.16666666666666666d0) * (im * im)) - 1.0d0)
              end if
              code = tmp
          end function
          
          public static double code(double re, double im) {
          	double tmp;
          	if (Math.sin(re) <= -0.0005) {
          		tmp = (((re * re) * -0.08333333333333333) * re) * ((((im * im) * -0.3333333333333333) - 2.0) * im);
          	} else {
          		tmp = (im * re) * (((((-0.008333333333333333 * im) * im) - 0.16666666666666666) * (im * im)) - 1.0);
          	}
          	return tmp;
          }
          
          def code(re, im):
          	tmp = 0
          	if math.sin(re) <= -0.0005:
          		tmp = (((re * re) * -0.08333333333333333) * re) * ((((im * im) * -0.3333333333333333) - 2.0) * im)
          	else:
          		tmp = (im * re) * (((((-0.008333333333333333 * im) * im) - 0.16666666666666666) * (im * im)) - 1.0)
          	return tmp
          
          function code(re, im)
          	tmp = 0.0
          	if (sin(re) <= -0.0005)
          		tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * Float64(Float64(Float64(Float64(im * im) * -0.3333333333333333) - 2.0) * im));
          	else
          		tmp = Float64(Float64(im * re) * Float64(Float64(Float64(Float64(Float64(-0.008333333333333333 * im) * im) - 0.16666666666666666) * Float64(im * im)) - 1.0));
          	end
          	return tmp
          end
          
          function tmp_2 = code(re, im)
          	tmp = 0.0;
          	if (sin(re) <= -0.0005)
          		tmp = (((re * re) * -0.08333333333333333) * re) * ((((im * im) * -0.3333333333333333) - 2.0) * im);
          	else
          		tmp = (im * re) * (((((-0.008333333333333333 * im) * im) - 0.16666666666666666) * (im * im)) - 1.0);
          	end
          	tmp_2 = tmp;
          end
          
          code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], -0.0005], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(im * im), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(im * re), $MachinePrecision] * N[(N[(N[(N[(N[(-0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\sin re \leq -0.0005:\\
          \;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(im \cdot re\right) \cdot \left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (sin.f64 re) < -5.0000000000000001e-4

            1. Initial program 62.6%

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

              \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right)} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
              2. lower-*.f64N/A

                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
              3. lower--.f64N/A

                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left(\frac{-1}{3} \cdot {im}^{2} - 2\right)} \cdot im\right) \]
              4. *-commutativeN/A

                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
              5. lower-*.f64N/A

                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
              6. unpow2N/A

                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
              7. lower-*.f6481.1

                \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
            5. Applied rewrites81.1%

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

              \[\leadsto \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right)\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
            7. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
              2. lower-*.f64N/A

                \[\leadsto \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
              3. +-commutativeN/A

                \[\leadsto \left(\color{blue}{\left(\frac{-1}{12} \cdot {re}^{2} + \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
              4. *-commutativeN/A

                \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
              5. lower-fma.f64N/A

                \[\leadsto \left(\color{blue}{\mathsf{fma}\left({re}^{2}, \frac{-1}{12}, \frac{1}{2}\right)} \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
              6. unpow2N/A

                \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
              7. lower-*.f6429.8

                \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
            8. Applied rewrites29.8%

              \[\leadsto \color{blue}{\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
            9. Taylor expanded in re around inf

              \[\leadsto \left(\left(\frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
            10. Step-by-step derivation
              1. Applied rewrites26.7%

                \[\leadsto \left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]

              if -5.0000000000000001e-4 < (sin.f64 re)

              1. Initial program 67.8%

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

                \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)} \]
              4. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
                2. lower-*.f64N/A

                  \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
              5. Applied rewrites91.9%

                \[\leadsto \color{blue}{\left(\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(-0.008333333333333333, im \cdot im, -0.16666666666666666\right), -1\right)\right) \cdot im} \]
              6. Taylor expanded in re around 0

                \[\leadsto im \cdot \color{blue}{\left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right)} \]
              7. Step-by-step derivation
                1. Applied rewrites75.2%

                  \[\leadsto \left(im \cdot re\right) \cdot \color{blue}{\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right)} \]
              8. Recombined 2 regimes into one program.
              9. Add Preprocessing

              Alternative 13: 55.7% accurate, 2.2× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq -0.0005:\\ \;\;\;\;\mathsf{fma}\left(im \cdot \left(0.16666666666666666 \cdot re\right), re, -im\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot re\right) \cdot \left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right)\\ \end{array} \end{array} \]
              (FPCore (re im)
               :precision binary64
               (if (<= (sin re) -0.0005)
                 (* (fma (* im (* 0.16666666666666666 re)) re (- im)) re)
                 (*
                  (* im re)
                  (-
                   (* (- (* (* -0.008333333333333333 im) im) 0.16666666666666666) (* im im))
                   1.0))))
              double code(double re, double im) {
              	double tmp;
              	if (sin(re) <= -0.0005) {
              		tmp = fma((im * (0.16666666666666666 * re)), re, -im) * re;
              	} else {
              		tmp = (im * re) * (((((-0.008333333333333333 * im) * im) - 0.16666666666666666) * (im * im)) - 1.0);
              	}
              	return tmp;
              }
              
              function code(re, im)
              	tmp = 0.0
              	if (sin(re) <= -0.0005)
              		tmp = Float64(fma(Float64(im * Float64(0.16666666666666666 * re)), re, Float64(-im)) * re);
              	else
              		tmp = Float64(Float64(im * re) * Float64(Float64(Float64(Float64(Float64(-0.008333333333333333 * im) * im) - 0.16666666666666666) * Float64(im * im)) - 1.0));
              	end
              	return tmp
              end
              
              code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], -0.0005], N[(N[(N[(im * N[(0.16666666666666666 * re), $MachinePrecision]), $MachinePrecision] * re + (-im)), $MachinePrecision] * re), $MachinePrecision], N[(N[(im * re), $MachinePrecision] * N[(N[(N[(N[(N[(-0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;\sin re \leq -0.0005:\\
              \;\;\;\;\mathsf{fma}\left(im \cdot \left(0.16666666666666666 \cdot re\right), re, -im\right) \cdot re\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(im \cdot re\right) \cdot \left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right)\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (sin.f64 re) < -5.0000000000000001e-4

                1. Initial program 62.6%

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

                  \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                4. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
                  2. associate-*r*N/A

                    \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                  3. lower-*.f64N/A

                    \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                  4. mul-1-negN/A

                    \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
                  5. lower-neg.f64N/A

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

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

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

                  \[\leadsto re \cdot \color{blue}{\left(-1 \cdot im + \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)} \]
                7. Step-by-step derivation
                  1. Applied rewrites25.5%

                    \[\leadsto \left(im \cdot \mathsf{fma}\left(0.16666666666666666 \cdot re, re, -1\right)\right) \cdot \color{blue}{re} \]
                  2. Step-by-step derivation
                    1. Applied rewrites25.5%

                      \[\leadsto \mathsf{fma}\left(im \cdot \left(0.16666666666666666 \cdot re\right), re, -im\right) \cdot re \]

                    if -5.0000000000000001e-4 < (sin.f64 re)

                    1. Initial program 67.8%

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

                      \[\leadsto \color{blue}{im \cdot \left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right)} \]
                    4. Step-by-step derivation
                      1. *-commutativeN/A

                        \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
                      2. lower-*.f64N/A

                        \[\leadsto \color{blue}{\left(-1 \cdot \sin re + {im}^{2} \cdot \left(\frac{-1}{6} \cdot \sin re + \frac{-1}{120} \cdot \left({im}^{2} \cdot \sin re\right)\right)\right) \cdot im} \]
                    5. Applied rewrites91.9%

                      \[\leadsto \color{blue}{\left(\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(-0.008333333333333333, im \cdot im, -0.16666666666666666\right), -1\right)\right) \cdot im} \]
                    6. Taylor expanded in re around 0

                      \[\leadsto im \cdot \color{blue}{\left(re \cdot \left({im}^{2} \cdot \left(\frac{-1}{120} \cdot {im}^{2} - \frac{1}{6}\right) - 1\right)\right)} \]
                    7. Step-by-step derivation
                      1. Applied rewrites75.2%

                        \[\leadsto \left(im \cdot re\right) \cdot \color{blue}{\left(\left(\left(-0.008333333333333333 \cdot im\right) \cdot im - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right)} \]
                    8. Recombined 2 regimes into one program.
                    9. Add Preprocessing

                    Alternative 14: 53.2% accurate, 2.3× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq -0.0005:\\ \;\;\;\;\mathsf{fma}\left(im \cdot \left(0.16666666666666666 \cdot re\right), re, -im\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right)\\ \end{array} \end{array} \]
                    (FPCore (re im)
                     :precision binary64
                     (if (<= (sin re) -0.0005)
                       (* (fma (* im (* 0.16666666666666666 re)) re (- im)) re)
                       (* (* 0.5 re) (* (- (* (* im im) -0.3333333333333333) 2.0) im))))
                    double code(double re, double im) {
                    	double tmp;
                    	if (sin(re) <= -0.0005) {
                    		tmp = fma((im * (0.16666666666666666 * re)), re, -im) * re;
                    	} else {
                    		tmp = (0.5 * re) * ((((im * im) * -0.3333333333333333) - 2.0) * im);
                    	}
                    	return tmp;
                    }
                    
                    function code(re, im)
                    	tmp = 0.0
                    	if (sin(re) <= -0.0005)
                    		tmp = Float64(fma(Float64(im * Float64(0.16666666666666666 * re)), re, Float64(-im)) * re);
                    	else
                    		tmp = Float64(Float64(0.5 * re) * Float64(Float64(Float64(Float64(im * im) * -0.3333333333333333) - 2.0) * im));
                    	end
                    	return tmp
                    end
                    
                    code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], -0.0005], N[(N[(N[(im * N[(0.16666666666666666 * re), $MachinePrecision]), $MachinePrecision] * re + (-im)), $MachinePrecision] * re), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(N[(N[(im * im), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;\sin re \leq -0.0005:\\
                    \;\;\;\;\mathsf{fma}\left(im \cdot \left(0.16666666666666666 \cdot re\right), re, -im\right) \cdot re\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right)\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if (sin.f64 re) < -5.0000000000000001e-4

                      1. Initial program 62.6%

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

                        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                      4. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
                        2. associate-*r*N/A

                          \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                        3. lower-*.f64N/A

                          \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                        4. mul-1-negN/A

                          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
                        5. lower-neg.f64N/A

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

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

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

                        \[\leadsto re \cdot \color{blue}{\left(-1 \cdot im + \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)} \]
                      7. Step-by-step derivation
                        1. Applied rewrites25.5%

                          \[\leadsto \left(im \cdot \mathsf{fma}\left(0.16666666666666666 \cdot re, re, -1\right)\right) \cdot \color{blue}{re} \]
                        2. Step-by-step derivation
                          1. Applied rewrites25.5%

                            \[\leadsto \mathsf{fma}\left(im \cdot \left(0.16666666666666666 \cdot re\right), re, -im\right) \cdot re \]

                          if -5.0000000000000001e-4 < (sin.f64 re)

                          1. Initial program 67.8%

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

                            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{3} \cdot {im}^{2} - 2\right)\right)} \]
                          4. Step-by-step derivation
                            1. *-commutativeN/A

                              \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
                            2. lower-*.f64N/A

                              \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(\left(\frac{-1}{3} \cdot {im}^{2} - 2\right) \cdot im\right)} \]
                            3. lower--.f64N/A

                              \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{\left(\frac{-1}{3} \cdot {im}^{2} - 2\right)} \cdot im\right) \]
                            4. *-commutativeN/A

                              \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
                            5. lower-*.f64N/A

                              \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{{im}^{2} \cdot \frac{-1}{3}} - 2\right) \cdot im\right) \]
                            6. unpow2N/A

                              \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
                            7. lower-*.f6488.6

                              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
                          5. Applied rewrites88.6%

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

                            \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot \frac{-1}{3} - 2\right) \cdot im\right) \]
                          7. Step-by-step derivation
                            1. lower-*.f6471.5

                              \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333 - 2\right) \cdot im\right) \]
                          8. Applied rewrites71.5%

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

                        Alternative 15: 34.3% accurate, 2.4× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq 10^{-6}:\\ \;\;\;\;\mathsf{fma}\left(im \cdot \left(0.16666666666666666 \cdot re\right), re, -im\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\left(-re\right) \cdot im\\ \end{array} \end{array} \]
                        (FPCore (re im)
                         :precision binary64
                         (if (<= (sin re) 1e-6)
                           (* (fma (* im (* 0.16666666666666666 re)) re (- im)) re)
                           (* (- re) im)))
                        double code(double re, double im) {
                        	double tmp;
                        	if (sin(re) <= 1e-6) {
                        		tmp = fma((im * (0.16666666666666666 * re)), re, -im) * re;
                        	} else {
                        		tmp = -re * im;
                        	}
                        	return tmp;
                        }
                        
                        function code(re, im)
                        	tmp = 0.0
                        	if (sin(re) <= 1e-6)
                        		tmp = Float64(fma(Float64(im * Float64(0.16666666666666666 * re)), re, Float64(-im)) * re);
                        	else
                        		tmp = Float64(Float64(-re) * im);
                        	end
                        	return tmp
                        end
                        
                        code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], 1e-6], N[(N[(N[(im * N[(0.16666666666666666 * re), $MachinePrecision]), $MachinePrecision] * re + (-im)), $MachinePrecision] * re), $MachinePrecision], N[((-re) * im), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;\sin re \leq 10^{-6}:\\
                        \;\;\;\;\mathsf{fma}\left(im \cdot \left(0.16666666666666666 \cdot re\right), re, -im\right) \cdot re\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\left(-re\right) \cdot im\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if (sin.f64 re) < 9.99999999999999955e-7

                          1. Initial program 69.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

                            \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                          4. Step-by-step derivation
                            1. *-commutativeN/A

                              \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
                            2. associate-*r*N/A

                              \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                            3. lower-*.f64N/A

                              \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                            4. mul-1-negN/A

                              \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
                            5. lower-neg.f64N/A

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

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

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

                            \[\leadsto re \cdot \color{blue}{\left(-1 \cdot im + \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)} \]
                          7. Step-by-step derivation
                            1. Applied rewrites45.7%

                              \[\leadsto \left(im \cdot \mathsf{fma}\left(0.16666666666666666 \cdot re, re, -1\right)\right) \cdot \color{blue}{re} \]
                            2. Step-by-step derivation
                              1. Applied rewrites45.7%

                                \[\leadsto \mathsf{fma}\left(im \cdot \left(0.16666666666666666 \cdot re\right), re, -im\right) \cdot re \]

                              if 9.99999999999999955e-7 < (sin.f64 re)

                              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

                                \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                              4. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
                                2. associate-*r*N/A

                                  \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                3. lower-*.f64N/A

                                  \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                4. mul-1-negN/A

                                  \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
                                5. lower-neg.f64N/A

                                  \[\leadsto \color{blue}{\left(-\sin re\right)} \cdot im \]
                                6. lower-sin.f6454.2

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

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

                                \[\leadsto \left(-1 \cdot re\right) \cdot im \]
                              7. Step-by-step derivation
                                1. Applied rewrites15.1%

                                  \[\leadsto \left(-re\right) \cdot im \]
                              8. Recombined 2 regimes into one program.
                              9. Add Preprocessing

                              Alternative 16: 34.3% accurate, 2.4× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq 10^{-6}:\\ \;\;\;\;\mathsf{fma}\left(0.16666666666666666, \left(re \cdot re\right) \cdot im, -im\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\left(-re\right) \cdot im\\ \end{array} \end{array} \]
                              (FPCore (re im)
                               :precision binary64
                               (if (<= (sin re) 1e-6)
                                 (* (fma 0.16666666666666666 (* (* re re) im) (- im)) re)
                                 (* (- re) im)))
                              double code(double re, double im) {
                              	double tmp;
                              	if (sin(re) <= 1e-6) {
                              		tmp = fma(0.16666666666666666, ((re * re) * im), -im) * re;
                              	} else {
                              		tmp = -re * im;
                              	}
                              	return tmp;
                              }
                              
                              function code(re, im)
                              	tmp = 0.0
                              	if (sin(re) <= 1e-6)
                              		tmp = Float64(fma(0.16666666666666666, Float64(Float64(re * re) * im), Float64(-im)) * re);
                              	else
                              		tmp = Float64(Float64(-re) * im);
                              	end
                              	return tmp
                              end
                              
                              code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], 1e-6], N[(N[(0.16666666666666666 * N[(N[(re * re), $MachinePrecision] * im), $MachinePrecision] + (-im)), $MachinePrecision] * re), $MachinePrecision], N[((-re) * im), $MachinePrecision]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;\sin re \leq 10^{-6}:\\
                              \;\;\;\;\mathsf{fma}\left(0.16666666666666666, \left(re \cdot re\right) \cdot im, -im\right) \cdot re\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\left(-re\right) \cdot im\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if (sin.f64 re) < 9.99999999999999955e-7

                                1. Initial program 69.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

                                  \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                                4. Step-by-step derivation
                                  1. *-commutativeN/A

                                    \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
                                  2. associate-*r*N/A

                                    \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                  3. lower-*.f64N/A

                                    \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                  4. mul-1-negN/A

                                    \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
                                  5. lower-neg.f64N/A

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

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

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

                                  \[\leadsto re \cdot \color{blue}{\left(-1 \cdot im + \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)} \]
                                7. Step-by-step derivation
                                  1. Applied rewrites45.7%

                                    \[\leadsto \left(im \cdot \mathsf{fma}\left(0.16666666666666666 \cdot re, re, -1\right)\right) \cdot \color{blue}{re} \]
                                  2. Step-by-step derivation
                                    1. Applied rewrites45.7%

                                      \[\leadsto \mathsf{fma}\left(0.16666666666666666, \left(re \cdot re\right) \cdot im, -im\right) \cdot re \]

                                    if 9.99999999999999955e-7 < (sin.f64 re)

                                    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

                                      \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                                    4. Step-by-step derivation
                                      1. *-commutativeN/A

                                        \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
                                      2. associate-*r*N/A

                                        \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                      3. lower-*.f64N/A

                                        \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                      4. mul-1-negN/A

                                        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
                                      5. lower-neg.f64N/A

                                        \[\leadsto \color{blue}{\left(-\sin re\right)} \cdot im \]
                                      6. lower-sin.f6454.2

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

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

                                      \[\leadsto \left(-1 \cdot re\right) \cdot im \]
                                    7. Step-by-step derivation
                                      1. Applied rewrites15.1%

                                        \[\leadsto \left(-re\right) \cdot im \]
                                    8. Recombined 2 regimes into one program.
                                    9. Add Preprocessing

                                    Alternative 17: 34.3% accurate, 2.5× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq 10^{-6}:\\ \;\;\;\;\left(im \cdot \mathsf{fma}\left(0.16666666666666666 \cdot re, re, -1\right)\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\left(-re\right) \cdot im\\ \end{array} \end{array} \]
                                    (FPCore (re im)
                                     :precision binary64
                                     (if (<= (sin re) 1e-6)
                                       (* (* im (fma (* 0.16666666666666666 re) re -1.0)) re)
                                       (* (- re) im)))
                                    double code(double re, double im) {
                                    	double tmp;
                                    	if (sin(re) <= 1e-6) {
                                    		tmp = (im * fma((0.16666666666666666 * re), re, -1.0)) * re;
                                    	} else {
                                    		tmp = -re * im;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    function code(re, im)
                                    	tmp = 0.0
                                    	if (sin(re) <= 1e-6)
                                    		tmp = Float64(Float64(im * fma(Float64(0.16666666666666666 * re), re, -1.0)) * re);
                                    	else
                                    		tmp = Float64(Float64(-re) * im);
                                    	end
                                    	return tmp
                                    end
                                    
                                    code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], 1e-6], N[(N[(im * N[(N[(0.16666666666666666 * re), $MachinePrecision] * re + -1.0), $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision], N[((-re) * im), $MachinePrecision]]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    \mathbf{if}\;\sin re \leq 10^{-6}:\\
                                    \;\;\;\;\left(im \cdot \mathsf{fma}\left(0.16666666666666666 \cdot re, re, -1\right)\right) \cdot re\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\left(-re\right) \cdot im\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if (sin.f64 re) < 9.99999999999999955e-7

                                      1. Initial program 69.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

                                        \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                                      4. Step-by-step derivation
                                        1. *-commutativeN/A

                                          \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
                                        2. associate-*r*N/A

                                          \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                        3. lower-*.f64N/A

                                          \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                        4. mul-1-negN/A

                                          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
                                        5. lower-neg.f64N/A

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

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

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

                                        \[\leadsto re \cdot \color{blue}{\left(-1 \cdot im + \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)} \]
                                      7. Step-by-step derivation
                                        1. Applied rewrites45.7%

                                          \[\leadsto \left(im \cdot \mathsf{fma}\left(0.16666666666666666 \cdot re, re, -1\right)\right) \cdot \color{blue}{re} \]

                                        if 9.99999999999999955e-7 < (sin.f64 re)

                                        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

                                          \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                                        4. Step-by-step derivation
                                          1. *-commutativeN/A

                                            \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
                                          2. associate-*r*N/A

                                            \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                          3. lower-*.f64N/A

                                            \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                          4. mul-1-negN/A

                                            \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
                                          5. lower-neg.f64N/A

                                            \[\leadsto \color{blue}{\left(-\sin re\right)} \cdot im \]
                                          6. lower-sin.f6454.2

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

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

                                          \[\leadsto \left(-1 \cdot re\right) \cdot im \]
                                        7. Step-by-step derivation
                                          1. Applied rewrites15.1%

                                            \[\leadsto \left(-re\right) \cdot im \]
                                        8. Recombined 2 regimes into one program.
                                        9. Add Preprocessing

                                        Alternative 18: 34.2% accurate, 2.5× speedup?

                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq -0.0005:\\ \;\;\;\;\left(\left(\left(im \cdot re\right) \cdot re\right) \cdot 0.16666666666666666\right) \cdot re\\ \mathbf{else}:\\ \;\;\;\;\left(-re\right) \cdot im\\ \end{array} \end{array} \]
                                        (FPCore (re im)
                                         :precision binary64
                                         (if (<= (sin re) -0.0005)
                                           (* (* (* (* im re) re) 0.16666666666666666) re)
                                           (* (- re) im)))
                                        double code(double re, double im) {
                                        	double tmp;
                                        	if (sin(re) <= -0.0005) {
                                        		tmp = (((im * re) * re) * 0.16666666666666666) * re;
                                        	} else {
                                        		tmp = -re * im;
                                        	}
                                        	return tmp;
                                        }
                                        
                                        real(8) function code(re, im)
                                            real(8), intent (in) :: re
                                            real(8), intent (in) :: im
                                            real(8) :: tmp
                                            if (sin(re) <= (-0.0005d0)) then
                                                tmp = (((im * re) * re) * 0.16666666666666666d0) * re
                                            else
                                                tmp = -re * im
                                            end if
                                            code = tmp
                                        end function
                                        
                                        public static double code(double re, double im) {
                                        	double tmp;
                                        	if (Math.sin(re) <= -0.0005) {
                                        		tmp = (((im * re) * re) * 0.16666666666666666) * re;
                                        	} else {
                                        		tmp = -re * im;
                                        	}
                                        	return tmp;
                                        }
                                        
                                        def code(re, im):
                                        	tmp = 0
                                        	if math.sin(re) <= -0.0005:
                                        		tmp = (((im * re) * re) * 0.16666666666666666) * re
                                        	else:
                                        		tmp = -re * im
                                        	return tmp
                                        
                                        function code(re, im)
                                        	tmp = 0.0
                                        	if (sin(re) <= -0.0005)
                                        		tmp = Float64(Float64(Float64(Float64(im * re) * re) * 0.16666666666666666) * re);
                                        	else
                                        		tmp = Float64(Float64(-re) * im);
                                        	end
                                        	return tmp
                                        end
                                        
                                        function tmp_2 = code(re, im)
                                        	tmp = 0.0;
                                        	if (sin(re) <= -0.0005)
                                        		tmp = (((im * re) * re) * 0.16666666666666666) * re;
                                        	else
                                        		tmp = -re * im;
                                        	end
                                        	tmp_2 = tmp;
                                        end
                                        
                                        code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], -0.0005], N[(N[(N[(N[(im * re), $MachinePrecision] * re), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * re), $MachinePrecision], N[((-re) * im), $MachinePrecision]]
                                        
                                        \begin{array}{l}
                                        
                                        \\
                                        \begin{array}{l}
                                        \mathbf{if}\;\sin re \leq -0.0005:\\
                                        \;\;\;\;\left(\left(\left(im \cdot re\right) \cdot re\right) \cdot 0.16666666666666666\right) \cdot re\\
                                        
                                        \mathbf{else}:\\
                                        \;\;\;\;\left(-re\right) \cdot im\\
                                        
                                        
                                        \end{array}
                                        \end{array}
                                        
                                        Derivation
                                        1. Split input into 2 regimes
                                        2. if (sin.f64 re) < -5.0000000000000001e-4

                                          1. Initial program 62.6%

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

                                            \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                                          4. Step-by-step derivation
                                            1. *-commutativeN/A

                                              \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
                                            2. associate-*r*N/A

                                              \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                            3. lower-*.f64N/A

                                              \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                            4. mul-1-negN/A

                                              \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
                                            5. lower-neg.f64N/A

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

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

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

                                            \[\leadsto re \cdot \color{blue}{\left(-1 \cdot im + \frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right)} \]
                                          7. Step-by-step derivation
                                            1. Applied rewrites25.5%

                                              \[\leadsto \left(im \cdot \mathsf{fma}\left(0.16666666666666666 \cdot re, re, -1\right)\right) \cdot \color{blue}{re} \]
                                            2. Taylor expanded in re around inf

                                              \[\leadsto \left(\frac{1}{6} \cdot \left(im \cdot {re}^{2}\right)\right) \cdot re \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites25.3%

                                                \[\leadsto \left(\left(\left(im \cdot re\right) \cdot re\right) \cdot 0.16666666666666666\right) \cdot re \]

                                              if -5.0000000000000001e-4 < (sin.f64 re)

                                              1. Initial program 67.8%

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

                                                \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                                              4. Step-by-step derivation
                                                1. *-commutativeN/A

                                                  \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
                                                2. associate-*r*N/A

                                                  \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                                3. lower-*.f64N/A

                                                  \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                                4. mul-1-negN/A

                                                  \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
                                                5. lower-neg.f64N/A

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

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

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

                                                \[\leadsto \left(-1 \cdot re\right) \cdot im \]
                                              7. Step-by-step derivation
                                                1. Applied rewrites45.3%

                                                  \[\leadsto \left(-re\right) \cdot im \]
                                              8. Recombined 2 regimes into one program.
                                              9. Add Preprocessing

                                              Alternative 19: 32.4% accurate, 39.5× speedup?

                                              \[\begin{array}{l} \\ \left(-re\right) \cdot im \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(Float64(-re) * im)
                                              end
                                              
                                              function tmp = code(re, im)
                                              	tmp = -re * im;
                                              end
                                              
                                              code[re_, im_] := N[((-re) * im), $MachinePrecision]
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \left(-re\right) \cdot im
                                              \end{array}
                                              
                                              Derivation
                                              1. Initial program 66.5%

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

                                                \[\leadsto \color{blue}{-1 \cdot \left(im \cdot \sin re\right)} \]
                                              4. Step-by-step derivation
                                                1. *-commutativeN/A

                                                  \[\leadsto -1 \cdot \color{blue}{\left(\sin re \cdot im\right)} \]
                                                2. associate-*r*N/A

                                                  \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                                3. lower-*.f64N/A

                                                  \[\leadsto \color{blue}{\left(-1 \cdot \sin re\right) \cdot im} \]
                                                4. mul-1-negN/A

                                                  \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\sin re\right)\right)} \cdot im \]
                                                5. lower-neg.f64N/A

                                                  \[\leadsto \color{blue}{\left(-\sin re\right)} \cdot im \]
                                                6. lower-sin.f6452.0

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

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

                                                \[\leadsto \left(-1 \cdot re\right) \cdot im \]
                                              7. Step-by-step derivation
                                                1. Applied rewrites37.8%

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

                                                Developer Target 1: 99.8% accurate, 1.0× 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 2024326 
                                                (FPCore (re im)
                                                  :name "math.cos on complex, imaginary part"
                                                  :precision binary64
                                                
                                                  :alt
                                                  (! :herbie-platform default (if (< (fabs im) 1) (- (* (sin re) (+ im (* 1/6 im im im) (* 1/120 im im im im im)))) (* (* 1/2 (sin re)) (- (exp (- im)) (exp im)))))
                                                
                                                  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))