math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 9.4s
Alternatives: 16
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 16 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} \\ \cosh im \cdot \sin re \end{array} \]
(FPCore (re im) :precision binary64 (* (cosh im) (sin re)))
double code(double re, double im) {
	return cosh(im) * sin(re);
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = cosh(im) * sin(re)
end function
public static double code(double re, double im) {
	return Math.cosh(im) * Math.sin(re);
}
def code(re, im):
	return math.cosh(im) * math.sin(re)
function code(re, im)
	return Float64(cosh(im) * sin(re))
end
function tmp = code(re, im)
	tmp = cosh(im) * sin(re);
end
code[re_, im_] := N[(N[Cosh[im], $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\cosh im \cdot \sin re
\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\color{blue}{1} \cdot \cosh im\right) \cdot \sin re \]
    19. 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. Final simplification100.0%

    \[\leadsto \cosh im \cdot \sin re \]
  6. Add Preprocessing

Alternative 2: 81.8% accurate, 0.4× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(im, \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.002777777777777778, 0.08333333333333333\right), im \cdot \left(im \cdot im\right), im\right), 2\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 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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(\color{blue}{im \cdot im}, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\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 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.f6498.6

          \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
      5. Applied rewrites98.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 im around 0

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

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

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

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

          \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {im}^{2}\right)\right), 2\right)} \]
      5. Applied rewrites82.1%

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

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

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

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

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

    Alternative 3: 81.4% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right)\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\right)\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(im, \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.002777777777777778, 0.08333333333333333\right), im \cdot \left(im \cdot im\right), im\right), 2\right) \cdot \left(re \cdot 0.5\right)\\ \end{array} \end{array} \]
    (FPCore (re im)
     :precision binary64
     (let* ((t_0 (* (* (sin re) 0.5) (+ (exp (- im)) (exp im)))))
       (if (<= t_0 (- INFINITY))
         (*
          (fma re (* (* re re) -0.16666666666666666) re)
          (fma (* im im) (fma im (* im 0.041666666666666664) 0.5) 1.0))
         (if (<= t_0 1.0)
           (sin re)
           (*
            (fma
             im
             (fma
              (fma im (* im 0.002777777777777778) 0.08333333333333333)
              (* im (* im im))
              im)
             2.0)
            (* re 0.5))))))
    double code(double re, double im) {
    	double t_0 = (sin(re) * 0.5) * (exp(-im) + exp(im));
    	double tmp;
    	if (t_0 <= -((double) INFINITY)) {
    		tmp = fma(re, ((re * re) * -0.16666666666666666), re) * fma((im * im), fma(im, (im * 0.041666666666666664), 0.5), 1.0);
    	} else if (t_0 <= 1.0) {
    		tmp = sin(re);
    	} else {
    		tmp = fma(im, fma(fma(im, (im * 0.002777777777777778), 0.08333333333333333), (im * (im * im)), im), 2.0) * (re * 0.5);
    	}
    	return tmp;
    }
    
    function code(re, im)
    	t_0 = Float64(Float64(sin(re) * 0.5) * Float64(exp(Float64(-im)) + exp(im)))
    	tmp = 0.0
    	if (t_0 <= Float64(-Inf))
    		tmp = Float64(fma(re, Float64(Float64(re * re) * -0.16666666666666666), re) * fma(Float64(im * im), fma(im, Float64(im * 0.041666666666666664), 0.5), 1.0));
    	elseif (t_0 <= 1.0)
    		tmp = sin(re);
    	else
    		tmp = Float64(fma(im, fma(fma(im, Float64(im * 0.002777777777777778), 0.08333333333333333), Float64(im * Float64(im * im)), im), 2.0) * Float64(re * 0.5));
    	end
    	return tmp
    end
    
    code[re_, im_] := Block[{t$95$0 = N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(re * N[(N[(re * re), $MachinePrecision] * -0.16666666666666666), $MachinePrecision] + re), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * N[(im * N[(im * 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[Sin[re], $MachinePrecision], N[(N[(im * N[(N[(im * N[(im * 0.002777777777777778), $MachinePrecision] + 0.08333333333333333), $MachinePrecision] * N[(im * N[(im * im), $MachinePrecision]), $MachinePrecision] + im), $MachinePrecision] + 2.0), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right)\\
    \mathbf{if}\;t\_0 \leq -\infty:\\
    \;\;\;\;\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\right)\\
    
    \mathbf{elif}\;t\_0 \leq 1:\\
    \;\;\;\;\sin re\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(im, \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.002777777777777778, 0.08333333333333333\right), im \cdot \left(im \cdot im\right), im\right), 2\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 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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(\color{blue}{im \cdot im}, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\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 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} \]
        4. Step-by-step derivation
          1. lower-sin.f6497.2

            \[\leadsto \color{blue}{\sin re} \]
        5. Applied rewrites97.2%

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

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

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

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

            \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {im}^{2}\right)\right), 2\right)} \]
        5. Applied rewrites82.1%

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

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

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

          \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \mathsf{fma}\left(im, \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.002777777777777778, 0.08333333333333333\right), im \cdot \left(im \cdot im\right), im\right), 2\right) \]
      8. Recombined 3 regimes into one program.
      9. Final simplification81.6%

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

      Alternative 4: 52.7% accurate, 0.9× speedup?

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

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

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

            \[\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) \]
          2. +-commutativeN/A

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

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

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

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

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

        if -0.20000000000000001 < (*.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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\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 rewrites62.4%

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

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

                \[\leadsto \mathsf{fma}\left(im \cdot \left(im \cdot \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right)\right), re, re\right) \]
            3. Recombined 2 regimes into one program.
            4. Final simplification54.3%

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

            Alternative 5: 45.0% accurate, 0.9× speedup?

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

              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} \]
              4. Step-by-step derivation
                1. lower-sin.f6435.1

                  \[\leadsto \color{blue}{\sin re} \]
              5. Applied rewrites35.1%

                \[\leadsto \color{blue}{\sin re} \]
              6. Taylor expanded in re around 0

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

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

                  \[\leadsto \frac{-1}{6} \cdot {re}^{\color{blue}{3}} \]
                3. Step-by-step derivation
                  1. Applied rewrites17.7%

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

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

                    if -0.20000000000000001 < (*.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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\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 rewrites62.4%

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

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

                            \[\leadsto \mathsf{fma}\left(im \cdot \left(im \cdot \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right)\right), re, re\right) \]
                        3. Recombined 2 regimes into one program.
                        4. Final simplification48.5%

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

                        Alternative 6: 43.1% accurate, 0.9× speedup?

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

                          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} \]
                          4. Step-by-step derivation
                            1. lower-sin.f6435.1

                              \[\leadsto \color{blue}{\sin re} \]
                          5. Applied rewrites35.1%

                            \[\leadsto \color{blue}{\sin re} \]
                          6. Taylor expanded in re around 0

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

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

                              \[\leadsto \frac{-1}{6} \cdot {re}^{\color{blue}{3}} \]
                            3. Step-by-step derivation
                              1. Applied rewrites17.7%

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

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

                                if -0.20000000000000001 < (*.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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\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 rewrites62.4%

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

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

                                      \[\leadsto \mathsf{fma}\left(im \cdot im, \left(\left(im \cdot im\right) \cdot 0.041666666666666664\right) \cdot re, re\right) \]
                                  4. Recombined 2 regimes into one program.
                                  5. Final simplification46.1%

                                    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq -0.2:\\ \;\;\;\;re \cdot \left(re \cdot \left(re \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(im \cdot im, re \cdot \left(\left(im \cdot im\right) \cdot 0.041666666666666664\right), re\right)\\ \end{array} \]
                                  6. Add Preprocessing

                                  Alternative 7: 42.8% accurate, 0.9× speedup?

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

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

                                        \[\leadsto \color{blue}{\sin re} \]
                                    5. Applied rewrites60.4%

                                      \[\leadsto \color{blue}{\sin re} \]
                                    6. Taylor expanded in re around 0

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

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

                                      if 4.99999999999999999e-15 < (*.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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

                                        \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\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 rewrites39.6%

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

                                          \[\leadsto \frac{1}{24} \cdot \left({im}^{4} \cdot \color{blue}{re}\right) \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites39.5%

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

                                          \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq 5 \cdot 10^{-15}:\\ \;\;\;\;\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left(re \cdot \left(\left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \end{array} \]
                                        6. Add Preprocessing

                                        Alternative 8: 79.1% accurate, 2.1× speedup?

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

                                          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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              \[\leadsto \left(\color{blue}{1} \cdot \cosh im\right) \cdot \sin re \]
                                            19. 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. Taylor expanded in re around 0

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

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

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

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

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

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

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

                                              \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{6}, re\right) \]
                                            8. lower-*.f6472.7

                                              \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \]
                                          7. Applied rewrites72.7%

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

                                          if 2e-52 < 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} \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {im}^{2}\right)\right)\right)} \]
                                          4. Step-by-step derivation
                                            1. +-commutativeN/A

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

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

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

                                              \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {im}^{2}\right)\right), 2\right)} \]
                                          5. Applied rewrites93.4%

                                            \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.002777777777777778, 0.08333333333333333\right), im \cdot \left(im \cdot im\right), im\right), 2\right)} \]
                                        3. Recombined 2 regimes into one program.
                                        4. Final simplification78.5%

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

                                        Alternative 9: 58.3% accurate, 2.1× speedup?

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

                                          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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

                                              \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \sin re + \color{blue}{\left(\frac{1}{2} \cdot {im}^{2} + 1\right) \cdot \sin re} \]
                                          5. Applied rewrites87.4%

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

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

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

                                            if -0.050000000000000003 < (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} \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {im}^{2}\right)\right)\right)} \]
                                            4. Step-by-step derivation
                                              1. +-commutativeN/A

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

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

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

                                                \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {im}^{2}\right)\right), 2\right)} \]
                                            5. Applied rewrites90.0%

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

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

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

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

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

                                          Alternative 10: 56.1% accurate, 2.1× speedup?

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

                                            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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

                                                \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \sin re + \color{blue}{\left(\frac{1}{2} \cdot {im}^{2} + 1\right) \cdot \sin re} \]
                                            5. Applied rewrites86.3%

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

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

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

                                              if 1e-54 < (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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

                                                \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\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 rewrites33.7%

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

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

                                                    \[\leadsto \mathsf{fma}\left(im \cdot im, \left(\left(im \cdot im\right) \cdot 0.041666666666666664\right) \cdot re, re\right) \]
                                                4. Recombined 2 regimes into one program.
                                                5. Final simplification56.9%

                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;\sin re \leq 10^{-54}:\\ \;\;\;\;\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(im \cdot im, re \cdot \left(\left(im \cdot im\right) \cdot 0.041666666666666664\right), re\right)\\ \end{array} \]
                                                6. Add Preprocessing

                                                Alternative 11: 92.1% accurate, 2.3× speedup?

                                                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\right)\\ \mathbf{if}\;im \leq 0.35:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+75}:\\ \;\;\;\;\cosh im \cdot \mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                                                (FPCore (re im)
                                                 :precision binary64
                                                 (let* ((t_0
                                                         (*
                                                          (sin re)
                                                          (fma (* im im) (fma im (* im 0.041666666666666664) 0.5) 1.0))))
                                                   (if (<= im 0.35)
                                                     t_0
                                                     (if (<= im 4.4e+75)
                                                       (* (cosh im) (fma re (* (* re re) -0.16666666666666666) re))
                                                       t_0))))
                                                double code(double re, double im) {
                                                	double t_0 = sin(re) * fma((im * im), fma(im, (im * 0.041666666666666664), 0.5), 1.0);
                                                	double tmp;
                                                	if (im <= 0.35) {
                                                		tmp = t_0;
                                                	} else if (im <= 4.4e+75) {
                                                		tmp = cosh(im) * fma(re, ((re * re) * -0.16666666666666666), re);
                                                	} else {
                                                		tmp = t_0;
                                                	}
                                                	return tmp;
                                                }
                                                
                                                function code(re, im)
                                                	t_0 = Float64(sin(re) * fma(Float64(im * im), fma(im, Float64(im * 0.041666666666666664), 0.5), 1.0))
                                                	tmp = 0.0
                                                	if (im <= 0.35)
                                                		tmp = t_0;
                                                	elseif (im <= 4.4e+75)
                                                		tmp = Float64(cosh(im) * fma(re, Float64(Float64(re * re) * -0.16666666666666666), re));
                                                	else
                                                		tmp = t_0;
                                                	end
                                                	return tmp
                                                end
                                                
                                                code[re_, im_] := Block[{t$95$0 = N[(N[Sin[re], $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * N[(im * N[(im * 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.35], t$95$0, If[LessEqual[im, 4.4e+75], N[(N[Cosh[im], $MachinePrecision] * N[(re * N[(N[(re * re), $MachinePrecision] * -0.16666666666666666), $MachinePrecision] + re), $MachinePrecision]), $MachinePrecision], t$95$0]]]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \begin{array}{l}
                                                t_0 := \sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\right)\\
                                                \mathbf{if}\;im \leq 0.35:\\
                                                \;\;\;\;t\_0\\
                                                
                                                \mathbf{elif}\;im \leq 4.4 \cdot 10^{+75}:\\
                                                \;\;\;\;\cosh im \cdot \mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;t\_0\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if im < 0.34999999999999998 or 4.40000000000000024e75 < 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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

                                                  if 0.34999999999999998 < im < 4.40000000000000024e75

                                                  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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                      \[\leadsto \left(\color{blue}{1} \cdot \cosh im\right) \cdot \sin re \]
                                                    19. 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. Taylor expanded in re around 0

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

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

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

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

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

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

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

                                                      \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{6}, re\right) \]
                                                    8. lower-*.f6483.3

                                                      \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \]
                                                  7. Applied rewrites83.3%

                                                    \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)} \]
                                                3. Recombined 2 regimes into one program.
                                                4. Final simplification93.7%

                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.35:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\right)\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+75}:\\ \;\;\;\;\cosh im \cdot \mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\right)\\ \end{array} \]
                                                5. Add Preprocessing

                                                Alternative 12: 83.8% accurate, 2.3× speedup?

                                                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{if}\;im \leq 0.0145:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq 7 \cdot 10^{+88}:\\ \;\;\;\;\cosh im \cdot \mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)\\ \mathbf{elif}\;im \leq 10^{+154}:\\ \;\;\;\;\mathsf{fma}\left(im, re \cdot \left(im \cdot \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right)\right), re\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                                                (FPCore (re im)
                                                 :precision binary64
                                                 (let* ((t_0 (* (* (sin re) 0.5) (fma im im 2.0))))
                                                   (if (<= im 0.0145)
                                                     t_0
                                                     (if (<= im 7e+88)
                                                       (* (cosh im) (fma re (* (* re re) -0.16666666666666666) re))
                                                       (if (<= im 1e+154)
                                                         (fma im (* re (* im (fma im (* im 0.041666666666666664) 0.5))) re)
                                                         t_0)))))
                                                double code(double re, double im) {
                                                	double t_0 = (sin(re) * 0.5) * fma(im, im, 2.0);
                                                	double tmp;
                                                	if (im <= 0.0145) {
                                                		tmp = t_0;
                                                	} else if (im <= 7e+88) {
                                                		tmp = cosh(im) * fma(re, ((re * re) * -0.16666666666666666), re);
                                                	} else if (im <= 1e+154) {
                                                		tmp = fma(im, (re * (im * fma(im, (im * 0.041666666666666664), 0.5))), re);
                                                	} else {
                                                		tmp = t_0;
                                                	}
                                                	return tmp;
                                                }
                                                
                                                function code(re, im)
                                                	t_0 = Float64(Float64(sin(re) * 0.5) * fma(im, im, 2.0))
                                                	tmp = 0.0
                                                	if (im <= 0.0145)
                                                		tmp = t_0;
                                                	elseif (im <= 7e+88)
                                                		tmp = Float64(cosh(im) * fma(re, Float64(Float64(re * re) * -0.16666666666666666), re));
                                                	elseif (im <= 1e+154)
                                                		tmp = fma(im, Float64(re * Float64(im * fma(im, Float64(im * 0.041666666666666664), 0.5))), re);
                                                	else
                                                		tmp = t_0;
                                                	end
                                                	return tmp
                                                end
                                                
                                                code[re_, im_] := Block[{t$95$0 = N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.0145], t$95$0, If[LessEqual[im, 7e+88], N[(N[Cosh[im], $MachinePrecision] * N[(re * N[(N[(re * re), $MachinePrecision] * -0.16666666666666666), $MachinePrecision] + re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1e+154], N[(im * N[(re * N[(im * N[(im * N[(im * 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + re), $MachinePrecision], t$95$0]]]]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \begin{array}{l}
                                                t_0 := \left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
                                                \mathbf{if}\;im \leq 0.0145:\\
                                                \;\;\;\;t\_0\\
                                                
                                                \mathbf{elif}\;im \leq 7 \cdot 10^{+88}:\\
                                                \;\;\;\;\cosh im \cdot \mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)\\
                                                
                                                \mathbf{elif}\;im \leq 10^{+154}:\\
                                                \;\;\;\;\mathsf{fma}\left(im, re \cdot \left(im \cdot \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right)\right), re\right)\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;t\_0\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 3 regimes
                                                2. if im < 0.0145000000000000007 or 1.00000000000000004e154 < 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 \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.f6485.5

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

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

                                                  if 0.0145000000000000007 < im < 6.9999999999999995e88

                                                  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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                      \[\leadsto \left(\color{blue}{1} \cdot \cosh im\right) \cdot \sin re \]
                                                    19. 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. Taylor expanded in re around 0

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

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

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

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

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

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

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

                                                      \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{6}, re\right) \]
                                                    8. lower-*.f6485.0

                                                      \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \]
                                                  7. Applied rewrites85.0%

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

                                                  if 6.9999999999999995e88 < im < 1.00000000000000004e154

                                                  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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

                                                    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\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 rewrites85.6%

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

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

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

                                                        \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.0145:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 7 \cdot 10^{+88}:\\ \;\;\;\;\cosh im \cdot \mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)\\ \mathbf{elif}\;im \leq 10^{+154}:\\ \;\;\;\;\mathsf{fma}\left(im, re \cdot \left(im \cdot \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right)\right), re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \end{array} \]
                                                      5. Add Preprocessing

                                                      Alternative 13: 52.8% accurate, 2.4× speedup?

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

                                                        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} \]
                                                        4. Step-by-step derivation
                                                          1. lower-sin.f6448.1

                                                            \[\leadsto \color{blue}{\sin re} \]
                                                        5. Applied rewrites48.1%

                                                          \[\leadsto \color{blue}{\sin re} \]
                                                        6. Taylor expanded in re around 0

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

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

                                                            \[\leadsto \frac{-1}{6} \cdot {re}^{\color{blue}{3}} \]
                                                          3. Step-by-step derivation
                                                            1. Applied rewrites23.8%

                                                              \[\leadsto re \cdot \left(\left(re \cdot re\right) \cdot \color{blue}{-0.16666666666666666}\right) \]
                                                            2. Step-by-step derivation
                                                              1. Applied rewrites23.8%

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

                                                              if -0.050000000000000003 < (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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

                                                                  \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \sin re + \color{blue}{\left(\frac{1}{2} \cdot {im}^{2} + 1\right) \cdot \sin re} \]
                                                              5. Applied rewrites88.4%

                                                                \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\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 rewrites62.7%

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

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

                                                                      \[\leadsto \mathsf{fma}\left(im, \left(im \cdot \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right)\right) \cdot \color{blue}{re}, re\right) \]
                                                                  3. Recombined 2 regimes into one program.
                                                                  4. Final simplification54.0%

                                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;\sin re \leq -0.05:\\ \;\;\;\;re \cdot \left(re \cdot \left(re \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(im, re \cdot \left(im \cdot \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right)\right), re\right)\\ \end{array} \]
                                                                  5. Add Preprocessing

                                                                  Alternative 14: 47.4% accurate, 2.6× speedup?

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

                                                                    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} \]
                                                                    4. Step-by-step derivation
                                                                      1. lower-sin.f6448.1

                                                                        \[\leadsto \color{blue}{\sin re} \]
                                                                    5. Applied rewrites48.1%

                                                                      \[\leadsto \color{blue}{\sin re} \]
                                                                    6. Taylor expanded in re around 0

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

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

                                                                        \[\leadsto \frac{-1}{6} \cdot {re}^{\color{blue}{3}} \]
                                                                      3. Step-by-step derivation
                                                                        1. Applied rewrites23.8%

                                                                          \[\leadsto re \cdot \left(\left(re \cdot re\right) \cdot \color{blue}{-0.16666666666666666}\right) \]
                                                                        2. Step-by-step derivation
                                                                          1. Applied rewrites23.8%

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

                                                                          if -0.050000000000000003 < (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. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

                                                                              \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \sin re + \color{blue}{\left(\frac{1}{2} \cdot {im}^{2} + 1\right) \cdot \sin re} \]
                                                                          5. Applied rewrites88.4%

                                                                            \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right), 1\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 rewrites62.7%

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

                                                                              \[\leadsto \mathsf{fma}\left(im \cdot im, \frac{1}{2} \cdot re, re\right) \]
                                                                            3. Step-by-step derivation
                                                                              1. Applied rewrites57.0%

                                                                                \[\leadsto \mathsf{fma}\left(im \cdot im, 0.5 \cdot re, re\right) \]
                                                                            4. Recombined 2 regimes into one program.
                                                                            5. Final simplification48.3%

                                                                              \[\leadsto \begin{array}{l} \mathbf{if}\;\sin re \leq -0.05:\\ \;\;\;\;re \cdot \left(re \cdot \left(re \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(im \cdot im, re \cdot 0.5, re\right)\\ \end{array} \]
                                                                            6. Add Preprocessing

                                                                            Alternative 15: 34.0% accurate, 18.6× speedup?

                                                                            \[\begin{array}{l} \\ \mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right) \end{array} \]
                                                                            (FPCore (re im)
                                                                             :precision binary64
                                                                             (fma re (* (* re re) -0.16666666666666666) re))
                                                                            double code(double re, double im) {
                                                                            	return fma(re, ((re * re) * -0.16666666666666666), re);
                                                                            }
                                                                            
                                                                            function code(re, im)
                                                                            	return fma(re, Float64(Float64(re * re) * -0.16666666666666666), re)
                                                                            end
                                                                            
                                                                            code[re_, im_] := N[(re * N[(N[(re * re), $MachinePrecision] * -0.16666666666666666), $MachinePrecision] + re), $MachinePrecision]
                                                                            
                                                                            \begin{array}{l}
                                                                            
                                                                            \\
                                                                            \mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\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 \color{blue}{\sin re} \]
                                                                            4. Step-by-step derivation
                                                                              1. lower-sin.f6451.1

                                                                                \[\leadsto \color{blue}{\sin re} \]
                                                                            5. Applied rewrites51.1%

                                                                              \[\leadsto \color{blue}{\sin re} \]
                                                                            6. Taylor expanded in re around 0

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

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

                                                                              Alternative 16: 10.6% accurate, 19.8× speedup?

                                                                              \[\begin{array}{l} \\ re \cdot \left(re \cdot \left(re \cdot -0.16666666666666666\right)\right) \end{array} \]
                                                                              (FPCore (re im) :precision binary64 (* re (* re (* re -0.16666666666666666))))
                                                                              double code(double re, double im) {
                                                                              	return re * (re * (re * -0.16666666666666666));
                                                                              }
                                                                              
                                                                              real(8) function code(re, im)
                                                                                  real(8), intent (in) :: re
                                                                                  real(8), intent (in) :: im
                                                                                  code = re * (re * (re * (-0.16666666666666666d0)))
                                                                              end function
                                                                              
                                                                              public static double code(double re, double im) {
                                                                              	return re * (re * (re * -0.16666666666666666));
                                                                              }
                                                                              
                                                                              def code(re, im):
                                                                              	return re * (re * (re * -0.16666666666666666))
                                                                              
                                                                              function code(re, im)
                                                                              	return Float64(re * Float64(re * Float64(re * -0.16666666666666666)))
                                                                              end
                                                                              
                                                                              function tmp = code(re, im)
                                                                              	tmp = re * (re * (re * -0.16666666666666666));
                                                                              end
                                                                              
                                                                              code[re_, im_] := N[(re * N[(re * N[(re * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                                                                              
                                                                              \begin{array}{l}
                                                                              
                                                                              \\
                                                                              re \cdot \left(re \cdot \left(re \cdot -0.16666666666666666\right)\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 \color{blue}{\sin re} \]
                                                                              4. Step-by-step derivation
                                                                                1. lower-sin.f6451.1

                                                                                  \[\leadsto \color{blue}{\sin re} \]
                                                                              5. Applied rewrites51.1%

                                                                                \[\leadsto \color{blue}{\sin re} \]
                                                                              6. Taylor expanded in re around 0

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

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

                                                                                  \[\leadsto \frac{-1}{6} \cdot {re}^{\color{blue}{3}} \]
                                                                                3. Step-by-step derivation
                                                                                  1. Applied rewrites11.0%

                                                                                    \[\leadsto re \cdot \left(\left(re \cdot re\right) \cdot \color{blue}{-0.16666666666666666}\right) \]
                                                                                  2. Step-by-step derivation
                                                                                    1. Applied rewrites11.0%

                                                                                      \[\leadsto re \cdot \left(\left(re \cdot -0.16666666666666666\right) \cdot re\right) \]
                                                                                    2. Final simplification11.0%

                                                                                      \[\leadsto re \cdot \left(re \cdot \left(re \cdot -0.16666666666666666\right)\right) \]
                                                                                    3. Add Preprocessing

                                                                                    Reproduce

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