math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 5.8s
Alternatives: 14
Speedup: 1.5×

Specification

?
\[\begin{array}{l} \\ \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
	return (0.5 * sin(re)) * (exp((0.0 - 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((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im):
	return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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 14 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: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
	return (0.5 * sin(re)) * (exp((0.0 - 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((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im):
	return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 100.0% accurate, 1.5× speedup?

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

\\
\sin re \cdot \cosh im
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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^{0 - im} + e^{im}\right)} \]
    2. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin re \cdot \left(\color{blue}{1} \cdot \cosh im\right) \]
    14. cosh-0N/A

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

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

      \[\leadsto \color{blue}{\left(\cosh 0 \cdot \cosh im\right) \cdot \sin re} \]
    17. cosh-0N/A

      \[\leadsto \left(\color{blue}{1} \cdot \cosh im\right) \cdot \sin re \]
    18. exp-0N/A

      \[\leadsto \left(\color{blue}{e^{0}} \cdot \cosh im\right) \cdot \sin re \]
    19. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(e^{0} \cdot \cosh im\right)} \cdot \sin re \]
    20. exp-0N/A

      \[\leadsto \left(\color{blue}{1} \cdot \cosh im\right) \cdot \sin re \]
    21. lower-cosh.f64100.0

      \[\leadsto \left(1 \cdot \color{blue}{\cosh im}\right) \cdot \sin re \]
  4. Applied rewrites100.0%

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

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

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

      \[\leadsto \color{blue}{\cosh im} \cdot \sin re \]
    4. *-commutativeN/A

      \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
    5. lower-*.f64100.0

      \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
  6. Applied rewrites100.0%

    \[\leadsto \color{blue}{\sin re \cdot \cosh im} \]
  7. Add Preprocessing

Alternative 2: 86.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 2 \cdot \cosh im\\ t_1 := 0.5 \cdot \sin re\\ t_2 := t\_1 \cdot \left(e^{-im} + e^{im}\right)\\ \mathbf{if}\;t\_2 \leq -\infty:\\ \;\;\;\;t\_0 \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\ \mathbf{elif}\;t\_2 \leq 1:\\ \;\;\;\;t\_1 \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(re \cdot 0.5\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 2.0 (cosh im)))
        (t_1 (* 0.5 (sin re)))
        (t_2 (* t_1 (+ (exp (- im)) (exp im)))))
   (if (<= t_2 (- INFINITY))
     (* t_0 (* (fma -0.08333333333333333 (* re re) 0.5) re))
     (if (<= t_2 1.0) (* t_1 (fma im im 2.0)) (* t_0 (* re 0.5))))))
