math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 11.6s
Alternatives: 20
Speedup: 1.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 20 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\sin re \cdot e^{-im}, 0.5, \sin re \cdot \left(0.5 \cdot e^{im}\right)\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (fma (* (sin re) (exp (- im))) 0.5 (* (sin re) (* 0.5 (exp im)))))
double code(double re, double im) {
	return fma((sin(re) * exp(-im)), 0.5, (sin(re) * (0.5 * exp(im))));
}
function code(re, im)
	return fma(Float64(sin(re) * exp(Float64(-im))), 0.5, Float64(sin(re) * Float64(0.5 * exp(im))))
end
code[re_, im_] := N[(N[(N[Sin[re], $MachinePrecision] * N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\sin re \cdot e^{-im}, 0.5, \sin re \cdot \left(0.5 \cdot e^{im}\right)\right)
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\sin re \cdot e^{\mathsf{neg}\left(im\right)}, \frac{1}{2}, \color{blue}{\sin re \cdot \left(\frac{1}{2} \cdot e^{im}\right)}\right) \]
    21. lower-*.f64100.0

      \[\leadsto \mathsf{fma}\left(\sin re \cdot e^{-im}, 0.5, \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im}\right)}\right) \]
  4. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\sin re \cdot e^{-im}, 0.5, \sin re \cdot \left(0.5 \cdot e^{im}\right)\right)} \]
  5. Add Preprocessing

Alternative 2: 72.1% accurate, 0.4× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-1}{6} \cdot \left({re}^{3} \cdot \left(1 + \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*r*N/A

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

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

        \[\leadsto \color{blue}{\left(1 + \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right) \cdot \left(\frac{-1}{6} \cdot {re}^{3}\right)} \]
    10. Simplified28.9%

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right) \]
    7. Simplified67.5%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right), re\right)} \]
    10. Simplified54.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, \color{blue}{im \cdot 0.001388888888888889}, 0.041666666666666664\right), 0.5\right)\right), re\right) \]
    13. Simplified54.7%

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

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

Alternative 3: 71.9% accurate, 0.4× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-1}{6} \cdot \left({re}^{3} \cdot \left(1 + \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*r*N/A

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

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

        \[\leadsto \color{blue}{\left(1 + \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right) \cdot \left(\frac{-1}{6} \cdot {re}^{3}\right)} \]
    10. Simplified28.9%

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

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

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\sin re} \]
    5. Simplified99.7%

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right) \]
    7. Simplified67.5%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right), re\right)} \]
    10. Simplified54.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, \color{blue}{im \cdot 0.001388888888888889}, 0.041666666666666664\right), 0.5\right)\right), re\right) \]
    13. Simplified54.7%

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

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

Alternative 4: 56.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.0001:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im \cdot im, 0.041666666666666664, 0.5\right), 1\right) \cdot \mathsf{fma}\left(re, -0.16666666666666666 \cdot \left(re \cdot re\right), re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right) \]
    7. Simplified44.6%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right), re\right)} \]
    10. Simplified36.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, \color{blue}{im \cdot 0.001388888888888889}, 0.041666666666666664\right), 0.5\right)\right), re\right) \]
    13. Simplified36.7%

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

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

Alternative 5: 52.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.0001:\\
\;\;\;\;\mathsf{fma}\left(0.5, im \cdot im, 1\right) \cdot \mathsf{fma}\left(re, -0.16666666666666666 \cdot \left(re \cdot re\right), re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \mathsf{fma}\left(\frac{1}{2}, \color{blue}{im \cdot im}, 1\right) \]
      14. lower-*.f6480.4

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right) \]
    7. Simplified44.6%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right), re\right)} \]
    10. Simplified36.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, \color{blue}{im \cdot 0.001388888888888889}, 0.041666666666666664\right), 0.5\right)\right), re\right) \]
    13. Simplified36.7%

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

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

Alternative 6: 52.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.0001:\\
\;\;\;\;\mathsf{fma}\left(0.5, im \cdot im, 1\right) \cdot \mathsf{fma}\left(re, -0.16666666666666666 \cdot \left(re \cdot re\right), re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \mathsf{fma}\left(\frac{1}{2}, \color{blue}{im \cdot im}, 1\right) \]
      14. lower-*.f6480.4

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right) \]
    7. Simplified44.6%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right), re\right)} \]
    10. Simplified36.7%

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

      \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \color{blue}{\left(\frac{1}{720} \cdot {im}^{4}\right)}, re\right) \]
    12. Step-by-step derivation
      1. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot 0.001388888888888889\right)\right), re\right) \]
    13. Simplified36.7%

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

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

Alternative 7: 51.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.0001:\\
\;\;\;\;\mathsf{fma}\left(0.5, im \cdot im, 1\right) \cdot \mathsf{fma}\left(re, -0.16666666666666666 \cdot \left(re \cdot re\right), re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \mathsf{fma}\left(\frac{1}{2}, \color{blue}{im \cdot im}, 1\right) \]
      14. lower-*.f6480.4

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right) \cdot re, re\right)} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(im \cdot \color{blue}{\left(im \cdot \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right)\right)}, re, re\right) \]
    10. Applied egg-rr36.7%

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

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

Alternative 8: 44.2% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.0001:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
    4. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re + \frac{-1}{6} \cdot {re}^{3}} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{-1}{6} \cdot {re}^{3} + re} \]
      2. lower-fma.f64N/A

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right) \cdot re, re\right)} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(im \cdot \color{blue}{\left(im \cdot \mathsf{fma}\left(im, im \cdot 0.041666666666666664, 0.5\right)\right)}, re, re\right) \]
    10. Applied egg-rr36.7%

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

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

Alternative 9: 42.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.0001:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
    4. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re + \frac{-1}{6} \cdot {re}^{3}} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{-1}{6} \cdot {re}^{3} + re} \]
      2. lower-fma.f64N/A

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 42.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.0001:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
    4. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re + \frac{-1}{6} \cdot {re}^{3}} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{-1}{6} \cdot {re}^{3} + re} \]
      2. lower-fma.f64N/A

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(im \cdot im, \left(\color{blue}{\left(im \cdot im\right)} \cdot 0.041666666666666664\right) \cdot re, re\right) \]
    11. Simplified29.7%

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

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

Alternative 11: 42.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.0001:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\

\mathbf{else}:\\
\;\;\;\;im \cdot \left(im \cdot \left(0.041666666666666664 \cdot \left(re \cdot \left(im \cdot im\right)\right)\right)\right)\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
    4. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re + \frac{-1}{6} \cdot {re}^{3}} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{-1}{6} \cdot {re}^{3} + re} \]
      2. lower-fma.f64N/A

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{24} \cdot \left({im}^{4} \cdot re\right)} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto im \cdot \left(im \cdot \left(\frac{1}{24} \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot re\right)\right)\right) \]
      15. lower-*.f6429.2

        \[\leadsto im \cdot \left(im \cdot \left(0.041666666666666664 \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot re\right)\right)\right) \]
    11. Simplified29.2%

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

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

Alternative 12: 40.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.0001:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
    4. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re + \frac{-1}{6} \cdot {re}^{3}} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{-1}{6} \cdot {re}^{3} + re} \]
      2. lower-fma.f64N/A

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 40.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.0001:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\

