math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 5.7s
Alternatives: 14
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.8× speedup?

\[\begin{array}{l} im = |im|\\ \\ \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right) \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im)
 :precision binary64
 (* (sin re) (fma 0.5 (exp im) (/ 0.5 (exp im)))))
im = abs(im);
double code(double re, double im) {
	return sin(re) * fma(0.5, exp(im), (0.5 / exp(im)));
}
im = abs(im)
function code(re, im)
	return Float64(sin(re) * fma(0.5, exp(im), Float64(0.5 / exp(im))))
end
NOTE: im should be positive before calling this function
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Exp[im], $MachinePrecision] + N[(0.5 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im = |im|\\
\\
\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\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. Step-by-step derivation
    1. distribute-rgt-in100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
    2. +-commutative100.0%

      \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
    3. associate-*r*100.0%

      \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
    4. associate-*r*100.0%

      \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
    5. distribute-rgt-out100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
    6. cancel-sign-sub100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
    7. distribute-lft-neg-in100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
    8. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
    9. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
    10. sub-neg100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
    11. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    12. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    13. remove-double-neg100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
    14. distribute-rgt-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
    15. distribute-lft-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Final simplification100.0%

    \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right) \]

Alternative 2: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} im = |im|\\ \\ \left(\sin re \cdot 0.5\right) \cdot \left(e^{im} + e^{-im}\right) \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im)
 :precision binary64
 (* (* (sin re) 0.5) (+ (exp im) (exp (- im)))))
im = abs(im);
double code(double re, double im) {
	return (sin(re) * 0.5) * (exp(im) + exp(-im));
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (sin(re) * 0.5d0) * (exp(im) + exp(-im))
end function
im = Math.abs(im);
public static double code(double re, double im) {
	return (Math.sin(re) * 0.5) * (Math.exp(im) + Math.exp(-im));
}
im = abs(im)
def code(re, im):
	return (math.sin(re) * 0.5) * (math.exp(im) + math.exp(-im))
im = abs(im)
function code(re, im)
	return Float64(Float64(sin(re) * 0.5) * Float64(exp(im) + exp(Float64(-im))))
end
im = abs(im)
function tmp = code(re, im)
	tmp = (sin(re) * 0.5) * (exp(im) + exp(-im));
end
NOTE: im should be positive before calling this function
code[re_, im_] := N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im = |im|\\
\\
\left(\sin re \cdot 0.5\right) \cdot \left(e^{im} + e^{-im}\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. Step-by-step derivation
    1. distribute-lft-in100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot e^{0 - im} + \left(0.5 \cdot \sin re\right) \cdot e^{im}} \]
    2. *-commutative100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
    3. cancel-sign-sub100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
    4. distribute-lft-neg-out100.0%

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

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
    6. distribute-rgt-neg-out100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
    7. neg-mul-1100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
    8. associate-*r*100.0%

      \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
    9. distribute-rgt-out--100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
    10. sub-neg100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
    11. neg-sub0100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
    12. *-commutative100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
    13. neg-mul-1100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
    14. remove-double-neg100.0%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \color{blue}{e^{im}}\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)} \]
  4. Final simplification100.0%

    \[\leadsto \left(\sin re \cdot 0.5\right) \cdot \left(e^{im} + e^{-im}\right) \]

Alternative 3: 93.1% accurate, 1.5× speedup?

\[\begin{array}{l} im = |im|\\ \\ \begin{array}{l} \mathbf{if}\;im \leq 6.2:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\ \end{array} \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im)
 :precision binary64
 (if (<= im 6.2)
   (* (* (sin re) 0.5) (fma im im 2.0))
   (if (<= im 2.7e+154)
     (* re (+ 0.5 (* 0.5 (exp im))))
     (* (sin re) (+ 1.0 (* im (+ 0.5 (* im 0.25))))))))
im = abs(im);
double code(double re, double im) {
	double tmp;
	if (im <= 6.2) {
		tmp = (sin(re) * 0.5) * fma(im, im, 2.0);
	} else if (im <= 2.7e+154) {
		tmp = re * (0.5 + (0.5 * exp(im)));
	} else {
		tmp = sin(re) * (1.0 + (im * (0.5 + (im * 0.25))));
	}
	return tmp;
}
im = abs(im)
function code(re, im)
	tmp = 0.0
	if (im <= 6.2)
		tmp = Float64(Float64(sin(re) * 0.5) * fma(im, im, 2.0));
	elseif (im <= 2.7e+154)
		tmp = Float64(re * Float64(0.5 + Float64(0.5 * exp(im))));
	else
		tmp = Float64(sin(re) * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.25)))));
	end
	return tmp
