math.exp on complex, imaginary part

Percentage Accurate: 100.0% → 98.5%
Time: 16.3s
Alternatives: 17
Speedup: 1.0×

Specification

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

\\
e^{re} \cdot \sin im
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

\\
e^{re} \cdot \sin im
\end{array}

Alternative 1: 98.5% accurate, 0.2× speedup?

\[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := e^{re} \cdot \sin im\_m\\ t_1 := e^{re} \cdot im\_m\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\left(re + 1\right) \cdot \mathsf{fma}\left(im\_m, -0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\ \mathbf{elif}\;t\_0 \leq -0.02:\\ \;\;\;\;\sin im\_m \cdot \left(re + 1\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-21}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\sin im\_m \cdot \left(re + \mathsf{fma}\left(re, re \cdot 0.5, 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
im\_m = (fabs.f64 im)
im\_s = (copysign.f64 #s(literal 1 binary64) im)
(FPCore (im_s re im_m)
 :precision binary64
 (let* ((t_0 (* (exp re) (sin im_m))) (t_1 (* (exp re) im_m)))
   (*
    im_s
    (if (<= t_0 (- INFINITY))
      (* (+ re 1.0) (fma im_m (* -0.16666666666666666 (* im_m im_m)) im_m))
      (if (<= t_0 -0.02)
        (* (sin im_m) (+ re 1.0))
        (if (<= t_0 5e-21)
          t_1
          (if (<= t_0 1.0)
            (* (sin im_m) (+ re (fma re (* re 0.5) 1.0)))
            t_1)))))))
im\_m = fabs(im);
im\_s = copysign(1.0, im);
double code(double im_s, double re, double im_m) {
	double t_0 = exp(re) * sin(im_m);
	double t_1 = exp(re) * im_m;
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (re + 1.0) * fma(im_m, (-0.16666666666666666 * (im_m * im_m)), im_m);
	} else if (t_0 <= -0.02) {
		tmp = sin(im_m) * (re + 1.0);
	} else if (t_0 <= 5e-21) {
		tmp = t_1;
	} else if (t_0 <= 1.0) {
		tmp = sin(im_m) * (re + fma(re, (re * 0.5), 1.0));
	} else {
		tmp = t_1;
	}
	return im_s * tmp;
}
im\_m = abs(im)
im\_s = copysign(1.0, im)
function code(im_s, re, im_m)
	t_0 = Float64(exp(re) * sin(im_m))
	t_1 = Float64(exp(re) * im_m)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(re + 1.0) * fma(im_m, Float64(-0.16666666666666666 * Float64(im_m * im_m)), im_m));
	elseif (t_0 <= -0.02)
		tmp = Float64(sin(im_m) * Float64(re + 1.0));
	elseif (t_0 <= 5e-21)
		tmp = t_1;
	elseif (t_0 <= 1.0)
		tmp = Float64(sin(im_m) * Float64(re + fma(re, Float64(re * 0.5), 1.0)));
	else
		tmp = t_1;
	end
	return Float64(im_s * tmp)
end
im\_m = N[Abs[im], $MachinePrecision]
im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[re], $MachinePrecision] * im$95$m), $MachinePrecision]}, N[(im$95$s * If[LessEqual[t$95$0, (-Infinity)], N[(N[(re + 1.0), $MachinePrecision] * N[(im$95$m * N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision] + im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.02], N[(N[Sin[im$95$m], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-21], t$95$1, If[LessEqual[t$95$0, 1.0], N[(N[Sin[im$95$m], $MachinePrecision] * N[(re + N[(re * N[(re * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]), $MachinePrecision]]]
\begin{array}{l}
im\_m = \left|im\right|
\\
im\_s = \mathsf{copysign}\left(1, im\right)

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

\mathbf{elif}\;t\_0 \leq -0.02:\\
\;\;\;\;\sin im\_m \cdot \left(re + 1\right)\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-21}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\sin im\_m \cdot \left(re + \mathsf{fma}\left(re, re \cdot 0.5, 1\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -inf.0

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0200000000000000004

    1. Initial program 99.9%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0

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

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

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

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

    if -0.0200000000000000004 < (*.f64 (exp.f64 re) (sin.f64 im)) < 4.99999999999999973e-21 or 1 < (*.f64 (exp.f64 re) (sin.f64 im))

    1. Initial program 100.0%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{im \cdot e^{re}} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{im \cdot e^{re}} \]
      2. lower-exp.f6491.9

        \[\leadsto im \cdot \color{blue}{e^{re}} \]
    5. Applied rewrites91.9%

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

    if 4.99999999999999973e-21 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1

    1. Initial program 99.9%

      \[e^{re} \cdot \sin im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(re, re \cdot 0.5, 1\right) + \color{blue}{re}\right) \cdot \sin im \]
    7. Recombined 4 regimes into one program.
    8. Final simplification87.5%

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

    Alternative 2: 98.5% accurate, 0.2× speedup?

    \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := e^{re} \cdot \sin im\_m\\ t_1 := e^{re} \cdot im\_m\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\left(re + 1\right) \cdot \mathsf{fma}\left(im\_m, -0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\ \mathbf{elif}\;t\_0 \leq -0.02:\\ \;\;\;\;\sin im\_m \cdot \left(re + 1\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-21}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\sin im\_m \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.5, 1\right), 1\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
    im\_m = (fabs.f64 im)
    im\_s = (copysign.f64 #s(literal 1 binary64) im)
    (FPCore (im_s re im_m)
     :precision binary64
     (let* ((t_0 (* (exp re) (sin im_m))) (t_1 (* (exp re) im_m)))
       (*
        im_s
        (if (<= t_0 (- INFINITY))
          (* (+ re 1.0) (fma im_m (* -0.16666666666666666 (* im_m im_m)) im_m))
          (if (<= t_0 -0.02)
            (* (sin im_m) (+ re 1.0))
            (if (<= t_0 5e-21)
              t_1
              (if (<= t_0 1.0)
                (* (sin im_m) (fma re (fma re 0.5 1.0) 1.0))
                t_1)))))))
    im\_m = fabs(im);
    im\_s = copysign(1.0, im);
    double code(double im_s, double re, double im_m) {
    	double t_0 = exp(re) * sin(im_m);
    	double t_1 = exp(re) * im_m;
    	double tmp;
    	if (t_0 <= -((double) INFINITY)) {
    		tmp = (re + 1.0) * fma(im_m, (-0.16666666666666666 * (im_m * im_m)), im_m);
    	} else if (t_0 <= -0.02) {
    		tmp = sin(im_m) * (re + 1.0);
    	} else if (t_0 <= 5e-21) {
    		tmp = t_1;
    	} else if (t_0 <= 1.0) {
    		tmp = sin(im_m) * fma(re, fma(re, 0.5, 1.0), 1.0);
    	} else {
    		tmp = t_1;
    	}
    	return im_s * tmp;
    }
    
    im\_m = abs(im)
    im\_s = copysign(1.0, im)
    function code(im_s, re, im_m)
    	t_0 = Float64(exp(re) * sin(im_m))
    	t_1 = Float64(exp(re) * im_m)
    	tmp = 0.0
    	if (t_0 <= Float64(-Inf))
    		tmp = Float64(Float64(re + 1.0) * fma(im_m, Float64(-0.16666666666666666 * Float64(im_m * im_m)), im_m));
    	elseif (t_0 <= -0.02)
    		tmp = Float64(sin(im_m) * Float64(re + 1.0));
    	elseif (t_0 <= 5e-21)
    		tmp = t_1;
    	elseif (t_0 <= 1.0)
    		tmp = Float64(sin(im_m) * fma(re, fma(re, 0.5, 1.0), 1.0));
    	else
    		tmp = t_1;
    	end
    	return Float64(im_s * tmp)
    end
    
    im\_m = N[Abs[im], $MachinePrecision]
    im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[re], $MachinePrecision] * im$95$m), $MachinePrecision]}, N[(im$95$s * If[LessEqual[t$95$0, (-Infinity)], N[(N[(re + 1.0), $MachinePrecision] * N[(im$95$m * N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision] + im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.02], N[(N[Sin[im$95$m], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-21], t$95$1, If[LessEqual[t$95$0, 1.0], N[(N[Sin[im$95$m], $MachinePrecision] * N[(re * N[(re * 0.5 + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]), $MachinePrecision]]]
    
    \begin{array}{l}
    im\_m = \left|im\right|
    \\
    im\_s = \mathsf{copysign}\left(1, im\right)
    
    \\
    \begin{array}{l}
    t_0 := e^{re} \cdot \sin im\_m\\
    t_1 := e^{re} \cdot im\_m\\
    im\_s \cdot \begin{array}{l}
    \mathbf{if}\;t\_0 \leq -\infty:\\
    \;\;\;\;\left(re + 1\right) \cdot \mathsf{fma}\left(im\_m, -0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\
    
    \mathbf{elif}\;t\_0 \leq -0.02:\\
    \;\;\;\;\sin im\_m \cdot \left(re + 1\right)\\
    
    \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-21}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;t\_0 \leq 1:\\
    \;\;\;\;\sin im\_m \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.5, 1\right), 1\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -inf.0

      1. Initial program 100.0%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -inf.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0200000000000000004

      1. Initial program 99.9%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0

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

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

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

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

      if -0.0200000000000000004 < (*.f64 (exp.f64 re) (sin.f64 im)) < 4.99999999999999973e-21 or 1 < (*.f64 (exp.f64 re) (sin.f64 im))

      1. Initial program 100.0%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \color{blue}{im \cdot e^{re}} \]
      4. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \color{blue}{im \cdot e^{re}} \]
        2. lower-exp.f6491.9

          \[\leadsto im \cdot \color{blue}{e^{re}} \]
      5. Applied rewrites91.9%

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

      if 4.99999999999999973e-21 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1

      1. Initial program 99.9%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0

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

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

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

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

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

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

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

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

    Alternative 3: 98.5% accurate, 0.2× speedup?

    \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := e^{re} \cdot \sin im\_m\\ t_1 := \sin im\_m \cdot \left(re + 1\right)\\ t_2 := e^{re} \cdot im\_m\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\left(re + 1\right) \cdot \mathsf{fma}\left(im\_m, -0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\ \mathbf{elif}\;t\_0 \leq -0.02:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-21}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \end{array} \]
    im\_m = (fabs.f64 im)
    im\_s = (copysign.f64 #s(literal 1 binary64) im)
    (FPCore (im_s re im_m)
     :precision binary64
     (let* ((t_0 (* (exp re) (sin im_m)))
            (t_1 (* (sin im_m) (+ re 1.0)))
            (t_2 (* (exp re) im_m)))
       (*
        im_s
        (if (<= t_0 (- INFINITY))
          (* (+ re 1.0) (fma im_m (* -0.16666666666666666 (* im_m im_m)) im_m))
          (if (<= t_0 -0.02)
            t_1
            (if (<= t_0 5e-21) t_2 (if (<= t_0 1.0) t_1 t_2)))))))
    im\_m = fabs(im);
    im\_s = copysign(1.0, im);
    double code(double im_s, double re, double im_m) {
    	double t_0 = exp(re) * sin(im_m);
    	double t_1 = sin(im_m) * (re + 1.0);
    	double t_2 = exp(re) * im_m;
    	double tmp;
    	if (t_0 <= -((double) INFINITY)) {
    		tmp = (re + 1.0) * fma(im_m, (-0.16666666666666666 * (im_m * im_m)), im_m);
    	} else if (t_0 <= -0.02) {
    		tmp = t_1;
    	} else if (t_0 <= 5e-21) {
    		tmp = t_2;
    	} else if (t_0 <= 1.0) {
    		tmp = t_1;
    	} else {
    		tmp = t_2;
    	}
    	return im_s * tmp;
    }
    
    im\_m = abs(im)
    im\_s = copysign(1.0, im)
    function code(im_s, re, im_m)
    	t_0 = Float64(exp(re) * sin(im_m))
    	t_1 = Float64(sin(im_m) * Float64(re + 1.0))
    	t_2 = Float64(exp(re) * im_m)
    	tmp = 0.0
    	if (t_0 <= Float64(-Inf))
    		tmp = Float64(Float64(re + 1.0) * fma(im_m, Float64(-0.16666666666666666 * Float64(im_m * im_m)), im_m));
    	elseif (t_0 <= -0.02)
    		tmp = t_1;
    	elseif (t_0 <= 5e-21)
    		tmp = t_2;
    	elseif (t_0 <= 1.0)
    		tmp = t_1;
    	else
    		tmp = t_2;
    	end
    	return Float64(im_s * tmp)
    end
    
    im\_m = N[Abs[im], $MachinePrecision]
    im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[im$95$m], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Exp[re], $MachinePrecision] * im$95$m), $MachinePrecision]}, N[(im$95$s * If[LessEqual[t$95$0, (-Infinity)], N[(N[(re + 1.0), $MachinePrecision] * N[(im$95$m * N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision] + im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.02], t$95$1, If[LessEqual[t$95$0, 5e-21], t$95$2, If[LessEqual[t$95$0, 1.0], t$95$1, t$95$2]]]]), $MachinePrecision]]]]
    
    \begin{array}{l}
    im\_m = \left|im\right|
    \\
    im\_s = \mathsf{copysign}\left(1, im\right)
    
    \\
    \begin{array}{l}
    t_0 := e^{re} \cdot \sin im\_m\\
    t_1 := \sin im\_m \cdot \left(re + 1\right)\\
    t_2 := e^{re} \cdot im\_m\\
    im\_s \cdot \begin{array}{l}
    \mathbf{if}\;t\_0 \leq -\infty:\\
    \;\;\;\;\left(re + 1\right) \cdot \mathsf{fma}\left(im\_m, -0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\
    
    \mathbf{elif}\;t\_0 \leq -0.02:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-21}:\\
    \;\;\;\;t\_2\\
    
    \mathbf{elif}\;t\_0 \leq 1:\\
    \;\;\;\;t\_1\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_2\\
    
    
    \end{array}
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -inf.0

      1. Initial program 100.0%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -inf.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0200000000000000004 or 4.99999999999999973e-21 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1

      1. Initial program 99.9%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0

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

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

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

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

      if -0.0200000000000000004 < (*.f64 (exp.f64 re) (sin.f64 im)) < 4.99999999999999973e-21 or 1 < (*.f64 (exp.f64 re) (sin.f64 im))

      1. Initial program 100.0%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \color{blue}{im \cdot e^{re}} \]
      4. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \color{blue}{im \cdot e^{re}} \]
        2. lower-exp.f6491.9

          \[\leadsto im \cdot \color{blue}{e^{re}} \]
      5. Applied rewrites91.9%

        \[\leadsto \color{blue}{im \cdot e^{re}} \]
    3. Recombined 3 regimes into one program.
    4. Final simplification87.5%

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

    Alternative 4: 98.2% accurate, 0.2× speedup?

    \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := e^{re} \cdot \sin im\_m\\ t_1 := e^{re} \cdot im\_m\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\left(re + 1\right) \cdot \mathsf{fma}\left(im\_m, -0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\ \mathbf{elif}\;t\_0 \leq -0.02:\\ \;\;\;\;\sin im\_m\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-21}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\sin im\_m\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \end{array} \]
    im\_m = (fabs.f64 im)
    im\_s = (copysign.f64 #s(literal 1 binary64) im)
    (FPCore (im_s re im_m)
     :precision binary64
     (let* ((t_0 (* (exp re) (sin im_m))) (t_1 (* (exp re) im_m)))
       (*
        im_s
        (if (<= t_0 (- INFINITY))
          (* (+ re 1.0) (fma im_m (* -0.16666666666666666 (* im_m im_m)) im_m))
          (if (<= t_0 -0.02)
            (sin im_m)
            (if (<= t_0 5e-21) t_1 (if (<= t_0 1.0) (sin im_m) t_1)))))))
    im\_m = fabs(im);
    im\_s = copysign(1.0, im);
    double code(double im_s, double re, double im_m) {
    	double t_0 = exp(re) * sin(im_m);
    	double t_1 = exp(re) * im_m;
    	double tmp;
    	if (t_0 <= -((double) INFINITY)) {
    		tmp = (re + 1.0) * fma(im_m, (-0.16666666666666666 * (im_m * im_m)), im_m);
    	} else if (t_0 <= -0.02) {
    		tmp = sin(im_m);
    	} else if (t_0 <= 5e-21) {
    		tmp = t_1;
    	} else if (t_0 <= 1.0) {
    		tmp = sin(im_m);
    	} else {
    		tmp = t_1;
    	}
    	return im_s * tmp;
    }
    
    im\_m = abs(im)
    im\_s = copysign(1.0, im)
    function code(im_s, re, im_m)
    	t_0 = Float64(exp(re) * sin(im_m))
    	t_1 = Float64(exp(re) * im_m)
    	tmp = 0.0
    	if (t_0 <= Float64(-Inf))
    		tmp = Float64(Float64(re + 1.0) * fma(im_m, Float64(-0.16666666666666666 * Float64(im_m * im_m)), im_m));
    	elseif (t_0 <= -0.02)
    		tmp = sin(im_m);
    	elseif (t_0 <= 5e-21)
    		tmp = t_1;
    	elseif (t_0 <= 1.0)
    		tmp = sin(im_m);
    	else
    		tmp = t_1;
    	end
    	return Float64(im_s * tmp)
    end
    
    im\_m = N[Abs[im], $MachinePrecision]
    im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[re], $MachinePrecision] * im$95$m), $MachinePrecision]}, N[(im$95$s * If[LessEqual[t$95$0, (-Infinity)], N[(N[(re + 1.0), $MachinePrecision] * N[(im$95$m * N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision] + im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.02], N[Sin[im$95$m], $MachinePrecision], If[LessEqual[t$95$0, 5e-21], t$95$1, If[LessEqual[t$95$0, 1.0], N[Sin[im$95$m], $MachinePrecision], t$95$1]]]]), $MachinePrecision]]]
    
    \begin{array}{l}
    im\_m = \left|im\right|
    \\
    im\_s = \mathsf{copysign}\left(1, im\right)
    
    \\
    \begin{array}{l}
    t_0 := e^{re} \cdot \sin im\_m\\
    t_1 := e^{re} \cdot im\_m\\
    im\_s \cdot \begin{array}{l}
    \mathbf{if}\;t\_0 \leq -\infty:\\
    \;\;\;\;\left(re + 1\right) \cdot \mathsf{fma}\left(im\_m, -0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\
    
    \mathbf{elif}\;t\_0 \leq -0.02:\\
    \;\;\;\;\sin im\_m\\
    
    \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-21}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;t\_0 \leq 1:\\
    \;\;\;\;\sin im\_m\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -inf.0

      1. Initial program 100.0%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -inf.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0200000000000000004 or 4.99999999999999973e-21 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1

      1. Initial program 99.9%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0

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

          \[\leadsto \color{blue}{\sin im} \]
      5. Applied rewrites97.9%

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

      if -0.0200000000000000004 < (*.f64 (exp.f64 re) (sin.f64 im)) < 4.99999999999999973e-21 or 1 < (*.f64 (exp.f64 re) (sin.f64 im))

      1. Initial program 100.0%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0

        \[\leadsto \color{blue}{im \cdot e^{re}} \]
      4. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \color{blue}{im \cdot e^{re}} \]
        2. lower-exp.f6491.9

          \[\leadsto im \cdot \color{blue}{e^{re}} \]
      5. Applied rewrites91.9%

        \[\leadsto \color{blue}{im \cdot e^{re}} \]
    3. Recombined 3 regimes into one program.
    4. Final simplification86.9%

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

    Alternative 5: 77.4% accurate, 0.2× speedup?

    \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ \begin{array}{l} t_0 := -0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\\ t_1 := e^{re} \cdot \sin im\_m\\ im\_s \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;\left(re + 1\right) \cdot \mathsf{fma}\left(im\_m, t\_0, im\_m\right)\\ \mathbf{elif}\;t\_1 \leq -0.02:\\ \;\;\;\;\sin im\_m\\ \mathbf{elif}\;t\_1 \leq 0:\\ \;\;\;\;im\_m \cdot t\_0\\ \mathbf{elif}\;t\_1 \leq 1:\\ \;\;\;\;\sin im\_m\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(re, \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), 1\right), 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im\_m \cdot im\_m, 0.008333333333333333, -0.16666666666666666\right), im\_m \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\ \end{array} \end{array} \end{array} \]
    im\_m = (fabs.f64 im)
    im\_s = (copysign.f64 #s(literal 1 binary64) im)
    (FPCore (im_s re im_m)
     :precision binary64
     (let* ((t_0 (* -0.16666666666666666 (* im_m im_m)))
            (t_1 (* (exp re) (sin im_m))))
       (*
        im_s
        (if (<= t_1 (- INFINITY))
          (* (+ re 1.0) (fma im_m t_0 im_m))
          (if (<= t_1 -0.02)
            (sin im_m)
            (if (<= t_1 0.0)
              (* im_m t_0)
              (if (<= t_1 1.0)
                (sin im_m)
                (*
                 (fma re (fma re (fma re 0.16666666666666666 0.5) 1.0) 1.0)
                 (fma
                  (fma (* im_m im_m) 0.008333333333333333 -0.16666666666666666)
                  (* im_m (* im_m im_m))
                  im_m)))))))))
    im\_m = fabs(im);
    im\_s = copysign(1.0, im);
    double code(double im_s, double re, double im_m) {
    	double t_0 = -0.16666666666666666 * (im_m * im_m);
    	double t_1 = exp(re) * sin(im_m);
    	double tmp;
    	if (t_1 <= -((double) INFINITY)) {
    		tmp = (re + 1.0) * fma(im_m, t_0, im_m);
    	} else if (t_1 <= -0.02) {
    		tmp = sin(im_m);
    	} else if (t_1 <= 0.0) {
    		tmp = im_m * t_0;
    	} else if (t_1 <= 1.0) {
    		tmp = sin(im_m);
    	} else {
    		tmp = fma(re, fma(re, fma(re, 0.16666666666666666, 0.5), 1.0), 1.0) * fma(fma((im_m * im_m), 0.008333333333333333, -0.16666666666666666), (im_m * (im_m * im_m)), im_m);
    	}
    	return im_s * tmp;
    }
    
    im\_m = abs(im)
    im\_s = copysign(1.0, im)
    function code(im_s, re, im_m)
    	t_0 = Float64(-0.16666666666666666 * Float64(im_m * im_m))
    	t_1 = Float64(exp(re) * sin(im_m))
    	tmp = 0.0
    	if (t_1 <= Float64(-Inf))
    		tmp = Float64(Float64(re + 1.0) * fma(im_m, t_0, im_m));
    	elseif (t_1 <= -0.02)
    		tmp = sin(im_m);
    	elseif (t_1 <= 0.0)
    		tmp = Float64(im_m * t_0);
    	elseif (t_1 <= 1.0)
    		tmp = sin(im_m);
    	else
    		tmp = Float64(fma(re, fma(re, fma(re, 0.16666666666666666, 0.5), 1.0), 1.0) * fma(fma(Float64(im_m * im_m), 0.008333333333333333, -0.16666666666666666), Float64(im_m * Float64(im_m * im_m)), im_m));
    	end
    	return Float64(im_s * tmp)
    end
    
    im\_m = N[Abs[im], $MachinePrecision]
    im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[im$95$s_, re_, im$95$m_] := Block[{t$95$0 = N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision]}, N[(im$95$s * If[LessEqual[t$95$1, (-Infinity)], N[(N[(re + 1.0), $MachinePrecision] * N[(im$95$m * t$95$0 + im$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -0.02], N[Sin[im$95$m], $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(im$95$m * t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 1.0], N[Sin[im$95$m], $MachinePrecision], N[(N[(re * N[(re * N[(re * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[(im$95$m * im$95$m), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(im$95$m * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision] + im$95$m), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]]
    
    \begin{array}{l}
    im\_m = \left|im\right|
    \\
    im\_s = \mathsf{copysign}\left(1, im\right)
    
    \\
    \begin{array}{l}
    t_0 := -0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\\
    t_1 := e^{re} \cdot \sin im\_m\\
    im\_s \cdot \begin{array}{l}
    \mathbf{if}\;t\_1 \leq -\infty:\\
    \;\;\;\;\left(re + 1\right) \cdot \mathsf{fma}\left(im\_m, t\_0, im\_m\right)\\
    
    \mathbf{elif}\;t\_1 \leq -0.02:\\
    \;\;\;\;\sin im\_m\\
    
    \mathbf{elif}\;t\_1 \leq 0:\\
    \;\;\;\;im\_m \cdot t\_0\\
    
    \mathbf{elif}\;t\_1 \leq 1:\\
    \;\;\;\;\sin im\_m\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(re, \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), 1\right), 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im\_m \cdot im\_m, 0.008333333333333333, -0.16666666666666666\right), im\_m \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\
    
    
    \end{array}
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -inf.0

      1. Initial program 100.0%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -inf.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0200000000000000004 or -0.0 < (*.f64 (exp.f64 re) (sin.f64 im)) < 1

      1. Initial program 99.9%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0

        \[\leadsto \color{blue}{\sin im} \]
      4. Step-by-step derivation
        1. lower-sin.f6497.7

          \[\leadsto \color{blue}{\sin im} \]
      5. Applied rewrites97.7%

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

      if -0.0200000000000000004 < (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0

      1. Initial program 100.0%

        \[e^{re} \cdot \sin im \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0

        \[\leadsto \color{blue}{\sin im} \]
      4. Step-by-step derivation
        1. lower-sin.f6436.8

          \[\leadsto \color{blue}{\sin im} \]
      5. Applied rewrites36.8%

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

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

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

          \[\leadsto \frac{-1}{6} \cdot {im}^{\color{blue}{3}} \]
        3. Step-by-step derivation
          1. Applied rewrites32.4%

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

          if 1 < (*.f64 (exp.f64 re) (sin.f64 im))

          1. Initial program 100.0%

            \[e^{re} \cdot \sin im \]
          2. Add Preprocessing
          3. Taylor expanded in re around 0

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

              \[\leadsto \color{blue}{\left(re + 1\right)} \cdot \sin im \]
            2. lower-+.f644.9

              \[\leadsto \color{blue}{\left(re + 1\right)} \cdot \sin im \]
          5. Applied rewrites4.9%

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(re + 1\right) \cdot \mathsf{fma}\left(\color{blue}{{im}^{2} \cdot \frac{1}{120}} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right), {im}^{3}, im\right) \]
            11. metadata-evalN/A

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

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

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

              \[\leadsto \left(re + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{im \cdot im}, \frac{1}{120}, \frac{-1}{6}\right), {im}^{3}, im\right) \]
            15. cube-multN/A

              \[\leadsto \left(re + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im \cdot im, \frac{1}{120}, \frac{-1}{6}\right), \color{blue}{im \cdot \left(im \cdot im\right)}, im\right) \]
            16. unpow2N/A

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

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

              \[\leadsto \left(re + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im \cdot im, \frac{1}{120}, \frac{-1}{6}\right), im \cdot \color{blue}{\left(im \cdot im\right)}, im\right) \]
            19. lower-*.f6421.2

              \[\leadsto \left(re + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im \cdot im, 0.008333333333333333, -0.16666666666666666\right), im \cdot \color{blue}{\left(im \cdot im\right)}, im\right) \]
          8. Applied rewrites21.2%

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

            \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im \cdot im, \frac{1}{120}, \frac{-1}{6}\right), im \cdot \left(im \cdot im\right), im\right) \]
          10. Applied rewrites53.3%

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

        Alternative 6: 53.4% accurate, 0.8× speedup?

        \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\ \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(re, \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), 1\right), 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im\_m \cdot im\_m, 0.008333333333333333, -0.16666666666666666\right), im\_m \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\ \end{array} \end{array} \]
        im\_m = (fabs.f64 im)
        im\_s = (copysign.f64 #s(literal 1 binary64) im)
        (FPCore (im_s re im_m)
         :precision binary64
         (*
          im_s
          (if (<= (* (exp re) (sin im_m)) 0.0)
            (* im_m (* -0.16666666666666666 (* im_m im_m)))
            (*
             (fma re (fma re (fma re 0.16666666666666666 0.5) 1.0) 1.0)
             (fma
              (fma (* im_m im_m) 0.008333333333333333 -0.16666666666666666)
              (* im_m (* im_m im_m))
              im_m)))))
        im\_m = fabs(im);
        im\_s = copysign(1.0, im);
        double code(double im_s, double re, double im_m) {
        	double tmp;
        	if ((exp(re) * sin(im_m)) <= 0.0) {
        		tmp = im_m * (-0.16666666666666666 * (im_m * im_m));
        	} else {
        		tmp = fma(re, fma(re, fma(re, 0.16666666666666666, 0.5), 1.0), 1.0) * fma(fma((im_m * im_m), 0.008333333333333333, -0.16666666666666666), (im_m * (im_m * im_m)), im_m);
        	}
        	return im_s * tmp;
        }
        
        im\_m = abs(im)
        im\_s = copysign(1.0, im)
        function code(im_s, re, im_m)
        	tmp = 0.0
        	if (Float64(exp(re) * sin(im_m)) <= 0.0)
        		tmp = Float64(im_m * Float64(-0.16666666666666666 * Float64(im_m * im_m)));
        	else
        		tmp = Float64(fma(re, fma(re, fma(re, 0.16666666666666666, 0.5), 1.0), 1.0) * fma(fma(Float64(im_m * im_m), 0.008333333333333333, -0.16666666666666666), Float64(im_m * Float64(im_m * im_m)), im_m));
        	end
        	return Float64(im_s * tmp)
        end
        
        im\_m = N[Abs[im], $MachinePrecision]
        im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
        code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision], 0.0], N[(im$95$m * N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(re * N[(re * N[(re * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[(im$95$m * im$95$m), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(im$95$m * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision] + im$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
        
        \begin{array}{l}
        im\_m = \left|im\right|
        \\
        im\_s = \mathsf{copysign}\left(1, im\right)
        
        \\
        im\_s \cdot \begin{array}{l}
        \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\
        \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(re, \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), 1\right), 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im\_m \cdot im\_m, 0.008333333333333333, -0.16666666666666666\right), im\_m \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0

          1. Initial program 100.0%

            \[e^{re} \cdot \sin im \]
          2. Add Preprocessing
          3. Taylor expanded in re around 0

            \[\leadsto \color{blue}{\sin im} \]
          4. Step-by-step derivation
            1. lower-sin.f6446.3

              \[\leadsto \color{blue}{\sin im} \]
          5. Applied rewrites46.3%

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

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

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

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

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

              if -0.0 < (*.f64 (exp.f64 re) (sin.f64 im))

              1. Initial program 100.0%

                \[e^{re} \cdot \sin im \]
              2. Add Preprocessing
              3. Taylor expanded in re around 0

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

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

                  \[\leadsto \color{blue}{\left(re + 1\right)} \cdot \sin im \]
              5. Applied rewrites66.4%

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(re + 1\right) \cdot \mathsf{fma}\left(\color{blue}{{im}^{2} \cdot \frac{1}{120}} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right), {im}^{3}, im\right) \]
                11. metadata-evalN/A

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

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

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

                  \[\leadsto \left(re + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{im \cdot im}, \frac{1}{120}, \frac{-1}{6}\right), {im}^{3}, im\right) \]
                15. cube-multN/A

                  \[\leadsto \left(re + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im \cdot im, \frac{1}{120}, \frac{-1}{6}\right), \color{blue}{im \cdot \left(im \cdot im\right)}, im\right) \]
                16. unpow2N/A

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

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

                  \[\leadsto \left(re + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im \cdot im, \frac{1}{120}, \frac{-1}{6}\right), im \cdot \color{blue}{\left(im \cdot im\right)}, im\right) \]
                19. lower-*.f6441.0

                  \[\leadsto \left(re + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im \cdot im, 0.008333333333333333, -0.16666666666666666\right), im \cdot \color{blue}{\left(im \cdot im\right)}, im\right) \]
              8. Applied rewrites41.0%

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

                \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im \cdot im, \frac{1}{120}, \frac{-1}{6}\right), im \cdot \left(im \cdot im\right), im\right) \]
              10. Applied rewrites52.4%

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

            Alternative 7: 51.5% accurate, 0.8× speedup?

            \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\ \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.5, 1\right), 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im\_m \cdot im\_m, 0.008333333333333333, -0.16666666666666666\right), im\_m \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\ \end{array} \end{array} \]
            im\_m = (fabs.f64 im)
            im\_s = (copysign.f64 #s(literal 1 binary64) im)
            (FPCore (im_s re im_m)
             :precision binary64
             (*
              im_s
              (if (<= (* (exp re) (sin im_m)) 0.0)
                (* im_m (* -0.16666666666666666 (* im_m im_m)))
                (*
                 (fma re (fma re 0.5 1.0) 1.0)
                 (fma
                  (fma (* im_m im_m) 0.008333333333333333 -0.16666666666666666)
                  (* im_m (* im_m im_m))
                  im_m)))))
            im\_m = fabs(im);
            im\_s = copysign(1.0, im);
            double code(double im_s, double re, double im_m) {
            	double tmp;
            	if ((exp(re) * sin(im_m)) <= 0.0) {
            		tmp = im_m * (-0.16666666666666666 * (im_m * im_m));
            	} else {
            		tmp = fma(re, fma(re, 0.5, 1.0), 1.0) * fma(fma((im_m * im_m), 0.008333333333333333, -0.16666666666666666), (im_m * (im_m * im_m)), im_m);
            	}
            	return im_s * tmp;
            }
            
            im\_m = abs(im)
            im\_s = copysign(1.0, im)
            function code(im_s, re, im_m)
            	tmp = 0.0
            	if (Float64(exp(re) * sin(im_m)) <= 0.0)
            		tmp = Float64(im_m * Float64(-0.16666666666666666 * Float64(im_m * im_m)));
            	else
            		tmp = Float64(fma(re, fma(re, 0.5, 1.0), 1.0) * fma(fma(Float64(im_m * im_m), 0.008333333333333333, -0.16666666666666666), Float64(im_m * Float64(im_m * im_m)), im_m));
            	end
            	return Float64(im_s * tmp)
            end
            
            im\_m = N[Abs[im], $MachinePrecision]
            im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
            code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision], 0.0], N[(im$95$m * N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(re * N[(re * 0.5 + 1.0), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[(im$95$m * im$95$m), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision] * N[(im$95$m * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision] + im$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
            
            \begin{array}{l}
            im\_m = \left|im\right|
            \\
            im\_s = \mathsf{copysign}\left(1, im\right)
            
            \\
            im\_s \cdot \begin{array}{l}
            \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\
            \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.5, 1\right), 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im\_m \cdot im\_m, 0.008333333333333333, -0.16666666666666666\right), im\_m \cdot \left(im\_m \cdot im\_m\right), im\_m\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0

              1. Initial program 100.0%

                \[e^{re} \cdot \sin im \]
              2. Add Preprocessing
              3. Taylor expanded in re around 0

                \[\leadsto \color{blue}{\sin im} \]
              4. Step-by-step derivation
                1. lower-sin.f6446.3

                  \[\leadsto \color{blue}{\sin im} \]
              5. Applied rewrites46.3%

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

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

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

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

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

                  if -0.0 < (*.f64 (exp.f64 re) (sin.f64 im))

                  1. Initial program 100.0%

                    \[e^{re} \cdot \sin im \]
                  2. Add Preprocessing
                  3. Taylor expanded in re around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(re, \mathsf{fma}\left(re, \frac{1}{2}, 1\right), 1\right) \cdot \mathsf{fma}\left(\color{blue}{{im}^{2} \cdot \frac{1}{120}} + \left(\mathsf{neg}\left(\frac{1}{6}\right)\right), {im}^{3}, im\right) \]
                    11. metadata-evalN/A

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(re, \mathsf{fma}\left(re, \frac{1}{2}, 1\right), 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im \cdot im, \frac{1}{120}, \frac{-1}{6}\right), im \cdot \color{blue}{\left(im \cdot im\right)}, im\right) \]
                    19. lower-*.f6452.3

                      \[\leadsto \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.5, 1\right), 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im \cdot im, 0.008333333333333333, -0.16666666666666666\right), im \cdot \color{blue}{\left(im \cdot im\right)}, im\right) \]
                  8. Applied rewrites52.3%

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

                Alternative 8: 52.9% accurate, 0.9× speedup?

                \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\ \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \left(re + \left(1 + re \cdot \left(re \cdot \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right)\right)\right)\right)\\ \end{array} \end{array} \]
                im\_m = (fabs.f64 im)
                im\_s = (copysign.f64 #s(literal 1 binary64) im)
                (FPCore (im_s re im_m)
                 :precision binary64
                 (*
                  im_s
                  (if (<= (* (exp re) (sin im_m)) 0.0)
                    (* im_m (* -0.16666666666666666 (* im_m im_m)))
                    (* im_m (+ re (+ 1.0 (* re (* re (fma re 0.16666666666666666 0.5)))))))))
                im\_m = fabs(im);
                im\_s = copysign(1.0, im);
                double code(double im_s, double re, double im_m) {
                	double tmp;
                	if ((exp(re) * sin(im_m)) <= 0.0) {
                		tmp = im_m * (-0.16666666666666666 * (im_m * im_m));
                	} else {
                		tmp = im_m * (re + (1.0 + (re * (re * fma(re, 0.16666666666666666, 0.5)))));
                	}
                	return im_s * tmp;
                }
                
                im\_m = abs(im)
                im\_s = copysign(1.0, im)
                function code(im_s, re, im_m)
                	tmp = 0.0
                	if (Float64(exp(re) * sin(im_m)) <= 0.0)
                		tmp = Float64(im_m * Float64(-0.16666666666666666 * Float64(im_m * im_m)));
                	else
                		tmp = Float64(im_m * Float64(re + Float64(1.0 + Float64(re * Float64(re * fma(re, 0.16666666666666666, 0.5))))));
                	end
                	return Float64(im_s * tmp)
                end
                
                im\_m = N[Abs[im], $MachinePrecision]
                im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
                code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision], 0.0], N[(im$95$m * N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im$95$m * N[(re + N[(1.0 + N[(re * N[(re * N[(re * 0.16666666666666666 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
                
                \begin{array}{l}
                im\_m = \left|im\right|
                \\
                im\_s = \mathsf{copysign}\left(1, im\right)
                
                \\
                im\_s \cdot \begin{array}{l}
                \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\
                \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;im\_m \cdot \left(re + \left(1 + re \cdot \left(re \cdot \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right)\right)\right)\right)\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0

                  1. Initial program 100.0%

                    \[e^{re} \cdot \sin im \]
                  2. Add Preprocessing
                  3. Taylor expanded in re around 0

                    \[\leadsto \color{blue}{\sin im} \]
                  4. Step-by-step derivation
                    1. lower-sin.f6446.3

                      \[\leadsto \color{blue}{\sin im} \]
                  5. Applied rewrites46.3%

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

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

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

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

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

                      if -0.0 < (*.f64 (exp.f64 re) (sin.f64 im))

                      1. Initial program 100.0%

                        \[e^{re} \cdot \sin im \]
                      2. Add Preprocessing
                      3. Taylor expanded in im around 0

                        \[\leadsto \color{blue}{im \cdot e^{re}} \]
                      4. Step-by-step derivation
                        1. lower-*.f64N/A

                          \[\leadsto \color{blue}{im \cdot e^{re}} \]
                        2. lower-exp.f6456.9

                          \[\leadsto im \cdot \color{blue}{e^{re}} \]
                      5. Applied rewrites56.9%

                        \[\leadsto \color{blue}{im \cdot e^{re}} \]
                      6. Taylor expanded in re around 0

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

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

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

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

                        Alternative 9: 52.9% accurate, 0.9× speedup?

                        \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\ \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), 1\right), 1\right)\\ \end{array} \end{array} \]
                        im\_m = (fabs.f64 im)
                        im\_s = (copysign.f64 #s(literal 1 binary64) im)
                        (FPCore (im_s re im_m)
                         :precision binary64
                         (*
                          im_s
                          (if (<= (* (exp re) (sin im_m)) 0.0)
                            (* im_m (* -0.16666666666666666 (* im_m im_m)))
                            (* im_m (fma re (fma re (fma re 0.16666666666666666 0.5) 1.0) 1.0)))))
                        im\_m = fabs(im);
                        im\_s = copysign(1.0, im);
                        double code(double im_s, double re, double im_m) {
                        	double tmp;
                        	if ((exp(re) * sin(im_m)) <= 0.0) {
                        		tmp = im_m * (-0.16666666666666666 * (im_m * im_m));
                        	} else {
                        		tmp = im_m * fma(re, fma(re, fma(re, 0.16666666666666666, 0.5), 1.0), 1.0);
                        	}
                        	return im_s * tmp;
                        }
                        
                        im\_m = abs(im)
                        im\_s = copysign(1.0, im)
                        function code(im_s, re, im_m)
                        	tmp = 0.0
                        	if (Float64(exp(re) * sin(im_m)) <= 0.0)
                        		tmp = Float64(im_m * Float64(-0.16666666666666666 * Float64(im_m * im_m)));
                        	else
                        		tmp = Float64(im_m * fma(re, fma(re, fma(re, 0.16666666666666666, 0.5), 1.0), 1.0));
                        	end
                        	return Float64(im_s * tmp)
                        end
                        
                        im\_m = N[Abs[im], $MachinePrecision]
                        im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
                        code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision], 0.0], N[(im$95$m * N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im$95$m * N[(re * N[(re * N[(re * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
                        
                        \begin{array}{l}
                        im\_m = \left|im\right|
                        \\
                        im\_s = \mathsf{copysign}\left(1, im\right)
                        
                        \\
                        im\_s \cdot \begin{array}{l}
                        \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\
                        \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;im\_m \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), 1\right), 1\right)\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0

                          1. Initial program 100.0%

                            \[e^{re} \cdot \sin im \]
                          2. Add Preprocessing
                          3. Taylor expanded in re around 0

                            \[\leadsto \color{blue}{\sin im} \]
                          4. Step-by-step derivation
                            1. lower-sin.f6446.3

                              \[\leadsto \color{blue}{\sin im} \]
                          5. Applied rewrites46.3%

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

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

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

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

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

                              if -0.0 < (*.f64 (exp.f64 re) (sin.f64 im))

                              1. Initial program 100.0%

                                \[e^{re} \cdot \sin im \]
                              2. Add Preprocessing
                              3. Taylor expanded in im around 0

                                \[\leadsto \color{blue}{im \cdot e^{re}} \]
                              4. Step-by-step derivation
                                1. lower-*.f64N/A

                                  \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                2. lower-exp.f6456.9

                                  \[\leadsto im \cdot \color{blue}{e^{re}} \]
                              5. Applied rewrites56.9%

                                \[\leadsto \color{blue}{im \cdot e^{re}} \]
                              6. Taylor expanded in re around 0

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

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

                              Alternative 10: 51.5% accurate, 0.9× speedup?

                              \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\ \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(re, \mathsf{fma}\left(im\_m, re \cdot \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), im\_m\right), im\_m\right)\\ \end{array} \end{array} \]
                              im\_m = (fabs.f64 im)
                              im\_s = (copysign.f64 #s(literal 1 binary64) im)
                              (FPCore (im_s re im_m)
                               :precision binary64
                               (*
                                im_s
                                (if (<= (* (exp re) (sin im_m)) 0.0)
                                  (* im_m (* -0.16666666666666666 (* im_m im_m)))
                                  (fma re (fma im_m (* re (fma re 0.16666666666666666 0.5)) im_m) im_m))))
                              im\_m = fabs(im);
                              im\_s = copysign(1.0, im);
                              double code(double im_s, double re, double im_m) {
                              	double tmp;
                              	if ((exp(re) * sin(im_m)) <= 0.0) {
                              		tmp = im_m * (-0.16666666666666666 * (im_m * im_m));
                              	} else {
                              		tmp = fma(re, fma(im_m, (re * fma(re, 0.16666666666666666, 0.5)), im_m), im_m);
                              	}
                              	return im_s * tmp;
                              }
                              
                              im\_m = abs(im)
                              im\_s = copysign(1.0, im)
                              function code(im_s, re, im_m)
                              	tmp = 0.0
                              	if (Float64(exp(re) * sin(im_m)) <= 0.0)
                              		tmp = Float64(im_m * Float64(-0.16666666666666666 * Float64(im_m * im_m)));
                              	else
                              		tmp = fma(re, fma(im_m, Float64(re * fma(re, 0.16666666666666666, 0.5)), im_m), im_m);
                              	end
                              	return Float64(im_s * tmp)
                              end
                              
                              im\_m = N[Abs[im], $MachinePrecision]
                              im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
                              code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision], 0.0], N[(im$95$m * N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(im$95$m * N[(re * N[(re * 0.16666666666666666 + 0.5), $MachinePrecision]), $MachinePrecision] + im$95$m), $MachinePrecision] + im$95$m), $MachinePrecision]]), $MachinePrecision]
                              
                              \begin{array}{l}
                              im\_m = \left|im\right|
                              \\
                              im\_s = \mathsf{copysign}\left(1, im\right)
                              
                              \\
                              im\_s \cdot \begin{array}{l}
                              \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\
                              \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\mathsf{fma}\left(re, \mathsf{fma}\left(im\_m, re \cdot \mathsf{fma}\left(re, 0.16666666666666666, 0.5\right), im\_m\right), im\_m\right)\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0

                                1. Initial program 100.0%

                                  \[e^{re} \cdot \sin im \]
                                2. Add Preprocessing
                                3. Taylor expanded in re around 0

                                  \[\leadsto \color{blue}{\sin im} \]
                                4. Step-by-step derivation
                                  1. lower-sin.f6446.3

                                    \[\leadsto \color{blue}{\sin im} \]
                                5. Applied rewrites46.3%

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

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

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

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

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

                                    if -0.0 < (*.f64 (exp.f64 re) (sin.f64 im))

                                    1. Initial program 100.0%

                                      \[e^{re} \cdot \sin im \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in im around 0

                                      \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                    4. Step-by-step derivation
                                      1. lower-*.f64N/A

                                        \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                      2. lower-exp.f6456.9

                                        \[\leadsto im \cdot \color{blue}{e^{re}} \]
                                    5. Applied rewrites56.9%

                                      \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                    6. Taylor expanded in re around 0

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

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

                                    Alternative 11: 50.5% accurate, 0.9× speedup?

                                    \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\ \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im\_m \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.5, 1\right), 1\right)\\ \end{array} \end{array} \]
                                    im\_m = (fabs.f64 im)
                                    im\_s = (copysign.f64 #s(literal 1 binary64) im)
                                    (FPCore (im_s re im_m)
                                     :precision binary64
                                     (*
                                      im_s
                                      (if (<= (* (exp re) (sin im_m)) 0.0)
                                        (* im_m (* -0.16666666666666666 (* im_m im_m)))
                                        (* im_m (fma re (fma re 0.5 1.0) 1.0)))))
                                    im\_m = fabs(im);
                                    im\_s = copysign(1.0, im);
                                    double code(double im_s, double re, double im_m) {
                                    	double tmp;
                                    	if ((exp(re) * sin(im_m)) <= 0.0) {
                                    		tmp = im_m * (-0.16666666666666666 * (im_m * im_m));
                                    	} else {
                                    		tmp = im_m * fma(re, fma(re, 0.5, 1.0), 1.0);
                                    	}
                                    	return im_s * tmp;
                                    }
                                    
                                    im\_m = abs(im)
                                    im\_s = copysign(1.0, im)
                                    function code(im_s, re, im_m)
                                    	tmp = 0.0
                                    	if (Float64(exp(re) * sin(im_m)) <= 0.0)
                                    		tmp = Float64(im_m * Float64(-0.16666666666666666 * Float64(im_m * im_m)));
                                    	else
                                    		tmp = Float64(im_m * fma(re, fma(re, 0.5, 1.0), 1.0));
                                    	end
                                    	return Float64(im_s * tmp)
                                    end
                                    
                                    im\_m = N[Abs[im], $MachinePrecision]
                                    im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
                                    code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision], 0.0], N[(im$95$m * N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im$95$m * N[(re * N[(re * 0.5 + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
                                    
                                    \begin{array}{l}
                                    im\_m = \left|im\right|
                                    \\
                                    im\_s = \mathsf{copysign}\left(1, im\right)
                                    
                                    \\
                                    im\_s \cdot \begin{array}{l}
                                    \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\
                                    \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;im\_m \cdot \mathsf{fma}\left(re, \mathsf{fma}\left(re, 0.5, 1\right), 1\right)\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0

                                      1. Initial program 100.0%

                                        \[e^{re} \cdot \sin im \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in re around 0

                                        \[\leadsto \color{blue}{\sin im} \]
                                      4. Step-by-step derivation
                                        1. lower-sin.f6446.3

                                          \[\leadsto \color{blue}{\sin im} \]
                                      5. Applied rewrites46.3%

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

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

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

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

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

                                          if -0.0 < (*.f64 (exp.f64 re) (sin.f64 im))

                                          1. Initial program 100.0%

                                            \[e^{re} \cdot \sin im \]
                                          2. Add Preprocessing
                                          3. Taylor expanded in im around 0

                                            \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                          4. Step-by-step derivation
                                            1. lower-*.f64N/A

                                              \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                            2. lower-exp.f6456.9

                                              \[\leadsto im \cdot \color{blue}{e^{re}} \]
                                          5. Applied rewrites56.9%

                                            \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                          6. Taylor expanded in re around 0

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

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

                                          Alternative 12: 47.6% accurate, 0.9× speedup?

                                          \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\ \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(re, \mathsf{fma}\left(re, im\_m \cdot 0.5, im\_m\right), im\_m\right)\\ \end{array} \end{array} \]
                                          im\_m = (fabs.f64 im)
                                          im\_s = (copysign.f64 #s(literal 1 binary64) im)
                                          (FPCore (im_s re im_m)
                                           :precision binary64
                                           (*
                                            im_s
                                            (if (<= (* (exp re) (sin im_m)) 0.0)
                                              (* im_m (* -0.16666666666666666 (* im_m im_m)))
                                              (fma re (fma re (* im_m 0.5) im_m) im_m))))
                                          im\_m = fabs(im);
                                          im\_s = copysign(1.0, im);
                                          double code(double im_s, double re, double im_m) {
                                          	double tmp;
                                          	if ((exp(re) * sin(im_m)) <= 0.0) {
                                          		tmp = im_m * (-0.16666666666666666 * (im_m * im_m));
                                          	} else {
                                          		tmp = fma(re, fma(re, (im_m * 0.5), im_m), im_m);
                                          	}
                                          	return im_s * tmp;
                                          }
                                          
                                          im\_m = abs(im)
                                          im\_s = copysign(1.0, im)
                                          function code(im_s, re, im_m)
                                          	tmp = 0.0
                                          	if (Float64(exp(re) * sin(im_m)) <= 0.0)
                                          		tmp = Float64(im_m * Float64(-0.16666666666666666 * Float64(im_m * im_m)));
                                          	else
                                          		tmp = fma(re, fma(re, Float64(im_m * 0.5), im_m), im_m);
                                          	end
                                          	return Float64(im_s * tmp)
                                          end
                                          
                                          im\_m = N[Abs[im], $MachinePrecision]
                                          im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
                                          code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision], 0.0], N[(im$95$m * N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(re * N[(im$95$m * 0.5), $MachinePrecision] + im$95$m), $MachinePrecision] + im$95$m), $MachinePrecision]]), $MachinePrecision]
                                          
                                          \begin{array}{l}
                                          im\_m = \left|im\right|
                                          \\
                                          im\_s = \mathsf{copysign}\left(1, im\right)
                                          
                                          \\
                                          im\_s \cdot \begin{array}{l}
                                          \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\
                                          \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;\mathsf{fma}\left(re, \mathsf{fma}\left(re, im\_m \cdot 0.5, im\_m\right), im\_m\right)\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0

                                            1. Initial program 100.0%

                                              \[e^{re} \cdot \sin im \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in re around 0

                                              \[\leadsto \color{blue}{\sin im} \]
                                            4. Step-by-step derivation
                                              1. lower-sin.f6446.3

                                                \[\leadsto \color{blue}{\sin im} \]
                                            5. Applied rewrites46.3%

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

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

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

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

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

                                                if -0.0 < (*.f64 (exp.f64 re) (sin.f64 im))

                                                1. Initial program 100.0%

                                                  \[e^{re} \cdot \sin im \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in im around 0

                                                  \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                4. Step-by-step derivation
                                                  1. lower-*.f64N/A

                                                    \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                  2. lower-exp.f6456.9

                                                    \[\leadsto im \cdot \color{blue}{e^{re}} \]
                                                5. Applied rewrites56.9%

                                                  \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                6. Taylor expanded in re around 0

                                                  \[\leadsto im \cdot 1 \]
                                                7. Step-by-step derivation
                                                  1. Applied rewrites33.8%

                                                    \[\leadsto im \cdot 1 \]
                                                  2. Taylor expanded in re around 0

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

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

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

                                                  Alternative 13: 42.8% accurate, 0.9× speedup?

                                                  \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\ \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(im\_m, re, im\_m\right)\\ \end{array} \end{array} \]
                                                  im\_m = (fabs.f64 im)
                                                  im\_s = (copysign.f64 #s(literal 1 binary64) im)
                                                  (FPCore (im_s re im_m)
                                                   :precision binary64
                                                   (*
                                                    im_s
                                                    (if (<= (* (exp re) (sin im_m)) 0.0)
                                                      (* im_m (* -0.16666666666666666 (* im_m im_m)))
                                                      (fma im_m re im_m))))
                                                  im\_m = fabs(im);
                                                  im\_s = copysign(1.0, im);
                                                  double code(double im_s, double re, double im_m) {
                                                  	double tmp;
                                                  	if ((exp(re) * sin(im_m)) <= 0.0) {
                                                  		tmp = im_m * (-0.16666666666666666 * (im_m * im_m));
                                                  	} else {
                                                  		tmp = fma(im_m, re, im_m);
                                                  	}
                                                  	return im_s * tmp;
                                                  }
                                                  
                                                  im\_m = abs(im)
                                                  im\_s = copysign(1.0, im)
                                                  function code(im_s, re, im_m)
                                                  	tmp = 0.0
                                                  	if (Float64(exp(re) * sin(im_m)) <= 0.0)
                                                  		tmp = Float64(im_m * Float64(-0.16666666666666666 * Float64(im_m * im_m)));
                                                  	else
                                                  		tmp = fma(im_m, re, im_m);
                                                  	end
                                                  	return Float64(im_s * tmp)
                                                  end
                                                  
                                                  im\_m = N[Abs[im], $MachinePrecision]
                                                  im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
                                                  code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[N[(N[Exp[re], $MachinePrecision] * N[Sin[im$95$m], $MachinePrecision]), $MachinePrecision], 0.0], N[(im$95$m * N[(-0.16666666666666666 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im$95$m * re + im$95$m), $MachinePrecision]]), $MachinePrecision]
                                                  
                                                  \begin{array}{l}
                                                  im\_m = \left|im\right|
                                                  \\
                                                  im\_s = \mathsf{copysign}\left(1, im\right)
                                                  
                                                  \\
                                                  im\_s \cdot \begin{array}{l}
                                                  \mathbf{if}\;e^{re} \cdot \sin im\_m \leq 0:\\
                                                  \;\;\;\;im\_m \cdot \left(-0.16666666666666666 \cdot \left(im\_m \cdot im\_m\right)\right)\\
                                                  
                                                  \mathbf{else}:\\
                                                  \;\;\;\;\mathsf{fma}\left(im\_m, re, im\_m\right)\\
                                                  
                                                  
                                                  \end{array}
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Split input into 2 regimes
                                                  2. if (*.f64 (exp.f64 re) (sin.f64 im)) < -0.0

                                                    1. Initial program 100.0%

                                                      \[e^{re} \cdot \sin im \]
                                                    2. Add Preprocessing
                                                    3. Taylor expanded in re around 0

                                                      \[\leadsto \color{blue}{\sin im} \]
                                                    4. Step-by-step derivation
                                                      1. lower-sin.f6446.3

                                                        \[\leadsto \color{blue}{\sin im} \]
                                                    5. Applied rewrites46.3%

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

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

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

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

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

                                                        if -0.0 < (*.f64 (exp.f64 re) (sin.f64 im))

                                                        1. Initial program 100.0%

                                                          \[e^{re} \cdot \sin im \]
                                                        2. Add Preprocessing
                                                        3. Taylor expanded in im around 0

                                                          \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                        4. Step-by-step derivation
                                                          1. lower-*.f64N/A

                                                            \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                          2. lower-exp.f6456.9

                                                            \[\leadsto im \cdot \color{blue}{e^{re}} \]
                                                        5. Applied rewrites56.9%

                                                          \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                        6. Taylor expanded in re around 0

                                                          \[\leadsto im + \color{blue}{im \cdot re} \]
                                                        7. Step-by-step derivation
                                                          1. Applied rewrites38.9%

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

                                                        Alternative 14: 100.0% accurate, 1.0× speedup?

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

                                                          \[e^{re} \cdot \sin im \]
                                                        2. Add Preprocessing
                                                        3. Add Preprocessing

                                                        Alternative 15: 30.1% accurate, 17.1× speedup?

                                                        \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \begin{array}{l} \mathbf{if}\;im\_m \leq 2.45 \cdot 10^{+39}:\\ \;\;\;\;im\_m \cdot 1\\ \mathbf{else}:\\ \;\;\;\;re \cdot im\_m\\ \end{array} \end{array} \]
                                                        im\_m = (fabs.f64 im)
                                                        im\_s = (copysign.f64 #s(literal 1 binary64) im)
                                                        (FPCore (im_s re im_m)
                                                         :precision binary64
                                                         (* im_s (if (<= im_m 2.45e+39) (* im_m 1.0) (* re im_m))))
                                                        im\_m = fabs(im);
                                                        im\_s = copysign(1.0, im);
                                                        double code(double im_s, double re, double im_m) {
                                                        	double tmp;
                                                        	if (im_m <= 2.45e+39) {
                                                        		tmp = im_m * 1.0;
                                                        	} else {
                                                        		tmp = re * im_m;
                                                        	}
                                                        	return im_s * tmp;
                                                        }
                                                        
                                                        im\_m = abs(im)
                                                        im\_s = copysign(1.0d0, im)
                                                        real(8) function code(im_s, re, im_m)
                                                            real(8), intent (in) :: im_s
                                                            real(8), intent (in) :: re
                                                            real(8), intent (in) :: im_m
                                                            real(8) :: tmp
                                                            if (im_m <= 2.45d+39) then
                                                                tmp = im_m * 1.0d0
                                                            else
                                                                tmp = re * im_m
                                                            end if
                                                            code = im_s * tmp
                                                        end function
                                                        
                                                        im\_m = Math.abs(im);
                                                        im\_s = Math.copySign(1.0, im);
                                                        public static double code(double im_s, double re, double im_m) {
                                                        	double tmp;
                                                        	if (im_m <= 2.45e+39) {
                                                        		tmp = im_m * 1.0;
                                                        	} else {
                                                        		tmp = re * im_m;
                                                        	}
                                                        	return im_s * tmp;
                                                        }
                                                        
                                                        im\_m = math.fabs(im)
                                                        im\_s = math.copysign(1.0, im)
                                                        def code(im_s, re, im_m):
                                                        	tmp = 0
                                                        	if im_m <= 2.45e+39:
                                                        		tmp = im_m * 1.0
                                                        	else:
                                                        		tmp = re * im_m
                                                        	return im_s * tmp
                                                        
                                                        im\_m = abs(im)
                                                        im\_s = copysign(1.0, im)
                                                        function code(im_s, re, im_m)
                                                        	tmp = 0.0
                                                        	if (im_m <= 2.45e+39)
                                                        		tmp = Float64(im_m * 1.0);
                                                        	else
                                                        		tmp = Float64(re * im_m);
                                                        	end
                                                        	return Float64(im_s * tmp)
                                                        end
                                                        
                                                        im\_m = abs(im);
                                                        im\_s = sign(im) * abs(1.0);
                                                        function tmp_2 = code(im_s, re, im_m)
                                                        	tmp = 0.0;
                                                        	if (im_m <= 2.45e+39)
                                                        		tmp = im_m * 1.0;
                                                        	else
                                                        		tmp = re * im_m;
                                                        	end
                                                        	tmp_2 = im_s * tmp;
                                                        end
                                                        
                                                        im\_m = N[Abs[im], $MachinePrecision]
                                                        im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
                                                        code[im$95$s_, re_, im$95$m_] := N[(im$95$s * If[LessEqual[im$95$m, 2.45e+39], N[(im$95$m * 1.0), $MachinePrecision], N[(re * im$95$m), $MachinePrecision]]), $MachinePrecision]
                                                        
                                                        \begin{array}{l}
                                                        im\_m = \left|im\right|
                                                        \\
                                                        im\_s = \mathsf{copysign}\left(1, im\right)
                                                        
                                                        \\
                                                        im\_s \cdot \begin{array}{l}
                                                        \mathbf{if}\;im\_m \leq 2.45 \cdot 10^{+39}:\\
                                                        \;\;\;\;im\_m \cdot 1\\
                                                        
                                                        \mathbf{else}:\\
                                                        \;\;\;\;re \cdot im\_m\\
                                                        
                                                        
                                                        \end{array}
                                                        \end{array}
                                                        
                                                        Derivation
                                                        1. Split input into 2 regimes
                                                        2. if im < 2.44999999999999994e39

                                                          1. Initial program 100.0%

                                                            \[e^{re} \cdot \sin im \]
                                                          2. Add Preprocessing
                                                          3. Taylor expanded in im around 0

                                                            \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                          4. Step-by-step derivation
                                                            1. lower-*.f64N/A

                                                              \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                            2. lower-exp.f6477.7

                                                              \[\leadsto im \cdot \color{blue}{e^{re}} \]
                                                          5. Applied rewrites77.7%

                                                            \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                          6. Taylor expanded in re around 0

                                                            \[\leadsto im \cdot 1 \]
                                                          7. Step-by-step derivation
                                                            1. Applied rewrites34.1%

                                                              \[\leadsto im \cdot 1 \]

                                                            if 2.44999999999999994e39 < im

                                                            1. Initial program 99.9%

                                                              \[e^{re} \cdot \sin im \]
                                                            2. Add Preprocessing
                                                            3. Taylor expanded in im around 0

                                                              \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                            4. Step-by-step derivation
                                                              1. lower-*.f64N/A

                                                                \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                              2. lower-exp.f6424.3

                                                                \[\leadsto im \cdot \color{blue}{e^{re}} \]
                                                            5. Applied rewrites24.3%

                                                              \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                            6. Taylor expanded in re around 0

                                                              \[\leadsto im \cdot 1 \]
                                                            7. Step-by-step derivation
                                                              1. Applied rewrites2.5%

                                                                \[\leadsto im \cdot 1 \]
                                                              2. Taylor expanded in re around 0

                                                                \[\leadsto im + \color{blue}{im \cdot re} \]
                                                              3. Step-by-step derivation
                                                                1. Applied rewrites10.2%

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

                                                                  \[\leadsto im \cdot re \]
                                                                3. Step-by-step derivation
                                                                  1. Applied rewrites11.4%

                                                                    \[\leadsto re \cdot im \]
                                                                4. Recombined 2 regimes into one program.
                                                                5. Add Preprocessing

                                                                Alternative 16: 30.1% accurate, 29.4× speedup?

                                                                \[\begin{array}{l} im\_m = \left|im\right| \\ im\_s = \mathsf{copysign}\left(1, im\right) \\ im\_s \cdot \mathsf{fma}\left(im\_m, re, im\_m\right) \end{array} \]
                                                                im\_m = (fabs.f64 im)
                                                                im\_s = (copysign.f64 #s(literal 1 binary64) im)
                                                                (FPCore (im_s re im_m) :precision binary64 (* im_s (fma im_m re im_m)))
                                                                im\_m = fabs(im);
                                                                im\_s = copysign(1.0, im);
                                                                double code(double im_s, double re, double im_m) {
                                                                	return im_s * fma(im_m, re, im_m);
                                                                }
                                                                
                                                                im\_m = abs(im)
                                                                im\_s = copysign(1.0, im)
                                                                function code(im_s, re, im_m)
                                                                	return Float64(im_s * fma(im_m, re, im_m))
                                                                end
                                                                
                                                                im\_m = N[Abs[im], $MachinePrecision]
                                                                im\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
                                                                code[im$95$s_, re_, im$95$m_] := N[(im$95$s * N[(im$95$m * re + im$95$m), $MachinePrecision]), $MachinePrecision]
                                                                
                                                                \begin{array}{l}
                                                                im\_m = \left|im\right|
                                                                \\
                                                                im\_s = \mathsf{copysign}\left(1, im\right)
                                                                
                                                                \\
                                                                im\_s \cdot \mathsf{fma}\left(im\_m, re, im\_m\right)
                                                                \end{array}
                                                                
                                                                Derivation
                                                                1. Initial program 100.0%

                                                                  \[e^{re} \cdot \sin im \]
                                                                2. Add Preprocessing
                                                                3. Taylor expanded in im around 0

                                                                  \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                                4. Step-by-step derivation
                                                                  1. lower-*.f64N/A

                                                                    \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                                  2. lower-exp.f6464.8

                                                                    \[\leadsto im \cdot \color{blue}{e^{re}} \]
                                                                5. Applied rewrites64.8%

                                                                  \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                                6. Taylor expanded in re around 0

                                                                  \[\leadsto im + \color{blue}{im \cdot re} \]
                                                                7. Step-by-step derivation
                                                                  1. Applied rewrites29.0%

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

                                                                  Alternative 17: 6.8% accurate, 34.3× speedup?

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

                                                                    \[e^{re} \cdot \sin im \]
                                                                  2. Add Preprocessing
                                                                  3. Taylor expanded in im around 0

                                                                    \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                                  4. Step-by-step derivation
                                                                    1. lower-*.f64N/A

                                                                      \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                                    2. lower-exp.f6464.8

                                                                      \[\leadsto im \cdot \color{blue}{e^{re}} \]
                                                                  5. Applied rewrites64.8%

                                                                    \[\leadsto \color{blue}{im \cdot e^{re}} \]
                                                                  6. Taylor expanded in re around 0

                                                                    \[\leadsto im \cdot 1 \]
                                                                  7. Step-by-step derivation
                                                                    1. Applied rewrites26.5%

                                                                      \[\leadsto im \cdot 1 \]
                                                                    2. Taylor expanded in re around 0

                                                                      \[\leadsto im + \color{blue}{im \cdot re} \]
                                                                    3. Step-by-step derivation
                                                                      1. Applied rewrites29.0%

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

                                                                        \[\leadsto im \cdot re \]
                                                                      3. Step-by-step derivation
                                                                        1. Applied rewrites6.3%

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

                                                                        Reproduce

                                                                        ?
                                                                        herbie shell --seed 2024238 
                                                                        (FPCore (re im)
                                                                          :name "math.exp on complex, imaginary part"
                                                                          :precision binary64
                                                                          (* (exp re) (sin im)))