\mathbf{else}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left(re \cdot 0.5\right)\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
    4. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re + \frac{-1}{6} \cdot {re}^{3}} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{-1}{6} \cdot {re}^{3} + re} \]
      2. lower-fma.f64N/A

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{im \cdot \left(\frac{1}{2} \cdot im\right)} + 1\right) \cdot \sin re \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)} \]
      8. lower-sin.f64N/A

        \[\leadsto \color{blue}{\sin re} \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right) \]
      9. *-commutativeN/A

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \]
      10. associate-*r*N/A

        \[\leadsto \sin re \cdot \left(\color{blue}{\frac{1}{2} \cdot \left(im \cdot im\right)} + 1\right) \]
      11. unpow2N/A

        \[\leadsto \sin re \cdot \left(\frac{1}{2} \cdot \color{blue}{{im}^{2}} + 1\right) \]
      12. lower-fma.f64N/A

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{2}, {im}^{2}, 1\right)} \]
      13. unpow2N/A

        \[\leadsto \sin re \cdot \mathsf{fma}\left(\frac{1}{2}, \color{blue}{im \cdot im}, 1\right) \]
      14. lower-*.f6464.6

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, \color{blue}{im \cdot im}, 1\right) \]
    5. Simplified64.6%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)} \]
    6. Taylor expanded in re around 0

      \[\leadsto \color{blue}{re \cdot \left(1 + \frac{1}{2} \cdot {im}^{2}\right)} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re \cdot \color{blue}{\left(\frac{1}{2} \cdot {im}^{2} + 1\right)} \]
      2. distribute-lft-inN/A

        \[\leadsto \color{blue}{re \cdot \left(\frac{1}{2} \cdot {im}^{2}\right) + re \cdot 1} \]
      3. *-rgt-identityN/A

        \[\leadsto re \cdot \left(\frac{1}{2} \cdot {im}^{2}\right) + \color{blue}{re} \]
      4. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \frac{1}{2} \cdot {im}^{2}, re\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\frac{1}{2} \cdot {im}^{2}}, re\right) \]
      6. unpow2N/A

        \[\leadsto \mathsf{fma}\left(re, \frac{1}{2} \cdot \color{blue}{\left(im \cdot im\right)}, re\right) \]
      7. lower-*.f6421.7

        \[\leadsto \mathsf{fma}\left(re, 0.5 \cdot \color{blue}{\left(im \cdot im\right)}, re\right) \]
    8. Simplified21.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re, 0.5 \cdot \left(im \cdot im\right), re\right)} \]
    9. Taylor expanded in im around inf

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \left({im}^{2} \cdot re\right)} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot {im}^{2}\right) \cdot re} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\left({im}^{2} \cdot \frac{1}{2}\right)} \cdot re \]
      3. associate-*r*N/A

        \[\leadsto \color{blue}{{im}^{2} \cdot \left(\frac{1}{2} \cdot re\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{{im}^{2} \cdot \left(\frac{1}{2} \cdot re\right)} \]
      5. unpow2N/A

        \[\leadsto \color{blue}{\left(im \cdot im\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(im \cdot im\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
      7. lower-*.f6421.3

        \[\leadsto \left(im \cdot im\right) \cdot \color{blue}{\left(0.5 \cdot re\right)} \]
    11. Simplified21.3%

      \[\leadsto \color{blue}{\left(im \cdot im\right) \cdot \left(0.5 \cdot re\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification36.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\sin re \cdot 0.5\right) \cdot \left(e^{-im} + e^{im}\right) \leq 0.0001:\\ \;\;\;\;\mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left(re \cdot 0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 100.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \sin re \cdot \cosh im \end{array} \]
(FPCore (re im) :precision binary64 (* (sin re) (cosh im)))
double code(double re, double im) {
	return sin(re) * cosh(im);
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = sin(re) * cosh(im)
end function
public static double code(double re, double im) {
	return Math.sin(re) * Math.cosh(im);
}
def code(re, im):
	return math.sin(re) * math.cosh(im)
function code(re, im)
	return Float64(sin(re) * cosh(im))
end
function tmp = code(re, im)
	tmp = sin(re) * cosh(im);
end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[Cosh[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sin re \cdot \cosh im
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-sin.f64N/A

      \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{\sin re}\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \sin re\right)} \cdot \left(e^{0 - im} + e^{im}\right) \]
    3. lift--.f64N/A

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{\color{blue}{0 - im}} + e^{im}\right) \]
    4. lift-exp.f64N/A

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
    5. lift-exp.f64N/A

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{e^{im}}\right) \]
    6. lift-+.f64N/A

      \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + e^{im}\right)} \]
    7. *-commutativeN/A

      \[\leadsto \color{blue}{\left(e^{0 - im} + e^{im}\right) \cdot \left(\frac{1}{2} \cdot \sin re\right)} \]
    8. lift-*.f64N/A

      \[\leadsto \left(e^{0 - im} + e^{im}\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot \sin re\right)} \]
    9. associate-*r*N/A

      \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
    10. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
  4. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \sin re} \]
  5. Final simplification100.0%

    \[\leadsto \sin re \cdot \cosh im \]
  6. Add Preprocessing

Alternative 15: 87.0% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(0.5, im \cdot im, 1\right)\\ \mathbf{if}\;im \leq 3.4 \cdot 10^{-5}:\\ \;\;\;\;\sin re \cdot t\_0\\ \mathbf{elif}\;im \leq 7 \cdot 10^{+51}:\\ \;\;\;\;\cosh im \cdot \mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), t\_0\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (fma 0.5 (* im im) 1.0)))
   (if (<= im 3.4e-5)
     (* (sin re) t_0)
     (if (<= im 7e+51)
       (* (cosh im) (fma -0.16666666666666666 (* re (* re re)) re))
       (*
        (sin re)
        (fma
         (fma im (* im 0.001388888888888889) 0.041666666666666664)
         (* im (* im (* im im)))
         t_0))))))