end
NOTE: im should be positive before calling this function
code[re_, im_] := If[LessEqual[im, 6.2], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.7e+154], N[(re * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
im = |im|\\
\\
\begin{array}{l}
\mathbf{if}\;im \leq 6.2:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\

\mathbf{elif}\;im \leq 2.7 \cdot 10^{+154}:\\
\;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\

\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 6.20000000000000018

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-lft-in100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot e^{0 - im} + \left(0.5 \cdot \sin re\right) \cdot e^{im}} \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
      3. cancel-sign-sub100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
      4. distribute-lft-neg-out100.0%

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

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
      6. distribute-rgt-neg-out100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
      7. neg-mul-1100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
      8. associate-*r*100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
      9. distribute-rgt-out--100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
      11. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
      12. *-commutative100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
      13. neg-mul-1100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
      14. remove-double-neg100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \color{blue}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)} \]
    4. Taylor expanded in im around 0 82.5%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    5. Step-by-step derivation
      1. +-commutative82.5%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left({im}^{2} + 2\right)} \]
      2. unpow282.5%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-def82.5%

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

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

    if 6.20000000000000018 < im < 2.70000000000000006e154

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
    5. Taylor expanded in re around 0 74.2%

      \[\leadsto \color{blue}{re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)} \]

    if 2.70000000000000006e154 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
    5. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)} \]
    6. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot e^{im}\right) \cdot \sin re} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot e^{im}\right) \cdot \sin re} \]
    8. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{\left(1 + \left(0.25 \cdot {im}^{2} + 0.5 \cdot im\right)\right)} \cdot \sin re \]
    9. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \left(1 + \color{blue}{\left(0.5 \cdot im + 0.25 \cdot {im}^{2}\right)}\right) \cdot \sin re \]
      2. *-commutative100.0%

        \[\leadsto \left(1 + \left(\color{blue}{im \cdot 0.5} + 0.25 \cdot {im}^{2}\right)\right) \cdot \sin re \]
      3. *-commutative100.0%

        \[\leadsto \left(1 + \left(im \cdot 0.5 + \color{blue}{{im}^{2} \cdot 0.25}\right)\right) \cdot \sin re \]
      4. unpow2100.0%

        \[\leadsto \left(1 + \left(im \cdot 0.5 + \color{blue}{\left(im \cdot im\right)} \cdot 0.25\right)\right) \cdot \sin re \]
      5. associate-*l*100.0%

        \[\leadsto \left(1 + \left(im \cdot 0.5 + \color{blue}{im \cdot \left(im \cdot 0.25\right)}\right)\right) \cdot \sin re \]
      6. distribute-lft-out100.0%

        \[\leadsto \left(1 + \color{blue}{im \cdot \left(0.5 + im \cdot 0.25\right)}\right) \cdot \sin re \]
    10. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 6.2:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\ \end{array} \]

Alternative 4: 98.8% accurate, 1.5× speedup?

\[\begin{array}{l} im = |im|\\ \\ \sin re \cdot \left(0.5 + 0.5 \cdot e^{im}\right) \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im) :precision binary64 (* (sin re) (+ 0.5 (* 0.5 (exp im)))))
im = abs(im);
double code(double re, double im) {
	return sin(re) * (0.5 + (0.5 * exp(im)));
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = sin(re) * (0.5d0 + (0.5d0 * exp(im)))
end function
im = Math.abs(im);
public static double code(double re, double im) {
	return Math.sin(re) * (0.5 + (0.5 * Math.exp(im)));
}
im = abs(im)
def code(re, im):
	return math.sin(re) * (0.5 + (0.5 * math.exp(im)))
im = abs(im)
function code(re, im)
	return Float64(sin(re) * Float64(0.5 + Float64(0.5 * exp(im))))
end
im = abs(im)
function tmp = code(re, im)
	tmp = sin(re) * (0.5 + (0.5 * exp(im)));
end
NOTE: im should be positive before calling this function
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im = |im|\\
\\
\sin re \cdot \left(0.5 + 0.5 \cdot e^{im}\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. Step-by-step derivation
    1. distribute-rgt-in100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
    2. +-commutative100.0%

      \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
    3. associate-*r*100.0%

      \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
    4. associate-*r*100.0%

      \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
    5. distribute-rgt-out100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
    6. cancel-sign-sub100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
    7. distribute-lft-neg-in100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
    8. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
    9. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
    10. sub-neg100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
    11. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    12. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    13. remove-double-neg100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
    14. distribute-rgt-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
    15. distribute-lft-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Taylor expanded in im around 0 74.5%

    \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
  5. Taylor expanded in re around inf 74.5%

    \[\leadsto \color{blue}{\sin re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)} \]
  6. Step-by-step derivation
    1. *-commutative74.5%

      \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot e^{im}\right) \cdot \sin re} \]
  7. Simplified74.5%

    \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot e^{im}\right) \cdot \sin re} \]
  8. Final simplification74.5%

    \[\leadsto \sin re \cdot \left(0.5 + 0.5 \cdot e^{im}\right) \]

Alternative 5: 92.8% accurate, 2.7× speedup?

\[\begin{array}{l} im = |im|\\ \\ \begin{array}{l} \mathbf{if}\;im \leq 2.7:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\ \end{array} \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im)
 :precision binary64
 (if (<= im 2.7)
   (sin re)
   (if (<= im 2.7e+154)
     (* re (+ 0.5 (* 0.5 (exp im))))
     (* (sin re) (+ 1.0 (* im (+ 0.5 (* im 0.25))))))))
im = abs(im);
double code(double re, double im) {
	double tmp;
	if (im <= 2.7) {
		tmp = sin(re);
	} else if (im <= 2.7e+154) {
		tmp = re * (0.5 + (0.5 * exp(im)));
	} else {
		tmp = sin(re) * (1.0 + (im * (0.5 + (im * 0.25))));
	}
	return tmp;
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 2.7d0) then
        tmp = sin(re)
    else if (im <= 2.7d+154) then
        tmp = re * (0.5d0 + (0.5d0 * exp(im)))
    else
        tmp = sin(re) * (1.0d0 + (im * (0.5d0 + (im * 0.25d0))))
    end if
    code = tmp