double code(double re, double im) {
	double t_0 = 2.0 * cosh(im);
	double t_1 = 0.5 * sin(re);
	double t_2 = t_1 * (exp(-im) + exp(im));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_0 * (fma(-0.08333333333333333, (re * re), 0.5) * re);
	} else if (t_2 <= 1.0) {
		tmp = t_1 * fma(im, im, 2.0);
	} else {
		tmp = t_0 * (re * 0.5);
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(2.0 * cosh(im))
	t_1 = Float64(0.5 * sin(re))
	t_2 = Float64(t_1 * Float64(exp(Float64(-im)) + exp(im)))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(t_0 * Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re));
	elseif (t_2 <= 1.0)
		tmp = Float64(t_1 * fma(im, im, 2.0));
	else
		tmp = Float64(t_0 * Float64(re * 0.5));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(2.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(t$95$0 * N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1.0], N[(t$95$1 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 2 \cdot \cosh im\\
t_1 := 0.5 \cdot \sin re\\
t_2 := t\_1 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_0 \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\

\mathbf{elif}\;t\_2 \leq 1:\\
\;\;\;\;t\_1 \cdot \mathsf{fma}\left(im, im, 2\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(re \cdot 0.5\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 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -inf.0

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. 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(e^{0 - im} + e^{im}\right) \]
    4. 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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{im}\right) \]
      7. lower-*.f6474.7

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    5. Applied rewrites74.7%

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
      4. lift--.f64N/A

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

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

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

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

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

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

        \[\leadsto \left(e^{0 - im} + \color{blue}{e^{im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      11. +-commutativeN/A

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

        \[\leadsto \left(\color{blue}{e^{im}} + e^{0 - im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      13. lift-exp.f64N/A

        \[\leadsto \left(e^{im} + \color{blue}{e^{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      14. lift--.f64N/A

        \[\leadsto \left(e^{im} + e^{\color{blue}{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      15. sub0-negN/A

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

        \[\leadsto \color{blue}{\left(2 \cdot \cosh im\right)} \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      17. lift-cosh.f64N/A

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

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

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

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

    1. Initial program 99.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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(2 + {im}^{2}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    5. Applied rewrites99.6%

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

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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. 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(e^{0 - im} + e^{im}\right) \]
    4. 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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{im}\right) \]
      7. lower-*.f6482.4

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    5. Applied rewrites82.4%

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
      4. lift--.f64N/A

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

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

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

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

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

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

        \[\leadsto \left(e^{0 - im} + \color{blue}{e^{im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      11. +-commutativeN/A

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

        \[\leadsto \left(\color{blue}{e^{im}} + e^{0 - im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      13. lift-exp.f64N/A

        \[\leadsto \left(e^{im} + \color{blue}{e^{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      14. lift--.f64N/A

        \[\leadsto \left(e^{im} + e^{\color{blue}{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      15. sub0-negN/A

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

        \[\leadsto \color{blue}{\left(2 \cdot \cosh im\right)} \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      17. lift-cosh.f64N/A

        \[\leadsto \left(2 \cdot \color{blue}{\cosh im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      18. lower-*.f6482.4

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

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

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

        \[\leadsto \left(2 \cdot \cosh im\right) \cdot \color{blue}{\left(re \cdot \frac{1}{2}\right)} \]
      2. lower-*.f6474.5

        \[\leadsto \left(2 \cdot \cosh im\right) \cdot \color{blue}{\left(re \cdot 0.5\right)} \]
    10. Applied rewrites74.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -\infty:\\ \;\;\;\;\left(2 \cdot \cosh im\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\ \mathbf{elif}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq 1:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \cosh im\right) \cdot \left(re \cdot 0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 84.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ t_1 := t\_0 \cdot \left(e^{-im} + e^{im}\right)\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;\left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), im \cdot im, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\ \mathbf{elif}\;t\_1 \leq 1:\\ \;\;\;\;t\_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \cosh im\right) \cdot \left(re \cdot 0.5\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (sin re))) (t_1 (* t_0 (+ (exp (- im)) (exp im)))))
   (if (<= t_1 (- INFINITY))
     (*
      (*
       2.0
       (fma
        (fma
         (fma 0.001388888888888889 (* im im) 0.041666666666666664)
         (* im im)
         0.5)
        (* im im)
        1.0))
      (* (fma -0.08333333333333333 (* re re) 0.5) re))
     (if (<= t_1 1.0)
       (* t_0 (fma im im 2.0))
       (* (* 2.0 (cosh im)) (* re 0.5))))))
double code(double re, double im) {
	double t_0 = 0.5 * sin(re);
	double t_1 = t_0 * (exp(-im) + exp(im));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = (2.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0)) * (fma(-0.08333333333333333, (re * re), 0.5) * re);
	} else if (t_1 <= 1.0) {
		tmp = t_0 * fma(im, im, 2.0);
	} else {
		tmp = (2.0 * cosh(im)) * (re * 0.5);
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(0.5 * sin(re))
	t_1 = Float64(t_0 * Float64(exp(Float64(-im)) + exp(im)))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(Float64(2.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)) * Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re));
	elseif (t_1 <= 1.0)
		tmp = Float64(t_0 * fma(im, im, 2.0));
	else
		tmp = Float64(Float64(2.0 * cosh(im)) * Float64(re * 0.5));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(2.0 * N[(N[(N[(0.001388888888888889 * N[(im * im), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1.0], N[(t$95$0 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
t_1 := t\_0 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), im \cdot im, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\

\mathbf{elif}\;t\_1 \leq 1:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\

\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \cosh im\right) \cdot \left(re \cdot 0.5\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 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -inf.0

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. 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(e^{0 - im} + e^{im}\right) \]
    4. 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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{im}\right) \]
      7. lower-*.f6474.7

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    5. Applied rewrites74.7%

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
      4. lift--.f64N/A

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

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

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

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

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

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

        \[\leadsto \left(e^{0 - im} + \color{blue}{e^{im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      11. +-commutativeN/A

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

        \[\leadsto \left(\color{blue}{e^{im}} + e^{0 - im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      13. lift-exp.f64N/A

        \[\leadsto \left(e^{im} + \color{blue}{e^{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      14. lift--.f64N/A

        \[\leadsto \left(e^{im} + e^{\color{blue}{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      15. sub0-negN/A

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

        \[\leadsto \color{blue}{\left(2 \cdot \cosh im\right)} \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      17. lift-cosh.f64N/A

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

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

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

      \[\leadsto \left(2 \cdot \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)}\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
    9. Step-by-step derivation
      1. +-commutativeN/A

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

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

        \[\leadsto \left(2 \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right), {im}^{2}, 1\right)}\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
      4. +-commutativeN/A

        \[\leadsto \left(2 \cdot \mathsf{fma}\left(\color{blue}{{im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right) + \frac{1}{2}}, {im}^{2}, 1\right)\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
      5. *-commutativeN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), \color{blue}{im \cdot im}, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \]
    10. Applied rewrites67.0%

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

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

    1. Initial program 99.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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(2 + {im}^{2}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    5. Applied rewrites99.6%

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

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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. 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(e^{0 - im} + e^{im}\right) \]
    4. 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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{im}\right) \]
      7. lower-*.f6482.4

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    5. Applied rewrites82.4%

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
      4. lift--.f64N/A

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

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

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

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

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

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

        \[\leadsto \left(e^{0 - im} + \color{blue}{e^{im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      11. +-commutativeN/A

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

        \[\leadsto \left(\color{blue}{e^{im}} + e^{0 - im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      13. lift-exp.f64N/A

        \[\leadsto \left(e^{im} + \color{blue}{e^{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      14. lift--.f64N/A

        \[\leadsto \left(e^{im} + e^{\color{blue}{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      15. sub0-negN/A

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

        \[\leadsto \color{blue}{\left(2 \cdot \cosh im\right)} \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      17. lift-cosh.f64N/A

        \[\leadsto \left(2 \cdot \color{blue}{\cosh im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      18. lower-*.f6482.4

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

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

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

        \[\leadsto \left(2 \cdot \cosh im\right) \cdot \color{blue}{\left(re \cdot \frac{1}{2}\right)} \]
      2. lower-*.f6474.5

        \[\leadsto \left(2 \cdot \cosh im\right) \cdot \color{blue}{\left(re \cdot 0.5\right)} \]
    10. Applied rewrites74.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -\infty:\\ \;\;\;\;\left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), im \cdot im, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\ \mathbf{elif}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq 1:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \cosh im\right) \cdot \left(re \cdot 0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 83.9% 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 -\infty:\\ \;\;\;\;\left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), im \cdot im, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \cosh im\right) \cdot \left(re \cdot 0.5\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im)))))
   (if (<= t_0 (- INFINITY))
     (*
      (*
       2.0
       (fma
        (fma
         (fma 0.001388888888888889 (* im im) 0.041666666666666664)
         (* im im)
         0.5)
        (* im im)
        1.0))
      (* (fma -0.08333333333333333 (* re re) 0.5) re))
     (if (<= t_0 1.0) (sin re) (* (* 2.0 (cosh im)) (* re 0.5))))))
double code(double re, double im) {
	double t_0 = (0.5 * sin(re)) * (exp(-im) + exp(im));
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (2.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0)) * (fma(-0.08333333333333333, (re * re), 0.5) * re);
	} else if (t_0 <= 1.0) {
		tmp = sin(re);
	} else {
		tmp = (2.0 * cosh(im)) * (re * 0.5);
	}
	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 <= Float64(-Inf))
		tmp = Float64(Float64(2.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)) * Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re));
	elseif (t_0 <= 1.0)
		tmp = sin(re);
	else
		tmp = Float64(Float64(2.0 * cosh(im)) * Float64(re * 0.5));
	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, (-Infinity)], N[(N[(2.0 * N[(N[(N[(0.001388888888888889 * N[(im * im), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[Sin[re], $MachinePrecision], N[(N[(2.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision] * N[(re * 0.5), $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 -\infty:\\
\;\;\;\;\left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), im \cdot im, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin re\\

\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \cosh im\right) \cdot \left(re \cdot 0.5\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 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -inf.0

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. 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(e^{0 - im} + e^{im}\right) \]
    4. 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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{im}\right) \]
      7. lower-*.f6474.7

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    5. Applied rewrites74.7%

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
      4. lift--.f64N/A

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

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

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

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

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

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

        \[\leadsto \left(e^{0 - im} + \color{blue}{e^{im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      11. +-commutativeN/A

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

        \[\leadsto \left(\color{blue}{e^{im}} + e^{0 - im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      13. lift-exp.f64N/A

        \[\leadsto \left(e^{im} + \color{blue}{e^{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      14. lift--.f64N/A

        \[\leadsto \left(e^{im} + e^{\color{blue}{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      15. sub0-negN/A

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

        \[\leadsto \color{blue}{\left(2 \cdot \cosh im\right)} \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      17. lift-cosh.f64N/A

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

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

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

      \[\leadsto \left(2 \cdot \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)}\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
    9. Step-by-step derivation
      1. +-commutativeN/A

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

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

        \[\leadsto \left(2 \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right), {im}^{2}, 1\right)}\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
      4. +-commutativeN/A

        \[\leadsto \left(2 \cdot \mathsf{fma}\left(\color{blue}{{im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right) + \frac{1}{2}}, {im}^{2}, 1\right)\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
      5. *-commutativeN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), \color{blue}{im \cdot im}, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \]
    10. Applied rewrites67.0%

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

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

    1. Initial program 99.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. 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(e^{0 - im} + e^{im}\right) \]
    4. 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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{im}\right) \]
      7. lower-*.f6461.6

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

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
      4. lift--.f64N/A

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

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

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

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

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

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

        \[\leadsto \left(e^{0 - im} + \color{blue}{e^{im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      11. +-commutativeN/A

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

        \[\leadsto \left(\color{blue}{e^{im}} + e^{0 - im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      13. lift-exp.f64N/A

        \[\leadsto \left(e^{im} + \color{blue}{e^{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      14. lift--.f64N/A

        \[\leadsto \left(e^{im} + e^{\color{blue}{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      15. sub0-negN/A

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

        \[\leadsto \color{blue}{\left(2 \cdot \cosh im\right)} \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      17. lift-cosh.f64N/A

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

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

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

      \[\leadsto \color{blue}{\sin re} \]
    9. Step-by-step derivation
      1. lower-sin.f6498.4

        \[\leadsto \color{blue}{\sin re} \]
    10. Applied rewrites98.4%

      \[\leadsto \color{blue}{\sin re} \]

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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. 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(e^{0 - im} + e^{im}\right) \]
    4. 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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{im}\right) \]
      7. lower-*.f6482.4

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    5. Applied rewrites82.4%

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
      4. lift--.f64N/A

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

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

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

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

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

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

        \[\leadsto \left(e^{0 - im} + \color{blue}{e^{im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      11. +-commutativeN/A

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

        \[\leadsto \left(\color{blue}{e^{im}} + e^{0 - im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      13. lift-exp.f64N/A

        \[\leadsto \left(e^{im} + \color{blue}{e^{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      14. lift--.f64N/A

        \[\leadsto \left(e^{im} + e^{\color{blue}{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      15. sub0-negN/A

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

        \[\leadsto \color{blue}{\left(2 \cdot \cosh im\right)} \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      17. lift-cosh.f64N/A

        \[\leadsto \left(2 \cdot \color{blue}{\cosh im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      18. lower-*.f6482.4

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

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

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

        \[\leadsto \left(2 \cdot \cosh im\right) \cdot \color{blue}{\left(re \cdot \frac{1}{2}\right)} \]
      2. lower-*.f6474.5

        \[\leadsto \left(2 \cdot \cosh im\right) \cdot \color{blue}{\left(re \cdot 0.5\right)} \]
    10. Applied rewrites74.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -\infty:\\ \;\;\;\;\left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), im \cdot im, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\ \mathbf{elif}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq 1:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \cosh im\right) \cdot \left(re \cdot 0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 80.2% 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 -\infty:\\ \;\;\;\;\left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), im \cdot im, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im)))))
   (if (<= t_0 (- INFINITY))
     (*
      (*
       2.0
       (fma
        (fma
         (fma 0.001388888888888889 (* im im) 0.041666666666666664)
         (* im im)
         0.5)
        (* im im)
        1.0))
      (* (fma -0.08333333333333333 (* re re) 0.5) re))
     (if (<= t_0 1.0)
       (sin re)
       (* (fma (fma 0.041666666666666664 (* im im) 0.5) (* im im) 1.0) re)))))
double code(double re, double im) {
	double t_0 = (0.5 * sin(re)) * (exp(-im) + exp(im));
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (2.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0)) * (fma(-0.08333333333333333, (re * re), 0.5) * re);
	} else if (t_0 <= 1.0) {
		tmp = sin(re);
	} else {
		tmp = fma(fma(0.041666666666666664, (im * im), 0.5), (im * im), 1.0) * re;
	}
	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 <= Float64(-Inf))
		tmp = Float64(Float64(2.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)) * Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re));
	elseif (t_0 <= 1.0)
		tmp = sin(re);
	else
		tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), 0.5), Float64(im * im), 1.0) * re);
	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, (-Infinity)], N[(N[(2.0 * N[(N[(N[(0.001388888888888889 * N[(im * im), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[Sin[re], $MachinePrecision], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * re), $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 -\infty:\\
\;\;\;\;\left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), im \cdot im, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin re\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot re\\


\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 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -inf.0

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. 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(e^{0 - im} + e^{im}\right) \]
    4. 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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{im}\right) \]
      7. lower-*.f6474.7

        \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    5. Applied rewrites74.7%

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
      4. lift--.f64N/A

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

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

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

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

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

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

        \[\leadsto \left(e^{0 - im} + \color{blue}{e^{im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      11. +-commutativeN/A

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

        \[\leadsto \left(\color{blue}{e^{im}} + e^{0 - im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      13. lift-exp.f64N/A

        \[\leadsto \left(e^{im} + \color{blue}{e^{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      14. lift--.f64N/A

        \[\leadsto \left(e^{im} + e^{\color{blue}{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      15. sub0-negN/A

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

        \[\leadsto \color{blue}{\left(2 \cdot \cosh im\right)} \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      17. lift-cosh.f64N/A

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

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

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

      \[\leadsto \left(2 \cdot \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)}\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
    9. Step-by-step derivation
      1. +-commutativeN/A

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

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

        \[\leadsto \left(2 \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right), {im}^{2}, 1\right)}\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
      4. +-commutativeN/A

        \[\leadsto \left(2 \cdot \mathsf{fma}\left(\color{blue}{{im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right) + \frac{1}{2}}, {im}^{2}, 1\right)\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
      5. *-commutativeN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), \color{blue}{im \cdot im}, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \]
    10. Applied rewrites67.0%

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

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

    1. Initial program 99.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. 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(e^{0 - im} + e^{im}\right) \]
    4. 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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{im}\right) \]
      7. lower-*.f6461.6

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

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
      4. lift--.f64N/A

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

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

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

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

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

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

        \[\leadsto \left(e^{0 - im} + \color{blue}{e^{im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      11. +-commutativeN/A

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

        \[\leadsto \left(\color{blue}{e^{im}} + e^{0 - im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      13. lift-exp.f64N/A

        \[\leadsto \left(e^{im} + \color{blue}{e^{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      14. lift--.f64N/A

        \[\leadsto \left(e^{im} + e^{\color{blue}{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      15. sub0-negN/A

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

        \[\leadsto \color{blue}{\left(2 \cdot \cosh im\right)} \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
      17. lift-cosh.f64N/A

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

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

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

      \[\leadsto \color{blue}{\sin re} \]
    9. Step-by-step derivation
      1. lower-sin.f6498.4

        \[\leadsto \color{blue}{\sin re} \]
    10. Applied rewrites98.4%

      \[\leadsto \color{blue}{\sin re} \]

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right) \cdot \color{blue}{\sin re}, {im}^{2}, \sin re\right) \]
      14. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right) \cdot \sin re, \color{blue}{im \cdot im}, \sin re\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right) \cdot \sin re, \color{blue}{im \cdot im}, \sin re\right) \]
      16. lower-sin.f6479.6

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right) \cdot \sin re, im \cdot im, \color{blue}{\sin re}\right) \]
    5. Applied rewrites79.6%

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot \color{blue}{re} \]
    8. Recombined 3 regimes into one program.
    9. Final simplification83.3%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq -\infty:\\ \;\;\;\;\left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), im \cdot im, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right)\\ \mathbf{elif}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right) \leq 1:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot re\\ \end{array} \]
    10. Add Preprocessing

    Alternative 6: 58.7% accurate, 1.7× speedup?

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

      1. Initial program 100.0%

        \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
      2. Add Preprocessing
      3. 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(e^{0 - im} + e^{im}\right) \]
      4. 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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{im}\right) \]
        7. lower-*.f6478.3

          \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
      5. Applied rewrites78.3%

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

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

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

          \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
        4. lift--.f64N/A

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

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

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

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

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

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

          \[\leadsto \left(e^{0 - im} + \color{blue}{e^{im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
        11. +-commutativeN/A

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

          \[\leadsto \left(\color{blue}{e^{im}} + e^{0 - im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
        13. lift-exp.f64N/A

          \[\leadsto \left(e^{im} + \color{blue}{e^{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
        14. lift--.f64N/A

          \[\leadsto \left(e^{im} + e^{\color{blue}{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
        15. sub0-negN/A

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

          \[\leadsto \color{blue}{\left(2 \cdot \cosh im\right)} \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
        17. lift-cosh.f64N/A

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

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

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

        \[\leadsto \left(2 \cdot \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)}\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
      9. Step-by-step derivation
        1. +-commutativeN/A

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

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

          \[\leadsto \left(2 \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right), {im}^{2}, 1\right)}\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
        4. +-commutativeN/A

          \[\leadsto \left(2 \cdot \mathsf{fma}\left(\color{blue}{{im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right) + \frac{1}{2}}, {im}^{2}, 1\right)\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
        5. *-commutativeN/A

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

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

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

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

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

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

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

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

          \[\leadsto \left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720}, im \cdot im, \frac{1}{24}\right), im \cdot im, \frac{1}{2}\right), \color{blue}{im \cdot im}, 1\right)\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
        14. lower-*.f6474.2

          \[\leadsto \left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), \color{blue}{im \cdot im}, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \]
      10. Applied rewrites74.2%

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

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

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right) \cdot \color{blue}{\sin re}, {im}^{2}, \sin re\right) \]
        14. unpow2N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right) \cdot \sin re, \color{blue}{im \cdot im}, \sin re\right) \]
        15. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right) \cdot \sin re, \color{blue}{im \cdot im}, \sin re\right) \]
        16. lower-sin.f6489.7

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right) \cdot \sin re, im \cdot im, \color{blue}{\sin re}\right) \]
      5. Applied rewrites89.7%

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

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

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

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{120} \cdot re, re, \frac{1}{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{120} \cdot {re}^{2} - \frac{1}{6}\right)\right)\right) - \frac{1}{6}, re \cdot re, \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right), im \cdot im, 1\right)\right) \cdot re \]
        3. Step-by-step derivation
          1. Applied rewrites20.4%

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

        Alternative 7: 58.6% accurate, 1.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq 5 \cdot 10^{-15}:\\ \;\;\;\;\left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), im \cdot im, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\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 \mathsf{fma}\left(im, im, 2\right)\\ \end{array} \end{array} \]
        (FPCore (re im)
         :precision binary64
         (if (<= (sin re) 5e-15)
           (*
            (*
             2.0
             (fma
              (fma
               (fma 0.001388888888888889 (* im im) 0.041666666666666664)
               (* im im)
               0.5)
              (* im im)
              1.0))
            (* (fma -0.08333333333333333 (* re re) 0.5) re))
           (*
            (*
             (fma
              (- (* 0.004166666666666667 (* re re)) 0.08333333333333333)
              (* re re)
              0.5)
             re)
            (fma im im 2.0))))
        double code(double re, double im) {
        	double tmp;
        	if (sin(re) <= 5e-15) {
        		tmp = (2.0 * fma(fma(fma(0.001388888888888889, (im * im), 0.041666666666666664), (im * im), 0.5), (im * im), 1.0)) * (fma(-0.08333333333333333, (re * re), 0.5) * re);
        	} else {
        		tmp = (fma(((0.004166666666666667 * (re * re)) - 0.08333333333333333), (re * re), 0.5) * re) * fma(im, im, 2.0);
        	}
        	return tmp;
        }
        
        function code(re, im)
        	tmp = 0.0
        	if (sin(re) <= 5e-15)
        		tmp = Float64(Float64(2.0 * fma(fma(fma(0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), 0.5), Float64(im * im), 1.0)) * Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re));
        	else
        		tmp = Float64(Float64(fma(Float64(Float64(0.004166666666666667 * Float64(re * re)) - 0.08333333333333333), Float64(re * re), 0.5) * re) * fma(im, im, 2.0));
        	end
        	return tmp
        end
        
        code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], 5e-15], N[(N[(2.0 * N[(N[(N[(0.001388888888888889 * N[(im * im), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $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[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\sin re \leq 5 \cdot 10^{-15}:\\
        \;\;\;\;\left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), im \cdot im, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\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 \mathsf{fma}\left(im, im, 2\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (sin.f64 re) < 4.99999999999999999e-15

          1. Initial program 100.0%

            \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
          2. Add Preprocessing
          3. 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(e^{0 - im} + e^{im}\right) \]
          4. 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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{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(e^{0 - im} + e^{im}\right) \]
            7. lower-*.f6478.0

              \[\leadsto \left(\mathsf{fma}\left(\color{blue}{re \cdot re}, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
          5. Applied rewrites78.0%

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

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

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

              \[\leadsto \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
            4. lift--.f64N/A

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

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

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

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

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

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

              \[\leadsto \left(e^{0 - im} + \color{blue}{e^{im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
            11. +-commutativeN/A

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

              \[\leadsto \left(\color{blue}{e^{im}} + e^{0 - im}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
            13. lift-exp.f64N/A

              \[\leadsto \left(e^{im} + \color{blue}{e^{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
            14. lift--.f64N/A

              \[\leadsto \left(e^{im} + e^{\color{blue}{0 - im}}\right) \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
            15. sub0-negN/A

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

              \[\leadsto \color{blue}{\left(2 \cdot \cosh im\right)} \cdot \left(\mathsf{fma}\left(re \cdot re, \frac{-1}{12}, \frac{1}{2}\right) \cdot re\right) \]
            17. lift-cosh.f64N/A

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

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

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

            \[\leadsto \left(2 \cdot \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)}\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
          9. Step-by-step derivation
            1. +-commutativeN/A

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

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

              \[\leadsto \left(2 \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right), {im}^{2}, 1\right)}\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
            4. +-commutativeN/A

              \[\leadsto \left(2 \cdot \mathsf{fma}\left(\color{blue}{{im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right) + \frac{1}{2}}, {im}^{2}, 1\right)\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
            5. *-commutativeN/A

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

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

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

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

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

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

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

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

              \[\leadsto \left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720}, im \cdot im, \frac{1}{24}\right), im \cdot im, \frac{1}{2}\right), \color{blue}{im \cdot im}, 1\right)\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{12}, re \cdot re, \frac{1}{2}\right) \cdot re\right) \]
            14. lower-*.f6473.8

              \[\leadsto \left(2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, 0.5\right), \color{blue}{im \cdot im}, 1\right)\right) \cdot \left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \]
          10. Applied rewrites73.8%

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

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

          1. Initial program 100.0%

            \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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(2 + {im}^{2}\right)} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

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

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

              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
          5. Applied rewrites80.6%

            \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\right) \]
            11. lower-*.f6425.2

              \[\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 \mathsf{fma}\left(im, im, 2\right) \]
          8. Applied rewrites25.2%

            \[\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 \mathsf{fma}\left(im, im, 2\right) \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 8: 55.9% accurate, 2.4× 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 \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot re\\ \end{array} \end{array} \]
        (FPCore (re im)
         :precision binary64
         (if (<= (sin re) -0.0005)
           (* (* (fma (* re re) -0.08333333333333333 0.5) re) (fma im im 2.0))
           (* (fma (fma 0.041666666666666664 (* im im) 0.5) (* im im) 1.0) re)))
        double code(double re, double im) {
        	double tmp;
        	if (sin(re) <= -0.0005) {
        		tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * fma(im, im, 2.0);
        	} else {
        		tmp = fma(fma(0.041666666666666664, (im * im), 0.5), (im * im), 1.0) * 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) * fma(im, im, 2.0));
        	else
        		tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), 0.5), Float64(im * im), 1.0) * 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[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * re), $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 \mathsf{fma}\left(im, im, 2\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot re\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (sin.f64 re) < -5.0000000000000001e-4

          1. Initial program 100.0%

            \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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(2 + {im}^{2}\right)} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

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

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

              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
          5. Applied rewrites72.7%

            \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\right) \]
            2. lower-*.f64N/A

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

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

              \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\right) \]
            7. lower-*.f6426.9

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

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

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

          1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right) \cdot \color{blue}{\sin re}, {im}^{2}, \sin re\right) \]
            14. unpow2N/A

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right) \cdot \sin re, \color{blue}{im \cdot im}, \sin re\right) \]
            15. lower-*.f64N/A

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right) \cdot \sin re, \color{blue}{im \cdot im}, \sin re\right) \]
            16. lower-sin.f6488.0

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right) \cdot \sin re, im \cdot im, \color{blue}{\sin re}\right) \]
          5. Applied rewrites88.0%

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot \color{blue}{re} \]
          8. Recombined 2 regimes into one program.
          9. Add Preprocessing

          Alternative 9: 55.7% accurate, 2.4× 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 \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot re\\ \end{array} \end{array} \]
          (FPCore (re im)
           :precision binary64
           (if (<= (sin re) -0.0005)
             (* (* (* (* re re) -0.08333333333333333) re) (fma im im 2.0))
             (* (fma (fma 0.041666666666666664 (* im im) 0.5) (* im im) 1.0) re)))
          double code(double re, double im) {
          	double tmp;
          	if (sin(re) <= -0.0005) {
          		tmp = (((re * re) * -0.08333333333333333) * re) * fma(im, im, 2.0);
          	} else {
          		tmp = fma(fma(0.041666666666666664, (im * im), 0.5), (im * im), 1.0) * re;
          	}
          	return tmp;
          }
          
          function code(re, im)
          	tmp = 0.0
          	if (sin(re) <= -0.0005)
          		tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * fma(im, im, 2.0));
          	else
          		tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), 0.5), Float64(im * im), 1.0) * 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), $MachinePrecision] * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * re), $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 \mathsf{fma}\left(im, im, 2\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot re\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (sin.f64 re) < -5.0000000000000001e-4

            1. Initial program 100.0%

              \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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(2 + {im}^{2}\right)} \]
            4. Step-by-step derivation
              1. +-commutativeN/A

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

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

                \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
            5. Applied rewrites72.7%

              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\right) \]
              2. lower-*.f64N/A

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

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

                \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\right) \]
              7. lower-*.f6426.9

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

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

              \[\leadsto \left(\left(\frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right) \]
            10. Step-by-step derivation
              1. Applied rewrites25.2%

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

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

              1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right) \cdot \color{blue}{\sin re}, {im}^{2}, \sin re\right) \]
                14. unpow2N/A

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right) \cdot \sin re, \color{blue}{im \cdot im}, \sin re\right) \]
                15. lower-*.f64N/A

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, im \cdot im, \frac{1}{2}\right) \cdot \sin re, \color{blue}{im \cdot im}, \sin re\right) \]
                16. lower-sin.f6488.0

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right) \cdot \sin re, im \cdot im, \color{blue}{\sin re}\right) \]
              5. Applied rewrites88.0%

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

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, 0.5\right), im \cdot im, 1\right) \cdot \color{blue}{re} \]
              8. Recombined 2 regimes into one program.
              9. Add Preprocessing

              Alternative 10: 48.7% accurate, 2.4× 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 \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \end{array} \end{array} \]
              (FPCore (re im)
               :precision binary64
               (if (<= (sin re) -0.0005)
                 (* (* (* (* re re) -0.08333333333333333) re) (fma im im 2.0))
                 (* (* 0.5 re) (fma im im 2.0))))
              double code(double re, double im) {
              	double tmp;
              	if (sin(re) <= -0.0005) {
              		tmp = (((re * re) * -0.08333333333333333) * re) * fma(im, im, 2.0);
              	} else {
              		tmp = (0.5 * re) * fma(im, im, 2.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) * fma(im, im, 2.0));
              	else
              		tmp = Float64(Float64(0.5 * re) * fma(im, im, 2.0));
              	end
              	return 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[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(im * im + 2.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 \mathsf{fma}\left(im, im, 2\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (sin.f64 re) < -5.0000000000000001e-4

                1. Initial program 100.0%

                  \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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(2 + {im}^{2}\right)} \]
                4. Step-by-step derivation
                  1. +-commutativeN/A

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

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

                    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
                5. Applied rewrites72.7%

                  \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\right) \]
                  2. lower-*.f64N/A

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

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

                    \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\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 \mathsf{fma}\left(im, im, 2\right) \]
                  7. lower-*.f6426.9

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

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

                  \[\leadsto \left(\left(\frac{-1}{12} \cdot {re}^{2}\right) \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right) \]
                10. Step-by-step derivation
                  1. Applied rewrites25.2%

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

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

                  1. Initial program 100.0%

                    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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(2 + {im}^{2}\right)} \]
                  4. Step-by-step derivation
                    1. +-commutativeN/A

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

                      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
                    3. lower-fma.f6479.0

                      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
                  5. Applied rewrites79.0%

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

                    \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \mathsf{fma}\left(im, im, 2\right) \]
                  7. Step-by-step derivation
                    1. lower-*.f6463.7

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

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

                Alternative 11: 47.3% accurate, 2.5× speedup?

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

                  1. Initial program 100.0%

                    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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}{2} \]
                  4. Step-by-step derivation
                    1. Applied rewrites42.6%

                      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{2} \]
                    2. 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 2 \]
                    3. 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 2 \]
                      2. lower-*.f64N/A

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

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

                        \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot 2 \]
                      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 2 \]
                      6. unpow2N/A

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

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

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

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

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

                      1. Initial program 100.0%

                        \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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(2 + {im}^{2}\right)} \]
                      4. Step-by-step derivation
                        1. +-commutativeN/A

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

                          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
                        3. lower-fma.f6479.0

                          \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
                      5. Applied rewrites79.0%

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

                        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \mathsf{fma}\left(im, im, 2\right) \]
                      7. Step-by-step derivation
                        1. lower-*.f6463.7

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

                        \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \mathsf{fma}\left(im, im, 2\right) \]
                    6. Recombined 2 regimes into one program.
                    7. Add Preprocessing

                    Alternative 12: 47.2% accurate, 2.5× speedup?

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

                      1. Initial program 100.0%

                        \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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}{2} \]
                      4. Step-by-step derivation
                        1. Applied rewrites42.6%

                          \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{2} \]
                        2. 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 2 \]
                        3. 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 2 \]
                          2. lower-*.f64N/A

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

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

                            \[\leadsto \left(\left(\color{blue}{{re}^{2} \cdot \frac{-1}{12}} + \frac{1}{2}\right) \cdot re\right) \cdot 2 \]
                          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 2 \]
                          6. unpow2N/A

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

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

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

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

                            \[\leadsto \left(\left(\left(\left(\frac{0.5}{re \cdot re} - 0.08333333333333333\right) \cdot re\right) \cdot re\right) \cdot re\right) \cdot 2 \]
                          2. Taylor expanded in re around inf

                            \[\leadsto \left(\left(\left(\frac{-1}{12} \cdot re\right) \cdot re\right) \cdot re\right) \cdot 2 \]
                          3. Step-by-step derivation
                            1. Applied rewrites16.8%

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

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

                            1. Initial program 100.0%

                              \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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(2 + {im}^{2}\right)} \]
                            4. Step-by-step derivation
                              1. +-commutativeN/A

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

                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
                              3. lower-fma.f6479.0

                                \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
                            5. Applied rewrites79.0%

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

                              \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \mathsf{fma}\left(im, im, 2\right) \]
                            7. Step-by-step derivation
                              1. lower-*.f6463.7

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

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

                          Alternative 13: 48.0% accurate, 18.6× speedup?

                          \[\begin{array}{l} \\ \left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right) \end{array} \]
                          (FPCore (re im) :precision binary64 (* (* 0.5 re) (fma im im 2.0)))
                          double code(double re, double im) {
                          	return (0.5 * re) * fma(im, im, 2.0);
                          }
                          
                          function code(re, im)
                          	return Float64(Float64(0.5 * re) * fma(im, im, 2.0))
                          end
                          
                          code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          \left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)
                          \end{array}
                          
                          Derivation
                          1. Initial program 100.0%

                            \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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(2 + {im}^{2}\right)} \]
                          4. Step-by-step derivation
                            1. +-commutativeN/A

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

                              \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
                            3. lower-fma.f6477.4

                              \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
                          5. Applied rewrites77.4%

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

                            \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot re\right)} \cdot \mathsf{fma}\left(im, im, 2\right) \]
                          7. Step-by-step derivation
                            1. lower-*.f6452.6

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

                            \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \mathsf{fma}\left(im, im, 2\right) \]
                          9. Add Preprocessing

                          Alternative 14: 25.9% accurate, 28.8× speedup?

                          \[\begin{array}{l} \\ \left(0.5 \cdot re\right) \cdot 2 \end{array} \]
                          (FPCore (re im) :precision binary64 (* (* 0.5 re) 2.0))
                          double code(double re, double im) {
                          	return (0.5 * re) * 2.0;
                          }
                          
                          real(8) function code(re, im)
                              real(8), intent (in) :: re
                              real(8), intent (in) :: im
                              code = (0.5d0 * re) * 2.0d0
                          end function
                          
                          public static double code(double re, double im) {
                          	return (0.5 * re) * 2.0;
                          }
                          
                          def code(re, im):
                          	return (0.5 * re) * 2.0
                          
                          function code(re, im)
                          	return Float64(Float64(0.5 * re) * 2.0)
                          end
                          
                          function tmp = code(re, im)
                          	tmp = (0.5 * re) * 2.0;
                          end
                          
                          code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * 2.0), $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          \left(0.5 \cdot re\right) \cdot 2
                          \end{array}
                          
                          Derivation
                          1. Initial program 100.0%

                            \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - 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}{2} \]
                          4. Step-by-step derivation
                            1. Applied rewrites51.3%

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

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

                                \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot 2 \]
                            4. Applied rewrites31.8%

                              \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot 2 \]
                            5. Add Preprocessing

                            Reproduce

                            ?
                            herbie shell --seed 2024326 
                            (FPCore (re im)
                              :name "math.sin on complex, real part"
                              :precision binary64
                              (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))