double code(double re, double im) {
	double t_0 = fma(0.5, (im * im), 1.0);
	double tmp;
	if (im <= 3.4e-5) {
		tmp = sin(re) * t_0;
	} else if (im <= 7e+51) {
		tmp = cosh(im) * fma(-0.16666666666666666, (re * (re * re)), re);
	} else {
		tmp = sin(re) * fma(fma(im, (im * 0.001388888888888889), 0.041666666666666664), (im * (im * (im * im))), t_0);
	}
	return tmp;
}
function code(re, im)
	t_0 = fma(0.5, Float64(im * im), 1.0)
	tmp = 0.0
	if (im <= 3.4e-5)
		tmp = Float64(sin(re) * t_0);
	elseif (im <= 7e+51)
		tmp = Float64(cosh(im) * fma(-0.16666666666666666, Float64(re * Float64(re * re)), re));
	else
		tmp = Float64(sin(re) * fma(fma(im, Float64(im * 0.001388888888888889), 0.041666666666666664), Float64(im * Float64(im * Float64(im * im))), t_0));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[im, 3.4e-5], N[(N[Sin[re], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[im, 7e+51], N[(N[Cosh[im], $MachinePrecision] * N[(-0.16666666666666666 * N[(re * N[(re * re), $MachinePrecision]), $MachinePrecision] + re), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(im * N[(im * 0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(im * N[(im * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(0.5, im \cdot im, 1\right)\\
\mathbf{if}\;im \leq 3.4 \cdot 10^{-5}:\\
\;\;\;\;\sin re \cdot t\_0\\

\mathbf{elif}\;im \leq 7 \cdot 10^{+51}:\\
\;\;\;\;\cosh im \cdot \mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\

\mathbf{else}:\\
\;\;\;\;\sin re \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), t\_0\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 3.4e-5

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{\sin re + \frac{1}{2} \cdot \left({im}^{2} \cdot \sin re\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \sin re + \color{blue}{\left(\frac{1}{2} \cdot {im}^{2}\right) \cdot \sin re} \]
      2. distribute-rgt1-inN/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot {im}^{2} + 1\right) \cdot \sin re} \]
      3. unpow2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{\left(im \cdot im\right)} + 1\right) \cdot \sin re \]
      4. associate-*r*N/A

        \[\leadsto \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \cdot \sin re \]
      5. *-commutativeN/A

        \[\leadsto \left(\color{blue}{im \cdot \left(\frac{1}{2} \cdot im\right)} + 1\right) \cdot \sin re \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)} \]
      8. lower-sin.f64N/A

        \[\leadsto \color{blue}{\sin re} \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right) \]
      9. *-commutativeN/A

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \]
      10. associate-*r*N/A

        \[\leadsto \sin re \cdot \left(\color{blue}{\frac{1}{2} \cdot \left(im \cdot im\right)} + 1\right) \]
      11. unpow2N/A

        \[\leadsto \sin re \cdot \left(\frac{1}{2} \cdot \color{blue}{{im}^{2}} + 1\right) \]
      12. lower-fma.f64N/A

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{2}, {im}^{2}, 1\right)} \]
      13. unpow2N/A

        \[\leadsto \sin re \cdot \mathsf{fma}\left(\frac{1}{2}, \color{blue}{im \cdot im}, 1\right) \]
      14. lower-*.f6484.7

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, \color{blue}{im \cdot im}, 1\right) \]
    5. Simplified84.7%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)} \]

    if 3.4e-5 < im < 7e51

    1. Initial program 99.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{\sin re}\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \sin re\right)} \cdot \left(e^{0 - im} + e^{im}\right) \]
      3. lift--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{\color{blue}{0 - im}} + e^{im}\right) \]
      4. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
      5. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{e^{im}}\right) \]
      6. lift-+.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + e^{im}\right)} \]
      7. *-commutativeN/A

        \[\leadsto \color{blue}{\left(e^{0 - im} + e^{im}\right) \cdot \left(\frac{1}{2} \cdot \sin re\right)} \]
      8. lift-*.f64N/A

        \[\leadsto \left(e^{0 - im} + e^{im}\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot \sin re\right)} \]
      9. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
      10. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
    4. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0

      \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\left(re \cdot \left(1 + \frac{-1}{6} \cdot {re}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \left(re \cdot \color{blue}{\left(\frac{-1}{6} \cdot {re}^{2} + 1\right)}\right) \]
      2. distribute-lft-inN/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\left(re \cdot \left(\frac{-1}{6} \cdot {re}^{2}\right) + re \cdot 1\right)} \]
      3. *-rgt-identityN/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \left(re \cdot \left(\frac{-1}{6} \cdot {re}^{2}\right) + \color{blue}{re}\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\mathsf{fma}\left(re, \frac{-1}{6} \cdot {re}^{2}, re\right)} \]
      5. *-commutativeN/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{{re}^{2} \cdot \frac{-1}{6}}, re\right) \]
      6. lower-*.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{{re}^{2} \cdot \frac{-1}{6}}, re\right) \]
      7. unpow2N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{6}, re\right) \]
      8. lower-*.f6483.2

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \]
    7. Simplified83.2%

      \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)} \]
    8. Step-by-step derivation
      1. lift-cosh.f64N/A

        \[\leadsto \left(1 \cdot \color{blue}{\cosh im}\right) \cdot \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right) + re\right) \]
      2. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right)} \cdot \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right) + re\right) \]
      3. lift-*.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \left(re \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{6}\right) + re\right) \]
      4. lift-*.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \left(re \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right)} + re\right) \]
      5. lift-fma.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot \frac{-1}{6}, re\right)} \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot \frac{-1}{6}, re\right) \cdot \left(1 \cdot \cosh im\right)} \]
      7. lower-*.f6483.2

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right) \cdot \left(1 \cdot \cosh im\right)} \]
      8. lift-fma.f64N/A

        \[\leadsto \color{blue}{\left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right) + re\right)} \cdot \left(1 \cdot \cosh im\right) \]
      9. lift-*.f64N/A

        \[\leadsto \left(re \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right)} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      10. associate-*r*N/A

        \[\leadsto \left(\color{blue}{\left(re \cdot \left(re \cdot re\right)\right) \cdot \frac{-1}{6}} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      11. lift-*.f64N/A

        \[\leadsto \left(\left(re \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \frac{-1}{6} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      12. cube-unmultN/A

        \[\leadsto \left(\color{blue}{{re}^{3}} \cdot \frac{-1}{6} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(\color{blue}{\frac{-1}{6} \cdot {re}^{3}} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      14. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{6}, {re}^{3}, re\right)} \cdot \left(1 \cdot \cosh im\right) \]
      15. cube-unmultN/A

        \[\leadsto \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{re \cdot \left(re \cdot re\right)}, re\right) \cdot \left(1 \cdot \cosh im\right) \]
      16. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{-1}{6}, re \cdot \color{blue}{\left(re \cdot re\right)}, re\right) \cdot \left(1 \cdot \cosh im\right) \]
      17. lower-*.f6483.2

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, \color{blue}{re \cdot \left(re \cdot re\right)}, re\right) \cdot \left(1 \cdot \cosh im\right) \]
      18. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{-1}{6}, re \cdot \left(re \cdot re\right), re\right) \cdot \color{blue}{\left(1 \cdot \cosh im\right)} \]
      19. *-lft-identity83.2

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right) \cdot \color{blue}{\cosh im} \]
    9. Applied egg-rr83.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right) \cdot \cosh im} \]

    if 7e51 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{\sin re + {im}^{2} \cdot \left(\frac{1}{2} \cdot \sin re + {im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \sin re\right) + \frac{1}{24} \cdot \sin re\right)\right)} \]
    4. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification87.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.4 \cdot 10^{-5}:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)\\ \mathbf{elif}\;im \leq 7 \cdot 10^{+51}:\\ \;\;\;\;\cosh im \cdot \mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 57.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq 0.0001:\\ \;\;\;\;re \cdot \left(\mathsf{fma}\left(re \cdot re, -0.16666666666666666, 1\right) \cdot \mathsf{fma}\left(im, im \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im \cdot im, 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889\right)\right), re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= (sin re) 0.0001)
   (*
    re
    (*
     (fma (* re re) -0.16666666666666666 1.0)
     (fma
      im
      (*
       im
       (fma
        (* im im)
        (fma (* im im) 0.001388888888888889 0.041666666666666664)
        0.5))
      1.0)))
   (fma re (* (* im im) (* (* im im) (* (* im im) 0.001388888888888889))) re)))