end function
im = Math.abs(im);
public static double code(double re, double im) {
	double tmp;
	if (im <= 2.7) {
		tmp = Math.sin(re);
	} else if (im <= 2.7e+154) {
		tmp = re * (0.5 + (0.5 * Math.exp(im)));
	} else {
		tmp = Math.sin(re) * (1.0 + (im * (0.5 + (im * 0.25))));
	}
	return tmp;
}
im = abs(im)
def code(re, im):
	tmp = 0
	if im <= 2.7:
		tmp = math.sin(re)
	elif im <= 2.7e+154:
		tmp = re * (0.5 + (0.5 * math.exp(im)))
	else:
		tmp = math.sin(re) * (1.0 + (im * (0.5 + (im * 0.25))))
	return tmp
im = abs(im)
function code(re, im)
	tmp = 0.0
	if (im <= 2.7)
		tmp = sin(re);
	elseif (im <= 2.7e+154)
		tmp = Float64(re * Float64(0.5 + Float64(0.5 * exp(im))));
	else
		tmp = Float64(sin(re) * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.25)))));
	end
	return tmp
end
im = abs(im)
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 2.7)
		tmp = sin(re);
	elseif (im <= 2.7e+154)
		tmp = re * (0.5 + (0.5 * exp(im)));
	else
		tmp = sin(re) * (1.0 + (im * (0.5 + (im * 0.25))));
	end
	tmp_2 = tmp;
end
NOTE: im should be positive before calling this function
code[re_, im_] := If[LessEqual[im, 2.7], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.7e+154], N[(re * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
im = |im|\\
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.7:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 2.7 \cdot 10^{+154}:\\
\;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\

\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 2.7000000000000002

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 65.7%

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

    if 2.7000000000000002 < im < 2.70000000000000006e154

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
    5. Taylor expanded in re around 0 74.2%

      \[\leadsto \color{blue}{re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)} \]

    if 2.70000000000000006e154 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
    5. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)} \]
    6. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot e^{im}\right) \cdot \sin re} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot e^{im}\right) \cdot \sin re} \]
    8. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{\left(1 + \left(0.25 \cdot {im}^{2} + 0.5 \cdot im\right)\right)} \cdot \sin re \]
    9. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \left(1 + \color{blue}{\left(0.5 \cdot im + 0.25 \cdot {im}^{2}\right)}\right) \cdot \sin re \]
      2. *-commutative100.0%

        \[\leadsto \left(1 + \left(\color{blue}{im \cdot 0.5} + 0.25 \cdot {im}^{2}\right)\right) \cdot \sin re \]
      3. *-commutative100.0%

        \[\leadsto \left(1 + \left(im \cdot 0.5 + \color{blue}{{im}^{2} \cdot 0.25}\right)\right) \cdot \sin re \]
      4. unpow2100.0%

        \[\leadsto \left(1 + \left(im \cdot 0.5 + \color{blue}{\left(im \cdot im\right)} \cdot 0.25\right)\right) \cdot \sin re \]
      5. associate-*l*100.0%

        \[\leadsto \left(1 + \left(im \cdot 0.5 + \color{blue}{im \cdot \left(im \cdot 0.25\right)}\right)\right) \cdot \sin re \]
      6. distribute-lft-out100.0%

        \[\leadsto \left(1 + \color{blue}{im \cdot \left(0.5 + im \cdot 0.25\right)}\right) \cdot \sin re \]
    10. Simplified100.0%

      \[\leadsto \color{blue}{\left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)} \cdot \sin re \]
  3. Recombined 3 regimes into one program.
  4. Final simplification71.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.7:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\ \end{array} \]

Alternative 6: 72.0% accurate, 2.8× speedup?

\[\begin{array}{l} im = |im|\\ \\ \begin{array}{l} \mathbf{if}\;im \leq 400:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot \mathsf{fma}\left(im, im, 2\right)\right)\\ \end{array} \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im)
 :precision binary64
 (if (<= im 400.0) (sin re) (* re (* 0.5 (fma im im 2.0)))))
im = abs(im);
double code(double re, double im) {
	double tmp;
	if (im <= 400.0) {
		tmp = sin(re);
	} else {
		tmp = re * (0.5 * fma(im, im, 2.0));
	}
	return tmp;
}
im = abs(im)
function code(re, im)
	tmp = 0.0
	if (im <= 400.0)
		tmp = sin(re);
	else
		tmp = Float64(re * Float64(0.5 * fma(im, im, 2.0)));
	end
	return tmp
end
NOTE: im should be positive before calling this function
code[re_, im_] := If[LessEqual[im, 400.0], N[Sin[re], $MachinePrecision], N[(re * N[(0.5 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
im = |im|\\
\\
\begin{array}{l}
\mathbf{if}\;im \leq 400:\\
\;\;\;\;\sin re\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 400

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 65.7%

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

    if 400 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-lft-in100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot e^{0 - im} + \left(0.5 \cdot \sin re\right) \cdot e^{im}} \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
      3. cancel-sign-sub100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
      4. distribute-lft-neg-out100.0%

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

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
      6. distribute-rgt-neg-out100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
      7. neg-mul-1100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
      8. associate-*r*100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
      9. distribute-rgt-out--100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
      11. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
      12. *-commutative100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
      13. neg-mul-1100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
      14. remove-double-neg100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \color{blue}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)} \]
    4. Taylor expanded in im around 0 56.9%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    5. Step-by-step derivation
      1. +-commutative56.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left({im}^{2} + 2\right)} \]
      2. unpow256.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-def56.9%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(2 + {im}^{2}\right)\right)} \]
    8. Step-by-step derivation
      1. associate-*r*47.2%

        \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(2 + {im}^{2}\right)} \]
      2. *-commutative47.2%

        \[\leadsto \color{blue}{\left(re \cdot 0.5\right)} \cdot \left(2 + {im}^{2}\right) \]
      3. associate-*l*47.2%

        \[\leadsto \color{blue}{re \cdot \left(0.5 \cdot \left(2 + {im}^{2}\right)\right)} \]
      4. *-commutative47.2%

        \[\leadsto re \cdot \color{blue}{\left(\left(2 + {im}^{2}\right) \cdot 0.5\right)} \]
      5. +-commutative47.2%

        \[\leadsto re \cdot \left(\color{blue}{\left({im}^{2} + 2\right)} \cdot 0.5\right) \]
      6. unpow247.2%

        \[\leadsto re \cdot \left(\left(\color{blue}{im \cdot im} + 2\right) \cdot 0.5\right) \]
      7. fma-def47.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 400:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot \mathsf{fma}\left(im, im, 2\right)\right)\\ \end{array} \]

Alternative 7: 86.7% accurate, 2.8× speedup?

\[\begin{array}{l} im = |im|\\ \\ \begin{array}{l} \mathbf{if}\;im \leq 4:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ \end{array} \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im)
 :precision binary64
 (if (<= im 4.0) (sin re) (* re (+ 0.5 (* 0.5 (exp im))))))
im = abs(im);
double code(double re, double im) {
	double tmp;
	if (im <= 4.0) {
		tmp = sin(re);
	} else {
		tmp = re * (0.5 + (0.5 * exp(im)));
	}
	return tmp;
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 4.0d0) then
        tmp = sin(re)
    else
        tmp = re * (0.5d0 + (0.5d0 * exp(im)))
    end if
    code = tmp
end function
im = Math.abs(im);
public static double code(double re, double im) {
	double tmp;
	if (im <= 4.0) {
		tmp = Math.sin(re);
	} else {
		tmp = re * (0.5 + (0.5 * Math.exp(im)));
	}
	return tmp;
}
im = abs(im)
def code(re, im):
	tmp = 0
	if im <= 4.0:
		tmp = math.sin(re)
	else:
		tmp = re * (0.5 + (0.5 * math.exp(im)))
	return tmp
im = abs(im)
function code(re, im)
	tmp = 0.0
	if (im <= 4.0)
		tmp = sin(re);
	else
		tmp = Float64(re * Float64(0.5 + Float64(0.5 * exp(im))));
	end
	return tmp
end
im = abs(im)
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 4.0)
		tmp = sin(re);
	else
		tmp = re * (0.5 + (0.5 * exp(im)));
	end
	tmp_2 = tmp;