double code(double re, double im) {
	double tmp;
	if (sin(re) <= 0.0001) {
		tmp = re * (fma((re * re), -0.16666666666666666, 1.0) * fma(im, (im * fma((im * im), fma((im * im), 0.001388888888888889, 0.041666666666666664), 0.5)), 1.0));
	} else {
		tmp = fma(re, ((im * im) * ((im * im) * ((im * im) * 0.001388888888888889))), re);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (sin(re) <= 0.0001)
		tmp = Float64(re * Float64(fma(Float64(re * re), -0.16666666666666666, 1.0) * fma(im, Float64(im * fma(Float64(im * im), fma(Float64(im * im), 0.001388888888888889, 0.041666666666666664), 0.5)), 1.0)));
	else
		tmp = fma(re, Float64(Float64(im * im) * Float64(Float64(im * im) * Float64(Float64(im * im) * 0.001388888888888889))), re);
	end
	return tmp
end
code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], 0.0001], N[(re * N[(N[(N[(re * re), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * N[(im * N[(im * N[(N[(im * im), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * 0.001388888888888889 + 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(N[(im * im), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + re), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\sin re \leq 0.0001:\\
\;\;\;\;re \cdot \left(\mathsf{fma}\left(re \cdot re, -0.16666666666666666, 1\right) \cdot \mathsf{fma}\left(im, im \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im \cdot im, 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889\right)\right), re\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sin.f64 re) < 1.00000000000000005e-4

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{\sin re + {im}^{2} \cdot \left(\frac{1}{2} \cdot \sin re + {im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \sin re\right) + \frac{1}{24} \cdot \sin re\right)\right)} \]
    4. Simplified92.9%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right)} \]
    5. Taylor expanded in re around 0

      \[\leadsto \color{blue}{re \cdot \left(1 + \left(\frac{-1}{6} \cdot \left({re}^{2} \cdot \left(1 + \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right) + \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right)} \]
    6. Simplified69.7%

      \[\leadsto \color{blue}{re \cdot \left(\mathsf{fma}\left(re \cdot re, -0.16666666666666666, 1\right) \cdot \mathsf{fma}\left(im, im \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im \cdot im, 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)\right)} \]

    if 1.00000000000000005e-4 < (sin.f64 re)

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{\sin re + {im}^{2} \cdot \left(\frac{1}{2} \cdot \sin re + {im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \sin re\right) + \frac{1}{24} \cdot \sin re\right)\right)} \]
    4. Simplified88.3%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right)} \]
    5. Taylor expanded in re around 0

      \[\leadsto \color{blue}{\left(re \cdot \left(1 + \frac{-1}{6} \cdot {re}^{2}\right)\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left(re \cdot \color{blue}{\left(\frac{-1}{6} \cdot {re}^{2} + 1\right)}\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      2. distribute-lft-inN/A

        \[\leadsto \color{blue}{\left(re \cdot \left(\frac{-1}{6} \cdot {re}^{2}\right) + re \cdot 1\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      3. *-rgt-identityN/A

        \[\leadsto \left(re \cdot \left(\frac{-1}{6} \cdot {re}^{2}\right) + \color{blue}{re}\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \frac{-1}{6} \cdot {re}^{2}, re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{{re}^{2} \cdot \frac{-1}{6}}, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      6. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{{re}^{2} \cdot \frac{-1}{6}}, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{6}, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      8. lower-*.f6429.5

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right) \]
    7. Simplified29.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right) \]
    8. Taylor expanded in re around 0

      \[\leadsto \color{blue}{re \cdot \left(1 + \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re \cdot \color{blue}{\left(\left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right) + 1\right)} \]
      2. distribute-lft-inN/A

        \[\leadsto \color{blue}{re \cdot \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right) + re \cdot 1} \]
      3. *-rgt-identityN/A

        \[\leadsto re \cdot \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right) + \color{blue}{re} \]
      4. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right), re\right)} \]
    10. Simplified18.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \mathsf{fma}\left(im, im \cdot \mathsf{fma}\left(im \cdot im, 0.001388888888888889, 0.041666666666666664\right), 0.5\right), re\right)} \]
    11. Taylor expanded in im around inf

      \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \color{blue}{\left(\frac{1}{720} \cdot {im}^{4}\right)}, re\right) \]
    12. Step-by-step derivation
      1. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \left(\frac{1}{720} \cdot {im}^{\color{blue}{\left(2 \cdot 2\right)}}\right), re\right) \]
      2. pow-sqrN/A

        \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \left(\frac{1}{720} \cdot \color{blue}{\left({im}^{2} \cdot {im}^{2}\right)}\right), re\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \color{blue}{\left(\left(\frac{1}{720} \cdot {im}^{2}\right) \cdot {im}^{2}\right)}, re\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{720} \cdot {im}^{2}\right)\right)}, re\right) \]
      5. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{720} \cdot {im}^{2}\right)\right)}, re\right) \]
      6. unpow2N/A

        \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot \left(\frac{1}{720} \cdot {im}^{2}\right)\right), re\right) \]
      7. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot \left(\frac{1}{720} \cdot {im}^{2}\right)\right), re\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \color{blue}{\left({im}^{2} \cdot \frac{1}{720}\right)}\right), re\right) \]
      9. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \color{blue}{\left({im}^{2} \cdot \frac{1}{720}\right)}\right), re\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{1}{720}\right)\right), re\right) \]
      11. lower-*.f6418.0

        \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot 0.001388888888888889\right)\right), re\right) \]
    13. Simplified18.0%

      \[\leadsto \mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)}, re\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 17: 57.0% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sin re \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot \mathsf{fma}\left(im \cdot im, 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right) \cdot \left(re \cdot \left(-0.16666666666666666 \cdot \left(re \cdot re\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right)\right), re\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= (sin re) -0.01)
   (*
    (fma
     (* im im)
     (fma
      im
      (* im (fma (* im im) 0.001388888888888889 0.041666666666666664))
      0.5)
     1.0)
    (* re (* -0.16666666666666666 (* re re))))
   (fma
    re
    (*
     im
     (*
      im
      (fma
       (* im im)
       (fma im (* im 0.001388888888888889) 0.041666666666666664)
       0.5)))
    re)))