end
NOTE: im should be positive before calling this function
code[re_, im_] := If[LessEqual[im, 4.0], N[Sin[re], $MachinePrecision], N[(re * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
im = |im|\\
\\
\begin{array}{l}
\mathbf{if}\;im \leq 4:\\
\;\;\;\;\sin re\\

\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 4

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 65.7%

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

    if 4 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
    5. Taylor expanded in re around 0 73.9%

      \[\leadsto \color{blue}{re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ \end{array} \]

Alternative 8: 72.0% accurate, 2.9× speedup?

\[\begin{array}{l} im = |im|\\ \\ \begin{array}{l} \mathbf{if}\;im \leq 660:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im)
 :precision binary64
 (if (<= im 660.0) (sin re) (* re (* 0.5 (pow im 2.0)))))
im = abs(im);
double code(double re, double im) {
	double tmp;
	if (im <= 660.0) {
		tmp = sin(re);
	} else {
		tmp = re * (0.5 * pow(im, 2.0));
	}
	return tmp;
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 660.0d0) then
        tmp = sin(re)
    else
        tmp = re * (0.5d0 * (im ** 2.0d0))
    end if
    code = tmp
end function
im = Math.abs(im);
public static double code(double re, double im) {
	double tmp;
	if (im <= 660.0) {
		tmp = Math.sin(re);
	} else {
		tmp = re * (0.5 * Math.pow(im, 2.0));
	}
	return tmp;
}
im = abs(im)
def code(re, im):
	tmp = 0
	if im <= 660.0:
		tmp = math.sin(re)
	else:
		tmp = re * (0.5 * math.pow(im, 2.0))
	return tmp
im = abs(im)
function code(re, im)
	tmp = 0.0
	if (im <= 660.0)
		tmp = sin(re);
	else
		tmp = Float64(re * Float64(0.5 * (im ^ 2.0)));
	end
	return tmp
end
im = abs(im)
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 660.0)
		tmp = sin(re);
	else
		tmp = re * (0.5 * (im ^ 2.0));
	end
	tmp_2 = tmp;
end
NOTE: im should be positive before calling this function
code[re_, im_] := If[LessEqual[im, 660.0], N[Sin[re], $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
im = |im|\\
\\
\begin{array}{l}
\mathbf{if}\;im \leq 660:\\
\;\;\;\;\sin re\\

\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 660

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 65.7%

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

    if 660 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-lft-in100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot e^{0 - im} + \left(0.5 \cdot \sin re\right) \cdot e^{im}} \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} + \left(0.5 \cdot \sin re\right) \cdot e^{im} \]
      3. cancel-sign-sub100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-0.5 \cdot \sin re\right) \cdot e^{im}} \]
      4. distribute-lft-neg-out100.0%

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

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \left(-\color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right)}\right) \]
      6. distribute-rgt-neg-out100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{e^{im} \cdot \left(-0.5 \cdot \sin re\right)} \]
      7. neg-mul-1100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - e^{im} \cdot \color{blue}{\left(-1 \cdot \left(0.5 \cdot \sin re\right)\right)} \]
      8. associate-*r*100.0%

        \[\leadsto e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) - \color{blue}{\left(e^{im} \cdot -1\right) \cdot \left(0.5 \cdot \sin re\right)} \]
      9. distribute-rgt-out--100.0%

        \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} - e^{im} \cdot -1\right)} \]
      10. sub-neg100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im} \cdot -1\right)\right)} \]
      11. neg-sub0100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + \left(-e^{im} \cdot -1\right)\right) \]
      12. *-commutative100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{-1 \cdot e^{im}}\right)\right) \]
      13. neg-mul-1100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \left(-\color{blue}{\left(-e^{im}\right)}\right)\right) \]
      14. remove-double-neg100.0%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \color{blue}{e^{im}}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)} \]
    4. Taylor expanded in im around 0 56.9%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
    5. Step-by-step derivation
      1. +-commutative56.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left({im}^{2} + 2\right)} \]
      2. unpow256.9%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{im \cdot im} + 2\right) \]
      3. fma-def56.9%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(2 + {im}^{2}\right)\right)} \]
    8. Step-by-step derivation
      1. associate-*r*47.2%

        \[\leadsto \color{blue}{\left(0.5 \cdot re\right) \cdot \left(2 + {im}^{2}\right)} \]
      2. *-commutative47.2%

        \[\leadsto \color{blue}{\left(re \cdot 0.5\right)} \cdot \left(2 + {im}^{2}\right) \]
      3. associate-*l*47.2%

        \[\leadsto \color{blue}{re \cdot \left(0.5 \cdot \left(2 + {im}^{2}\right)\right)} \]
      4. *-commutative47.2%

        \[\leadsto re \cdot \color{blue}{\left(\left(2 + {im}^{2}\right) \cdot 0.5\right)} \]
      5. +-commutative47.2%

        \[\leadsto re \cdot \left(\color{blue}{\left({im}^{2} + 2\right)} \cdot 0.5\right) \]
      6. unpow247.2%

        \[\leadsto re \cdot \left(\left(\color{blue}{im \cdot im} + 2\right) \cdot 0.5\right) \]
      7. fma-def47.2%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left({im}^{2} \cdot re\right)} \]
    11. Step-by-step derivation
      1. associate-*r*47.2%

        \[\leadsto \color{blue}{\left(0.5 \cdot {im}^{2}\right) \cdot re} \]
    12. Simplified47.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 660:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \]

Alternative 9: 72.0% accurate, 3.0× speedup?

\[\begin{array}{l} im = |im|\\ \\ \begin{array}{l} \mathbf{if}\;im \leq 2300000:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\ \end{array} \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im)
 :precision binary64
 (if (<= im 2300000.0) (sin re) (* re (+ 1.0 (* im (+ 0.5 (* im 0.25)))))))
im = abs(im);
double code(double re, double im) {
	double tmp;
	if (im <= 2300000.0) {
		tmp = sin(re);
	} else {
		tmp = re * (1.0 + (im * (0.5 + (im * 0.25))));
	}
	return tmp;
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 2300000.0d0) then
        tmp = sin(re)
    else
        tmp = re * (1.0d0 + (im * (0.5d0 + (im * 0.25d0))))
    end if
    code = tmp
end function
im = Math.abs(im);
public static double code(double re, double im) {
	double tmp;
	if (im <= 2300000.0) {
		tmp = Math.sin(re);
	} else {
		tmp = re * (1.0 + (im * (0.5 + (im * 0.25))));
	}
	return tmp;
}
im = abs(im)
def code(re, im):
	tmp = 0
	if im <= 2300000.0:
		tmp = math.sin(re)
	else:
		tmp = re * (1.0 + (im * (0.5 + (im * 0.25))))
	return tmp
im = abs(im)
function code(re, im)
	tmp = 0.0
	if (im <= 2300000.0)
		tmp = sin(re);
	else
		tmp = Float64(re * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.25)))));
	end
	return tmp
end
im = abs(im)
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 2300000.0)
		tmp = sin(re);
	else
		tmp = re * (1.0 + (im * (0.5 + (im * 0.25))));
	end
	tmp_2 = tmp;
end
NOTE: im should be positive before calling this function
code[re_, im_] := If[LessEqual[im, 2300000.0], N[Sin[re], $MachinePrecision], N[(re * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
im = |im|\\
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2300000:\\
\;\;\;\;\sin re\\

\mathbf{else}:\\
\;\;\;\;re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 2.3e6

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 65.7%

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

    if 2.3e6 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
    5. Taylor expanded in re around inf 100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)} \]
    6. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot e^{im}\right) \cdot \sin re} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot e^{im}\right) \cdot \sin re} \]
    8. Taylor expanded in im around 0 56.9%

      \[\leadsto \color{blue}{\left(1 + \left(0.25 \cdot {im}^{2} + 0.5 \cdot im\right)\right)} \cdot \sin re \]
    9. Step-by-step derivation
      1. +-commutative56.9%

        \[\leadsto \left(1 + \color{blue}{\left(0.5 \cdot im + 0.25 \cdot {im}^{2}\right)}\right) \cdot \sin re \]
      2. *-commutative56.9%

        \[\leadsto \left(1 + \left(\color{blue}{im \cdot 0.5} + 0.25 \cdot {im}^{2}\right)\right) \cdot \sin re \]
      3. *-commutative56.9%

        \[\leadsto \left(1 + \left(im \cdot 0.5 + \color{blue}{{im}^{2} \cdot 0.25}\right)\right) \cdot \sin re \]
      4. unpow256.9%

        \[\leadsto \left(1 + \left(im \cdot 0.5 + \color{blue}{\left(im \cdot im\right)} \cdot 0.25\right)\right) \cdot \sin re \]
      5. associate-*l*56.9%

        \[\leadsto \left(1 + \left(im \cdot 0.5 + \color{blue}{im \cdot \left(im \cdot 0.25\right)}\right)\right) \cdot \sin re \]
      6. distribute-lft-out56.9%

        \[\leadsto \left(1 + \color{blue}{im \cdot \left(0.5 + im \cdot 0.25\right)}\right) \cdot \sin re \]
    10. Simplified56.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2300000:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right)\\ \end{array} \]

Alternative 10: 48.3% accurate, 28.1× speedup?

\[\begin{array}{l} im = |im|\\ \\ re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right) \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im) :precision binary64 (* re (+ 1.0 (* im (+ 0.5 (* im 0.25))))))
im = abs(im);
double code(double re, double im) {
	return re * (1.0 + (im * (0.5 + (im * 0.25))));
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = re * (1.0d0 + (im * (0.5d0 + (im * 0.25d0))))
end function
im = Math.abs(im);
public static double code(double re, double im) {
	return re * (1.0 + (im * (0.5 + (im * 0.25))));
}
im = abs(im)
def code(re, im):
	return re * (1.0 + (im * (0.5 + (im * 0.25))))
im = abs(im)
function code(re, im)
	return Float64(re * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.25)))))
end
im = abs(im)
function tmp = code(re, im)
	tmp = re * (1.0 + (im * (0.5 + (im * 0.25))));
end
NOTE: im should be positive before calling this function
code[re_, im_] := N[(re * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im = |im|\\
\\
re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\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. Step-by-step derivation
    1. distribute-rgt-in100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
    2. +-commutative100.0%

      \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
    3. associate-*r*100.0%

      \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
    4. associate-*r*100.0%

      \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
    5. distribute-rgt-out100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
    6. cancel-sign-sub100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
    7. distribute-lft-neg-in100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
    8. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
    9. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
    10. sub-neg100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
    11. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    12. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    13. remove-double-neg100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
    14. distribute-rgt-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
    15. distribute-lft-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Taylor expanded in im around 0 74.5%

    \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
  5. Taylor expanded in re around inf 74.5%

    \[\leadsto \color{blue}{\sin re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)} \]
  6. Step-by-step derivation
    1. *-commutative74.5%

      \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot e^{im}\right) \cdot \sin re} \]
  7. Simplified74.5%

    \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot e^{im}\right) \cdot \sin re} \]
  8. Taylor expanded in im around 0 74.8%

    \[\leadsto \color{blue}{\left(1 + \left(0.25 \cdot {im}^{2} + 0.5 \cdot im\right)\right)} \cdot \sin re \]
  9. Step-by-step derivation
    1. +-commutative74.8%

      \[\leadsto \left(1 + \color{blue}{\left(0.5 \cdot im + 0.25 \cdot {im}^{2}\right)}\right) \cdot \sin re \]
    2. *-commutative74.8%

      \[\leadsto \left(1 + \left(\color{blue}{im \cdot 0.5} + 0.25 \cdot {im}^{2}\right)\right) \cdot \sin re \]
    3. *-commutative74.8%

      \[\leadsto \left(1 + \left(im \cdot 0.5 + \color{blue}{{im}^{2} \cdot 0.25}\right)\right) \cdot \sin re \]
    4. unpow274.8%

      \[\leadsto \left(1 + \left(im \cdot 0.5 + \color{blue}{\left(im \cdot im\right)} \cdot 0.25\right)\right) \cdot \sin re \]
    5. associate-*l*74.8%

      \[\leadsto \left(1 + \left(im \cdot 0.5 + \color{blue}{im \cdot \left(im \cdot 0.25\right)}\right)\right) \cdot \sin re \]
    6. distribute-lft-out74.8%

      \[\leadsto \left(1 + \color{blue}{im \cdot \left(0.5 + im \cdot 0.25\right)}\right) \cdot \sin re \]
  10. Simplified74.8%

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

    \[\leadsto \color{blue}{re \cdot \left(1 + im \cdot \left(0.5 + 0.25 \cdot im\right)\right)} \]
  12. Final simplification49.6%

    \[\leadsto re \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.25\right)\right) \]