double code(double re, double im) {
	double tmp;
	if (sin(re) <= -0.01) {
		tmp = fma((im * im), fma(im, (im * fma((im * im), 0.001388888888888889, 0.041666666666666664)), 0.5), 1.0) * (re * (-0.16666666666666666 * (re * re)));
	} else {
		tmp = fma(re, (im * (im * fma((im * im), fma(im, (im * 0.001388888888888889), 0.041666666666666664), 0.5))), re);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (sin(re) <= -0.01)
		tmp = Float64(fma(Float64(im * im), fma(im, Float64(im * fma(Float64(im * im), 0.001388888888888889, 0.041666666666666664)), 0.5), 1.0) * Float64(re * Float64(-0.16666666666666666 * Float64(re * re))));
	else
		tmp = fma(re, Float64(im * Float64(im * fma(Float64(im * im), fma(im, Float64(im * 0.001388888888888889), 0.041666666666666664), 0.5))), re);
	end
	return tmp
end
code[re_, im_] := If[LessEqual[N[Sin[re], $MachinePrecision], -0.01], N[(N[(N[(im * im), $MachinePrecision] * N[(im * N[(im * N[(N[(im * im), $MachinePrecision] * 0.001388888888888889 + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] * N[(re * N[(-0.16666666666666666 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(im * N[(im * N[(N[(im * im), $MachinePrecision] * N[(im * N[(im * 0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + re), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\sin re \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot \mathsf{fma}\left(im \cdot im, 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right) \cdot \left(re \cdot \left(-0.16666666666666666 \cdot \left(re \cdot re\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right)\right), re\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sin.f64 re) < -0.0100000000000000002

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{\sin re + {im}^{2} \cdot \left(\frac{1}{2} \cdot \sin re + {im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \sin re\right) + \frac{1}{24} \cdot \sin re\right)\right)} \]
    4. Simplified97.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right)} \]
    5. Taylor expanded in re around 0

      \[\leadsto \color{blue}{\left(re \cdot \left(1 + \frac{-1}{6} \cdot {re}^{2}\right)\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left(re \cdot \color{blue}{\left(\frac{-1}{6} \cdot {re}^{2} + 1\right)}\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      2. distribute-lft-inN/A

        \[\leadsto \color{blue}{\left(re \cdot \left(\frac{-1}{6} \cdot {re}^{2}\right) + re \cdot 1\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      3. *-rgt-identityN/A

        \[\leadsto \left(re \cdot \left(\frac{-1}{6} \cdot {re}^{2}\right) + \color{blue}{re}\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \frac{-1}{6} \cdot {re}^{2}, re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{{re}^{2} \cdot \frac{-1}{6}}, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      6. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{{re}^{2} \cdot \frac{-1}{6}}, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{6}, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      8. lower-*.f6428.3

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right) \]
    7. Simplified28.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right) \]
    8. Taylor expanded in re around inf

      \[\leadsto \color{blue}{\frac{-1}{6} \cdot \left({re}^{3} \cdot \left(1 + \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right)} \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\frac{-1}{6} \cdot {re}^{3}\right) \cdot \left(1 + \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\left(1 + \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right) \cdot \left(\frac{-1}{6} \cdot {re}^{3}\right)} \]
      3. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(1 + \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right) \cdot \left(\frac{-1}{6} \cdot {re}^{3}\right)} \]
    10. Simplified28.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot \mathsf{fma}\left(im \cdot im, 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right) \cdot \left(re \cdot \left(\left(re \cdot re\right) \cdot -0.16666666666666666\right)\right)} \]

    if -0.0100000000000000002 < (sin.f64 re)

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{\sin re + {im}^{2} \cdot \left(\frac{1}{2} \cdot \sin re + {im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \sin re\right) + \frac{1}{24} \cdot \sin re\right)\right)} \]
    4. Simplified90.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right)} \]
    5. Taylor expanded in re around 0

      \[\leadsto \color{blue}{\left(re \cdot \left(1 + \frac{-1}{6} \cdot {re}^{2}\right)\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left(re \cdot \color{blue}{\left(\frac{-1}{6} \cdot {re}^{2} + 1\right)}\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      2. distribute-lft-inN/A

        \[\leadsto \color{blue}{\left(re \cdot \left(\frac{-1}{6} \cdot {re}^{2}\right) + re \cdot 1\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      3. *-rgt-identityN/A

        \[\leadsto \left(re \cdot \left(\frac{-1}{6} \cdot {re}^{2}\right) + \color{blue}{re}\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \frac{-1}{6} \cdot {re}^{2}, re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{{re}^{2} \cdot \frac{-1}{6}}, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      6. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{{re}^{2} \cdot \frac{-1}{6}}, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{6}, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(\frac{1}{2}, im \cdot im, 1\right)\right) \]
      8. lower-*.f6469.7

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right) \]
    7. Simplified69.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), im \cdot \left(im \cdot \left(im \cdot im\right)\right), \mathsf{fma}\left(0.5, im \cdot im, 1\right)\right) \]
    8. Taylor expanded in re around 0

      \[\leadsto \color{blue}{re \cdot \left(1 + \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re \cdot \color{blue}{\left(\left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right) + 1\right)} \]
      2. distribute-lft-inN/A

        \[\leadsto \color{blue}{re \cdot \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right) + re \cdot 1} \]
      3. *-rgt-identityN/A

        \[\leadsto re \cdot \left(\frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right) + \color{blue}{re} \]
      4. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \frac{1}{2} \cdot {im}^{2} + {im}^{4} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right), re\right)} \]
    10. Simplified66.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(re, \left(im \cdot im\right) \cdot \mathsf{fma}\left(im, im \cdot \mathsf{fma}\left(im \cdot im, 0.001388888888888889, 0.041666666666666664\right), 0.5\right), re\right)} \]
    11. Taylor expanded in im around 0

      \[\leadsto \mathsf{fma}\left(re, \color{blue}{{im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)}, re\right) \]
    12. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{\left(im \cdot im\right)} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right), re\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{im \cdot \left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)}, re\right) \]
      3. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(re, \color{blue}{im \cdot \left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)}, re\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(re, im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)}, re\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right) + \frac{1}{2}\right)}\right), re\right) \]
      6. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \color{blue}{\mathsf{fma}\left({im}^{2}, \frac{1}{24} + \frac{1}{720} \cdot {im}^{2}, \frac{1}{2}\right)}\right), re\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(\color{blue}{im \cdot im}, \frac{1}{24} + \frac{1}{720} \cdot {im}^{2}, \frac{1}{2}\right)\right), re\right) \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(\color{blue}{im \cdot im}, \frac{1}{24} + \frac{1}{720} \cdot {im}^{2}, \frac{1}{2}\right)\right), re\right) \]
      9. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \color{blue}{\frac{1}{720} \cdot {im}^{2} + \frac{1}{24}}, \frac{1}{2}\right)\right), re\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \color{blue}{{im}^{2} \cdot \frac{1}{720}} + \frac{1}{24}, \frac{1}{2}\right)\right), re\right) \]
      11. unpow2N/A

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \color{blue}{\left(im \cdot im\right)} \cdot \frac{1}{720} + \frac{1}{24}, \frac{1}{2}\right)\right), re\right) \]
      12. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \color{blue}{im \cdot \left(im \cdot \frac{1}{720}\right)} + \frac{1}{24}, \frac{1}{2}\right)\right), re\right) \]
      13. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \color{blue}{\mathsf{fma}\left(im, im \cdot \frac{1}{720}, \frac{1}{24}\right)}, \frac{1}{2}\right)\right), re\right) \]
      14. lower-*.f6466.1

        \[\leadsto \mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, \color{blue}{im \cdot 0.001388888888888889}, 0.041666666666666664\right), 0.5\right)\right), re\right) \]
    13. Simplified66.1%

      \[\leadsto \mathsf{fma}\left(re, \color{blue}{im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right)\right)}, re\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification56.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sin re \leq -0.01:\\ \;\;\;\;\mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot \mathsf{fma}\left(im \cdot im, 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right) \cdot \left(re \cdot \left(-0.16666666666666666 \cdot \left(re \cdot re\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(re, im \cdot \left(im \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im, im \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right)\right), re\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 86.3% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 3.4 \cdot 10^{-5}:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)\\ \mathbf{elif}\;im \leq 2.5 \cdot 10^{+77}:\\ \;\;\;\;\cosh im \cdot \mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im \cdot im, 0.041666666666666664, 0.5\right), 1\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 3.4e-5)
   (* (sin re) (fma 0.5 (* im im) 1.0))
   (if (<= im 2.5e+77)
     (* (cosh im) (fma -0.16666666666666666 (* re (* re re)) re))
     (*
      (sin re)
      (fma (* im im) (fma (* im im) 0.041666666666666664 0.5) 1.0)))))