Alternative 11: 33.0% accurate, 43.8× speedup?

\[\begin{array}{l} im = |im|\\ \\ \begin{array}{l} \mathbf{if}\;im \leq 1.02 \cdot 10^{-5}:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot im\right)\\ \end{array} \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im) :precision binary64 (if (<= im 1.02e-5) re (* re (* 0.5 im))))
im = abs(im);
double code(double re, double im) {
	double tmp;
	if (im <= 1.02e-5) {
		tmp = re;
	} else {
		tmp = re * (0.5 * im);
	}
	return tmp;
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 1.02d-5) then
        tmp = re
    else
        tmp = re * (0.5d0 * im)
    end if
    code = tmp
end function
im = Math.abs(im);
public static double code(double re, double im) {
	double tmp;
	if (im <= 1.02e-5) {
		tmp = re;
	} else {
		tmp = re * (0.5 * im);
	}
	return tmp;
}
im = abs(im)
def code(re, im):
	tmp = 0
	if im <= 1.02e-5:
		tmp = re
	else:
		tmp = re * (0.5 * im)
	return tmp
im = abs(im)
function code(re, im)
	tmp = 0.0
	if (im <= 1.02e-5)
		tmp = re;
	else
		tmp = Float64(re * Float64(0.5 * im));
	end
	return tmp
end
im = abs(im)
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 1.02e-5)
		tmp = re;
	else
		tmp = re * (0.5 * im);
	end
	tmp_2 = tmp;
end
NOTE: im should be positive before calling this function
code[re_, im_] := If[LessEqual[im, 1.02e-5], re, N[(re * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
im = |im|\\
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.02 \cdot 10^{-5}:\\
\;\;\;\;re\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 1.0200000000000001e-5

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 65.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
    5. Taylor expanded in im around 0 64.2%

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

      \[\leadsto \color{blue}{re \cdot \left(1 + 0.5 \cdot im\right)} \]
    7. Taylor expanded in im around 0 34.9%

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

    if 1.0200000000000001e-5 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-rgt-in100.0%

        \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
      2. +-commutative100.0%

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
      3. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

        \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
      5. distribute-rgt-out100.0%

        \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
      6. cancel-sign-sub100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
      7. distribute-lft-neg-in100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
      8. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
      9. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
      10. sub-neg100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
      11. *-commutative100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      12. neg-mul-1100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
      13. remove-double-neg100.0%

        \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
      14. distribute-rgt-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
      15. distribute-lft-in100.0%

        \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Taylor expanded in im around 0 100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
    5. Taylor expanded in im around 0 4.2%

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

      \[\leadsto \color{blue}{re \cdot \left(1 + 0.5 \cdot im\right)} \]
    7. Taylor expanded in im around inf 11.3%

      \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot re\right)} \]
    8. Step-by-step derivation
      1. associate-*r*11.3%

        \[\leadsto \color{blue}{\left(0.5 \cdot im\right) \cdot re} \]
    9. Simplified11.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.02 \cdot 10^{-5}:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot im\right)\\ \end{array} \]

Alternative 12: 32.9% accurate, 44.1× speedup?

\[\begin{array}{l} im = |im|\\ \\ re \cdot \left(1 + 0.5 \cdot im\right) \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im) :precision binary64 (* re (+ 1.0 (* 0.5 im))))
im = abs(im);
double code(double re, double im) {
	return re * (1.0 + (0.5 * im));
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = re * (1.0d0 + (0.5d0 * im))
end function
im = Math.abs(im);
public static double code(double re, double im) {
	return re * (1.0 + (0.5 * im));
}
im = abs(im)
def code(re, im):
	return re * (1.0 + (0.5 * im))
im = abs(im)
function code(re, im)
	return Float64(re * Float64(1.0 + Float64(0.5 * im)))
end
im = abs(im)
function tmp = code(re, im)
	tmp = re * (1.0 + (0.5 * im));
end
NOTE: im should be positive before calling this function
code[re_, im_] := N[(re * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im = |im|\\
\\
re \cdot \left(1 + 0.5 \cdot im\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. Step-by-step derivation
    1. distribute-rgt-in100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
    2. +-commutative100.0%

      \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
    3. associate-*r*100.0%

      \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
    4. associate-*r*100.0%

      \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
    5. distribute-rgt-out100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
    6. cancel-sign-sub100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
    7. distribute-lft-neg-in100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
    8. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
    9. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
    10. sub-neg100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
    11. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    12. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    13. remove-double-neg100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
    14. distribute-rgt-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
    15. distribute-lft-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Taylor expanded in im around 0 74.5%

    \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
  5. Taylor expanded in im around 0 48.0%

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

    \[\leadsto \color{blue}{re \cdot \left(1 + 0.5 \cdot im\right)} \]
  7. Final simplification30.6%

    \[\leadsto re \cdot \left(1 + 0.5 \cdot im\right) \]

Alternative 13: 2.9% accurate, 309.0× speedup?

\[\begin{array}{l} im = |im|\\ \\ 0 \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im) :precision binary64 0.0)
im = abs(im);
double code(double re, double im) {
	return 0.0;
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = 0.0d0
end function
im = Math.abs(im);
public static double code(double re, double im) {
	return 0.0;
}
im = abs(im)
def code(re, im):
	return 0.0
im = abs(im)
function code(re, im)
	return 0.0
end
im = abs(im)
function tmp = code(re, im)
	tmp = 0.0;
end
NOTE: im should be positive before calling this function
code[re_, im_] := 0.0
\begin{array}{l}
im = |im|\\
\\
0
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. Step-by-step derivation
    1. distribute-rgt-in100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
    2. +-commutative100.0%

      \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
    3. associate-*r*100.0%

      \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
    4. associate-*r*100.0%

      \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
    5. distribute-rgt-out100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
    6. cancel-sign-sub100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
    7. distribute-lft-neg-in100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
    8. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
    9. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
    10. sub-neg100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
    11. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    12. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    13. remove-double-neg100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
    14. distribute-rgt-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
    15. distribute-lft-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
  3. Simplified100.0%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(-1, \sin re \cdot -0.5, \sin re \cdot -0.5\right)} \]
  5. Step-by-step derivation
    1. fma-udef2.9%

      \[\leadsto \color{blue}{-1 \cdot \left(\sin re \cdot -0.5\right) + \sin re \cdot -0.5} \]
    2. neg-mul-12.9%

      \[\leadsto \color{blue}{\left(-\sin re \cdot -0.5\right)} + \sin re \cdot -0.5 \]
    3. +-commutative2.9%

      \[\leadsto \color{blue}{\sin re \cdot -0.5 + \left(-\sin re \cdot -0.5\right)} \]
    4. sub-neg2.9%

      \[\leadsto \color{blue}{\sin re \cdot -0.5 - \sin re \cdot -0.5} \]
    5. +-inverses2.9%

      \[\leadsto \color{blue}{0} \]
  6. Simplified2.9%

    \[\leadsto \color{blue}{0} \]
  7. Final simplification2.9%

    \[\leadsto 0 \]

Alternative 14: 26.9% accurate, 309.0× speedup?

\[\begin{array}{l} im = |im|\\ \\ re \end{array} \]
NOTE: im should be positive before calling this function
(FPCore (re im) :precision binary64 re)
im = abs(im);
double code(double re, double im) {
	return re;
}
NOTE: im should be positive before calling this function
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = re
end function
im = Math.abs(im);
public static double code(double re, double im) {
	return re;
}
im = abs(im)
def code(re, im):
	return re
im = abs(im)
function code(re, im)
	return re
end
im = abs(im)
function tmp = code(re, im)
	tmp = re;
end
NOTE: im should be positive before calling this function
code[re_, im_] := re
\begin{array}{l}
im = |im|\\
\\
re
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. Step-by-step derivation
    1. distribute-rgt-in100.0%

      \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
    2. +-commutative100.0%

      \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot \sin re\right) + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right)} \]
    3. associate-*r*100.0%

      \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
    4. associate-*r*100.0%

      \[\leadsto \left(e^{im} \cdot 0.5\right) \cdot \sin re + \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot \sin re} \]
    5. distribute-rgt-out100.0%

      \[\leadsto \color{blue}{\sin re \cdot \left(e^{im} \cdot 0.5 + e^{0 - im} \cdot 0.5\right)} \]
    6. cancel-sign-sub100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 - \left(-e^{0 - im}\right) \cdot 0.5\right)} \]
    7. distribute-lft-neg-in100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right) \]
    8. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right) \]
    9. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 - \color{blue}{\left(e^{0 - im} \cdot 0.5\right) \cdot -1}\right) \]
    10. sub-neg100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(e^{im} \cdot 0.5 + \left(-\left(e^{0 - im} \cdot 0.5\right) \cdot -1\right)\right)} \]
    11. *-commutative100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{-1 \cdot \left(e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    12. neg-mul-1100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \left(-\color{blue}{\left(-e^{0 - im} \cdot 0.5\right)}\right)\right) \]
    13. remove-double-neg100.0%

      \[\leadsto \sin re \cdot \left(e^{im} \cdot 0.5 + \color{blue}{e^{0 - im} \cdot 0.5}\right) \]
    14. distribute-rgt-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot \left(e^{im} + e^{0 - im}\right)\right)} \]
    15. distribute-lft-in100.0%

      \[\leadsto \sin re \cdot \color{blue}{\left(0.5 \cdot e^{im} + 0.5 \cdot e^{0 - im}\right)} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Taylor expanded in im around 0 74.5%

    \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
  5. Taylor expanded in im around 0 48.0%

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

    \[\leadsto \color{blue}{re \cdot \left(1 + 0.5 \cdot im\right)} \]
  7. Taylor expanded in im around 0 26.2%

    \[\leadsto \color{blue}{re} \]
  8. Final simplification26.2%

    \[\leadsto re \]

Reproduce

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