double code(double re, double im) {
	double tmp;
	if (im <= 3.4e-5) {
		tmp = sin(re) * fma(0.5, (im * im), 1.0);
	} else if (im <= 2.5e+77) {
		tmp = cosh(im) * fma(-0.16666666666666666, (re * (re * re)), re);
	} else {
		tmp = sin(re) * fma((im * im), fma((im * im), 0.041666666666666664, 0.5), 1.0);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 3.4e-5)
		tmp = Float64(sin(re) * fma(0.5, Float64(im * im), 1.0));
	elseif (im <= 2.5e+77)
		tmp = Float64(cosh(im) * fma(-0.16666666666666666, Float64(re * Float64(re * re)), re));
	else
		tmp = Float64(sin(re) * fma(Float64(im * im), fma(Float64(im * im), 0.041666666666666664, 0.5), 1.0));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 3.4e-5], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.5e+77], N[(N[Cosh[im], $MachinePrecision] * N[(-0.16666666666666666 * N[(re * N[(re * re), $MachinePrecision]), $MachinePrecision] + re), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * 0.041666666666666664 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.4 \cdot 10^{-5}:\\
\;\;\;\;\sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)\\

\mathbf{elif}\;im \leq 2.5 \cdot 10^{+77}:\\
\;\;\;\;\cosh im \cdot \mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\

\mathbf{else}:\\
\;\;\;\;\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im \cdot im, 0.041666666666666664, 0.5\right), 1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 3.4e-5

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{\sin re + \frac{1}{2} \cdot \left({im}^{2} \cdot \sin re\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \sin re + \color{blue}{\left(\frac{1}{2} \cdot {im}^{2}\right) \cdot \sin re} \]
      2. distribute-rgt1-inN/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot {im}^{2} + 1\right) \cdot \sin re} \]
      3. unpow2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{\left(im \cdot im\right)} + 1\right) \cdot \sin re \]
      4. associate-*r*N/A

        \[\leadsto \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \cdot \sin re \]
      5. *-commutativeN/A

        \[\leadsto \left(\color{blue}{im \cdot \left(\frac{1}{2} \cdot im\right)} + 1\right) \cdot \sin re \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)} \]
      8. lower-sin.f64N/A

        \[\leadsto \color{blue}{\sin re} \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right) \]
      9. *-commutativeN/A

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \]
      10. associate-*r*N/A

        \[\leadsto \sin re \cdot \left(\color{blue}{\frac{1}{2} \cdot \left(im \cdot im\right)} + 1\right) \]
      11. unpow2N/A

        \[\leadsto \sin re \cdot \left(\frac{1}{2} \cdot \color{blue}{{im}^{2}} + 1\right) \]
      12. lower-fma.f64N/A

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{2}, {im}^{2}, 1\right)} \]
      13. unpow2N/A

        \[\leadsto \sin re \cdot \mathsf{fma}\left(\frac{1}{2}, \color{blue}{im \cdot im}, 1\right) \]
      14. lower-*.f6484.7

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, \color{blue}{im \cdot im}, 1\right) \]
    5. Simplified84.7%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)} \]

    if 3.4e-5 < im < 2.50000000000000002e77

    1. Initial program 99.9%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{\sin re}\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \sin re\right)} \cdot \left(e^{0 - im} + e^{im}\right) \]
      3. lift--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{\color{blue}{0 - im}} + e^{im}\right) \]
      4. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
      5. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{e^{im}}\right) \]
      6. lift-+.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + e^{im}\right)} \]
      7. *-commutativeN/A

        \[\leadsto \color{blue}{\left(e^{0 - im} + e^{im}\right) \cdot \left(\frac{1}{2} \cdot \sin re\right)} \]
      8. lift-*.f64N/A

        \[\leadsto \left(e^{0 - im} + e^{im}\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot \sin re\right)} \]
      9. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
      10. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
    4. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0

      \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\left(re \cdot \left(1 + \frac{-1}{6} \cdot {re}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \left(re \cdot \color{blue}{\left(\frac{-1}{6} \cdot {re}^{2} + 1\right)}\right) \]
      2. distribute-lft-inN/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\left(re \cdot \left(\frac{-1}{6} \cdot {re}^{2}\right) + re \cdot 1\right)} \]
      3. *-rgt-identityN/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \left(re \cdot \left(\frac{-1}{6} \cdot {re}^{2}\right) + \color{blue}{re}\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\mathsf{fma}\left(re, \frac{-1}{6} \cdot {re}^{2}, re\right)} \]
      5. *-commutativeN/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{{re}^{2} \cdot \frac{-1}{6}}, re\right) \]
      6. lower-*.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{{re}^{2} \cdot \frac{-1}{6}}, re\right) \]
      7. unpow2N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{6}, re\right) \]
      8. lower-*.f6471.3

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \]
    7. Simplified71.3%

      \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)} \]
    8. Step-by-step derivation
      1. lift-cosh.f64N/A

        \[\leadsto \left(1 \cdot \color{blue}{\cosh im}\right) \cdot \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right) + re\right) \]
      2. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right)} \cdot \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right) + re\right) \]
      3. lift-*.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \left(re \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{6}\right) + re\right) \]
      4. lift-*.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \left(re \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right)} + re\right) \]
      5. lift-fma.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot \frac{-1}{6}, re\right)} \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot \frac{-1}{6}, re\right) \cdot \left(1 \cdot \cosh im\right)} \]
      7. lower-*.f6471.3

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right) \cdot \left(1 \cdot \cosh im\right)} \]
      8. lift-fma.f64N/A

        \[\leadsto \color{blue}{\left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right) + re\right)} \cdot \left(1 \cdot \cosh im\right) \]
      9. lift-*.f64N/A

        \[\leadsto \left(re \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right)} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      10. associate-*r*N/A

        \[\leadsto \left(\color{blue}{\left(re \cdot \left(re \cdot re\right)\right) \cdot \frac{-1}{6}} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      11. lift-*.f64N/A

        \[\leadsto \left(\left(re \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \frac{-1}{6} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      12. cube-unmultN/A

        \[\leadsto \left(\color{blue}{{re}^{3}} \cdot \frac{-1}{6} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(\color{blue}{\frac{-1}{6} \cdot {re}^{3}} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      14. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{6}, {re}^{3}, re\right)} \cdot \left(1 \cdot \cosh im\right) \]
      15. cube-unmultN/A

        \[\leadsto \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{re \cdot \left(re \cdot re\right)}, re\right) \cdot \left(1 \cdot \cosh im\right) \]
      16. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{-1}{6}, re \cdot \color{blue}{\left(re \cdot re\right)}, re\right) \cdot \left(1 \cdot \cosh im\right) \]
      17. lower-*.f6471.3

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, \color{blue}{re \cdot \left(re \cdot re\right)}, re\right) \cdot \left(1 \cdot \cosh im\right) \]
      18. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{-1}{6}, re \cdot \left(re \cdot re\right), re\right) \cdot \color{blue}{\left(1 \cdot \cosh im\right)} \]
      19. *-lft-identity71.3

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right) \cdot \color{blue}{\cosh im} \]
    9. Applied egg-rr71.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right) \cdot \cosh im} \]

    if 2.50000000000000002e77 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{\sin re + {im}^{2} \cdot \left(\frac{1}{24} \cdot \left({im}^{2} \cdot \sin re\right) + \frac{1}{2} \cdot \sin re\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{{im}^{2} \cdot \left(\frac{1}{24} \cdot \left({im}^{2} \cdot \sin re\right) + \frac{1}{2} \cdot \sin re\right) + \sin re} \]
      2. distribute-lft-inN/A

        \[\leadsto \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{24} \cdot \left({im}^{2} \cdot \sin re\right)\right) + {im}^{2} \cdot \left(\frac{1}{2} \cdot \sin re\right)\right)} + \sin re \]
      3. associate-+l+N/A

        \[\leadsto \color{blue}{{im}^{2} \cdot \left(\frac{1}{24} \cdot \left({im}^{2} \cdot \sin re\right)\right) + \left({im}^{2} \cdot \left(\frac{1}{2} \cdot \sin re\right) + \sin re\right)} \]
      4. associate-*r*N/A

        \[\leadsto {im}^{2} \cdot \color{blue}{\left(\left(\frac{1}{24} \cdot {im}^{2}\right) \cdot \sin re\right)} + \left({im}^{2} \cdot \left(\frac{1}{2} \cdot \sin re\right) + \sin re\right) \]
      5. associate-*r*N/A

        \[\leadsto \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \sin re} + \left({im}^{2} \cdot \left(\frac{1}{2} \cdot \sin re\right) + \sin re\right) \]
      6. associate-*r*N/A

        \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \sin re + \left(\color{blue}{\left({im}^{2} \cdot \frac{1}{2}\right) \cdot \sin re} + \sin re\right) \]
      7. unpow2N/A

        \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \sin re + \left(\left(\color{blue}{\left(im \cdot im\right)} \cdot \frac{1}{2}\right) \cdot \sin re + \sin re\right) \]
      8. associate-*r*N/A

        \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \sin re + \left(\color{blue}{\left(im \cdot \left(im \cdot \frac{1}{2}\right)\right)} \cdot \sin re + \sin re\right) \]
      9. *-commutativeN/A

        \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \sin re + \left(\left(im \cdot \color{blue}{\left(\frac{1}{2} \cdot im\right)}\right) \cdot \sin re + \sin re\right) \]
      10. distribute-lft1-inN/A

        \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \sin re + \color{blue}{\left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right) \cdot \sin re} \]
      11. distribute-rgt-outN/A

        \[\leadsto \color{blue}{\sin re \cdot \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)\right)} \]
      12. lower-*.f64N/A

        \[\leadsto \color{blue}{\sin re \cdot \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)\right)} \]
      13. lower-sin.f64N/A

        \[\leadsto \color{blue}{\sin re} \cdot \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)\right) \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im \cdot im, 0.041666666666666664, 0.5\right), 1\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.4 \cdot 10^{-5}:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)\\ \mathbf{elif}\;im \leq 2.5 \cdot 10^{+77}:\\ \;\;\;\;\cosh im \cdot \mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(im \cdot im, \mathsf{fma}\left(im \cdot im, 0.041666666666666664, 0.5\right), 1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 84.8% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)\\ \mathbf{if}\;im \leq 3.4 \cdot 10^{-5}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\cosh im \cdot \mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (sin re) (fma 0.5 (* im im) 1.0))))
   (if (<= im 3.4e-5)
     t_0
     (if (<= im 1.35e+154)
       (* (cosh im) (fma -0.16666666666666666 (* re (* re re)) re))
       t_0))))
double code(double re, double im) {
	double t_0 = sin(re) * fma(0.5, (im * im), 1.0);
	double tmp;
	if (im <= 3.4e-5) {
		tmp = t_0;
	} else if (im <= 1.35e+154) {
		tmp = cosh(im) * fma(-0.16666666666666666, (re * (re * re)), re);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(sin(re) * fma(0.5, Float64(im * im), 1.0))
	tmp = 0.0
	if (im <= 3.4e-5)
		tmp = t_0;
	elseif (im <= 1.35e+154)
		tmp = Float64(cosh(im) * fma(-0.16666666666666666, Float64(re * Float64(re * re)), re));
	else
		tmp = t_0;
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 3.4e-5], t$95$0, If[LessEqual[im, 1.35e+154], N[(N[Cosh[im], $MachinePrecision] * N[(-0.16666666666666666 * N[(re * N[(re * re), $MachinePrecision]), $MachinePrecision] + re), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)\\
\mathbf{if}\;im \leq 3.4 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\cosh im \cdot \mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 3.4e-5 or 1.35000000000000003e154 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0

      \[\leadsto \color{blue}{\sin re + \frac{1}{2} \cdot \left({im}^{2} \cdot \sin re\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \sin re + \color{blue}{\left(\frac{1}{2} \cdot {im}^{2}\right) \cdot \sin re} \]
      2. distribute-rgt1-inN/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot {im}^{2} + 1\right) \cdot \sin re} \]
      3. unpow2N/A

        \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{\left(im \cdot im\right)} + 1\right) \cdot \sin re \]
      4. associate-*r*N/A

        \[\leadsto \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \cdot \sin re \]
      5. *-commutativeN/A

        \[\leadsto \left(\color{blue}{im \cdot \left(\frac{1}{2} \cdot im\right)} + 1\right) \cdot \sin re \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)} \]
      8. lower-sin.f64N/A

        \[\leadsto \color{blue}{\sin re} \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right) \]
      9. *-commutativeN/A

        \[\leadsto \sin re \cdot \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \]
      10. associate-*r*N/A

        \[\leadsto \sin re \cdot \left(\color{blue}{\frac{1}{2} \cdot \left(im \cdot im\right)} + 1\right) \]
      11. unpow2N/A

        \[\leadsto \sin re \cdot \left(\frac{1}{2} \cdot \color{blue}{{im}^{2}} + 1\right) \]
      12. lower-fma.f64N/A

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{2}, {im}^{2}, 1\right)} \]
      13. unpow2N/A

        \[\leadsto \sin re \cdot \mathsf{fma}\left(\frac{1}{2}, \color{blue}{im \cdot im}, 1\right) \]
      14. lower-*.f6486.3

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, \color{blue}{im \cdot im}, 1\right) \]
    5. Simplified86.3%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)} \]

    if 3.4e-5 < im < 1.35000000000000003e154

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-sin.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{\sin re}\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \sin re\right)} \cdot \left(e^{0 - im} + e^{im}\right) \]
      3. lift--.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{\color{blue}{0 - im}} + e^{im}\right) \]
      4. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\color{blue}{e^{0 - im}} + e^{im}\right) \]
      5. lift-exp.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \left(e^{0 - im} + \color{blue}{e^{im}}\right) \]
      6. lift-+.f64N/A

        \[\leadsto \left(\frac{1}{2} \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + e^{im}\right)} \]
      7. *-commutativeN/A

        \[\leadsto \color{blue}{\left(e^{0 - im} + e^{im}\right) \cdot \left(\frac{1}{2} \cdot \sin re\right)} \]
      8. lift-*.f64N/A

        \[\leadsto \left(e^{0 - im} + e^{im}\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot \sin re\right)} \]
      9. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
      10. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(e^{0 - im} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \sin re} \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \sin re} \]
    5. Taylor expanded in re around 0

      \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\left(re \cdot \left(1 + \frac{-1}{6} \cdot {re}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \left(re \cdot \color{blue}{\left(\frac{-1}{6} \cdot {re}^{2} + 1\right)}\right) \]
      2. distribute-lft-inN/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\left(re \cdot \left(\frac{-1}{6} \cdot {re}^{2}\right) + re \cdot 1\right)} \]
      3. *-rgt-identityN/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \left(re \cdot \left(\frac{-1}{6} \cdot {re}^{2}\right) + \color{blue}{re}\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\mathsf{fma}\left(re, \frac{-1}{6} \cdot {re}^{2}, re\right)} \]
      5. *-commutativeN/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{{re}^{2} \cdot \frac{-1}{6}}, re\right) \]
      6. lower-*.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{{re}^{2} \cdot \frac{-1}{6}}, re\right) \]
      7. unpow2N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{6}, re\right) \]
      8. lower-*.f6476.3

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \mathsf{fma}\left(re, \color{blue}{\left(re \cdot re\right)} \cdot -0.16666666666666666, re\right) \]
    7. Simplified76.3%

      \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right)} \]
    8. Step-by-step derivation
      1. lift-cosh.f64N/A

        \[\leadsto \left(1 \cdot \color{blue}{\cosh im}\right) \cdot \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right) + re\right) \]
      2. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right)} \cdot \left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right) + re\right) \]
      3. lift-*.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \left(re \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot \frac{-1}{6}\right) + re\right) \]
      4. lift-*.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \left(re \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right)} + re\right) \]
      5. lift-fma.f64N/A

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot \frac{-1}{6}, re\right)} \]
      6. *-commutativeN/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot \frac{-1}{6}, re\right) \cdot \left(1 \cdot \cosh im\right)} \]
      7. lower-*.f6476.3

        \[\leadsto \color{blue}{\mathsf{fma}\left(re, \left(re \cdot re\right) \cdot -0.16666666666666666, re\right) \cdot \left(1 \cdot \cosh im\right)} \]
      8. lift-fma.f64N/A

        \[\leadsto \color{blue}{\left(re \cdot \left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right) + re\right)} \cdot \left(1 \cdot \cosh im\right) \]
      9. lift-*.f64N/A

        \[\leadsto \left(re \cdot \color{blue}{\left(\left(re \cdot re\right) \cdot \frac{-1}{6}\right)} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      10. associate-*r*N/A

        \[\leadsto \left(\color{blue}{\left(re \cdot \left(re \cdot re\right)\right) \cdot \frac{-1}{6}} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      11. lift-*.f64N/A

        \[\leadsto \left(\left(re \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot \frac{-1}{6} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      12. cube-unmultN/A

        \[\leadsto \left(\color{blue}{{re}^{3}} \cdot \frac{-1}{6} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(\color{blue}{\frac{-1}{6} \cdot {re}^{3}} + re\right) \cdot \left(1 \cdot \cosh im\right) \]
      14. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{6}, {re}^{3}, re\right)} \cdot \left(1 \cdot \cosh im\right) \]
      15. cube-unmultN/A

        \[\leadsto \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{re \cdot \left(re \cdot re\right)}, re\right) \cdot \left(1 \cdot \cosh im\right) \]
      16. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{-1}{6}, re \cdot \color{blue}{\left(re \cdot re\right)}, re\right) \cdot \left(1 \cdot \cosh im\right) \]
      17. lower-*.f6476.3

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, \color{blue}{re \cdot \left(re \cdot re\right)}, re\right) \cdot \left(1 \cdot \cosh im\right) \]
      18. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{-1}{6}, re \cdot \left(re \cdot re\right), re\right) \cdot \color{blue}{\left(1 \cdot \cosh im\right)} \]
      19. *-lft-identity76.3

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right) \cdot \color{blue}{\cosh im} \]
    9. Applied egg-rr76.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right) \cdot \cosh im} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification84.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.4 \cdot 10^{-5}:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\cosh im \cdot \mathsf{fma}\left(-0.16666666666666666, re \cdot \left(re \cdot re\right), re\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 24.3% accurate, 19.8× speedup?

\[\begin{array}{l} \\ \left(im \cdot im\right) \cdot \left(re \cdot 0.5\right) \end{array} \]
(FPCore (re im) :precision binary64 (* (* im im) (* re 0.5)))
double code(double re, double im) {
	return (im * im) * (re * 0.5);
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (im * im) * (re * 0.5d0)
end function
public static double code(double re, double im) {
	return (im * im) * (re * 0.5);
}
def code(re, im):
	return (im * im) * (re * 0.5)
function code(re, im)
	return Float64(Float64(im * im) * Float64(re * 0.5))
end
function tmp = code(re, im)
	tmp = (im * im) * (re * 0.5);
end
code[re_, im_] := N[(N[(im * im), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(im \cdot im\right) \cdot \left(re \cdot 0.5\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in im around 0

    \[\leadsto \color{blue}{\sin re + \frac{1}{2} \cdot \left({im}^{2} \cdot \sin re\right)} \]
  4. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \sin re + \color{blue}{\left(\frac{1}{2} \cdot {im}^{2}\right) \cdot \sin re} \]
    2. distribute-rgt1-inN/A

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot {im}^{2} + 1\right) \cdot \sin re} \]
    3. unpow2N/A

      \[\leadsto \left(\frac{1}{2} \cdot \color{blue}{\left(im \cdot im\right)} + 1\right) \cdot \sin re \]
    4. associate-*r*N/A

      \[\leadsto \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \cdot \sin re \]
    5. *-commutativeN/A

      \[\leadsto \left(\color{blue}{im \cdot \left(\frac{1}{2} \cdot im\right)} + 1\right) \cdot \sin re \]
    6. *-commutativeN/A

      \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)} \]
    7. lower-*.f64N/A

      \[\leadsto \color{blue}{\sin re \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right)} \]
    8. lower-sin.f64N/A

      \[\leadsto \color{blue}{\sin re} \cdot \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right) \]
    9. *-commutativeN/A

      \[\leadsto \sin re \cdot \left(\color{blue}{\left(\frac{1}{2} \cdot im\right) \cdot im} + 1\right) \]
    10. associate-*r*N/A

      \[\leadsto \sin re \cdot \left(\color{blue}{\frac{1}{2} \cdot \left(im \cdot im\right)} + 1\right) \]
    11. unpow2N/A

      \[\leadsto \sin re \cdot \left(\frac{1}{2} \cdot \color{blue}{{im}^{2}} + 1\right) \]
    12. lower-fma.f64N/A

      \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{2}, {im}^{2}, 1\right)} \]
    13. unpow2N/A

      \[\leadsto \sin re \cdot \mathsf{fma}\left(\frac{1}{2}, \color{blue}{im \cdot im}, 1\right) \]
    14. lower-*.f6474.5

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, \color{blue}{im \cdot im}, 1\right) \]
  5. Simplified74.5%

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, im \cdot im, 1\right)} \]
  6. Taylor expanded in re around 0

    \[\leadsto \color{blue}{re \cdot \left(1 + \frac{1}{2} \cdot {im}^{2}\right)} \]
  7. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto re \cdot \color{blue}{\left(\frac{1}{2} \cdot {im}^{2} + 1\right)} \]
    2. distribute-lft-inN/A

      \[\leadsto \color{blue}{re \cdot \left(\frac{1}{2} \cdot {im}^{2}\right) + re \cdot 1} \]
    3. *-rgt-identityN/A

      \[\leadsto re \cdot \left(\frac{1}{2} \cdot {im}^{2}\right) + \color{blue}{re} \]
    4. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(re, \frac{1}{2} \cdot {im}^{2}, re\right)} \]
    5. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(re, \color{blue}{\frac{1}{2} \cdot {im}^{2}}, re\right) \]
    6. unpow2N/A

      \[\leadsto \mathsf{fma}\left(re, \frac{1}{2} \cdot \color{blue}{\left(im \cdot im\right)}, re\right) \]
    7. lower-*.f6440.4

      \[\leadsto \mathsf{fma}\left(re, 0.5 \cdot \color{blue}{\left(im \cdot im\right)}, re\right) \]
  8. Simplified40.4%

    \[\leadsto \color{blue}{\mathsf{fma}\left(re, 0.5 \cdot \left(im \cdot im\right), re\right)} \]
  9. Taylor expanded in im around inf

    \[\leadsto \color{blue}{\frac{1}{2} \cdot \left({im}^{2} \cdot re\right)} \]
  10. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot {im}^{2}\right) \cdot re} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\left({im}^{2} \cdot \frac{1}{2}\right)} \cdot re \]
    3. associate-*r*N/A

      \[\leadsto \color{blue}{{im}^{2} \cdot \left(\frac{1}{2} \cdot re\right)} \]
    4. lower-*.f64N/A

      \[\leadsto \color{blue}{{im}^{2} \cdot \left(\frac{1}{2} \cdot re\right)} \]
    5. unpow2N/A

      \[\leadsto \color{blue}{\left(im \cdot im\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
    6. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(im \cdot im\right)} \cdot \left(\frac{1}{2} \cdot re\right) \]
    7. lower-*.f6417.4

      \[\leadsto \left(im \cdot im\right) \cdot \color{blue}{\left(0.5 \cdot re\right)} \]
  11. Simplified17.4%

    \[\leadsto \color{blue}{\left(im \cdot im\right) \cdot \left(0.5 \cdot re\right)} \]
  12. Final simplification17.4%

    \[\leadsto \left(im \cdot im\right) \cdot \left(re \cdot 0.5\right) \]
  13. Add Preprocessing

Reproduce

?
herbie shell --seed 2024207 
(FPCore (re im)
  :name "math.sin on complex, real part"
  :precision binary64
  (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))