math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 9.2s
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} \\ \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (sin re) (fma 0.5 (exp im) (/ 0.5 (exp im)))))
double code(double re, double im) {
	return sin(re) * fma(0.5, exp(im), (0.5 / exp(im)));
}
function code(re, im)
	return Float64(sin(re) * fma(0.5, exp(im), Float64(0.5 / exp(im))))
end
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}

\\
\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: 84.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.3:\\
\;\;\;\;\mathsf{fma}\left(im \cdot \left(\sin re \cdot 0.5\right), im, \sin re\right)\\

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


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

    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 87.6%

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

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

        \[\leadsto \sin re + \left(\color{blue}{\left(0.5 \cdot {im}^{2}\right) \cdot \sin re} + 0.041666666666666664 \cdot \left({im}^{4} \cdot \sin re\right)\right) \]
      3. associate-*r*87.6%

        \[\leadsto \sin re + \left(\left(0.5 \cdot {im}^{2}\right) \cdot \sin re + \color{blue}{\left(0.041666666666666664 \cdot {im}^{4}\right) \cdot \sin re}\right) \]
      4. distribute-rgt-out87.6%

        \[\leadsto \sin re + \color{blue}{\sin re \cdot \left(0.5 \cdot {im}^{2} + 0.041666666666666664 \cdot {im}^{4}\right)} \]
      5. fma-def87.6%

        \[\leadsto \sin re + \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, {im}^{2}, 0.041666666666666664 \cdot {im}^{4}\right)} \]
    6. Simplified87.6%

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

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

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

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

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

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

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

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

    if 1.30000000000000004 < 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. Applied egg-rr99.9%

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

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

Alternative 3: 100.0% accurate, 1.0× speedup?

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

\\
\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 4: 87.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.3:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\

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


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

    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 77.7%

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

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

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

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

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

    if 1.30000000000000004 < 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. Applied egg-rr99.9%

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

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

Alternative 5: 84.3% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 1950 \lor \neg \left(im \leq 1.32 \cdot 10^{+154}\right):\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im 1950.0) (not (<= im 1.32e+154)))
   (* (* (sin re) 0.5) (fma im im 2.0))
   (* 0.5 (* re (+ (exp im) (exp (- im)))))))
double code(double re, double im) {
	double tmp;
	if ((im <= 1950.0) || !(im <= 1.32e+154)) {
		tmp = (sin(re) * 0.5) * fma(im, im, 2.0);
	} else {
		tmp = 0.5 * (re * (exp(im) + exp(-im)));
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if ((im <= 1950.0) || !(im <= 1.32e+154))
		tmp = Float64(Float64(sin(re) * 0.5) * fma(im, im, 2.0));
	else
		tmp = Float64(0.5 * Float64(re * Float64(exp(im) + exp(Float64(-im)))));
	end
	return tmp
end
code[re_, im_] := If[Or[LessEqual[im, 1950.0], N[Not[LessEqual[im, 1.32e+154]], $MachinePrecision]], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re * N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1950 \lor \neg \left(im \leq 1.32 \cdot 10^{+154}\right):\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 1950 or 1.31999999999999998e154 < 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 80.9%

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

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

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

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

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

    if 1950 < im < 1.31999999999999998e154

    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 re around 0 67.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1950 \lor \neg \left(im \leq 1.32 \cdot 10^{+154}\right):\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)\\ \end{array} \]

Alternative 6: 77.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 1100 \lor \neg \left(im \leq 2.02 \cdot 10^{+149}\right):\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {\left({re}^{4}\right)}^{0.25}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im 1100.0) (not (<= im 2.02e+149)))
   (* (* (sin re) 0.5) (fma im im 2.0))
   (* 0.5 (pow (pow re 4.0) 0.25))))
double code(double re, double im) {
	double tmp;
	if ((im <= 1100.0) || !(im <= 2.02e+149)) {
		tmp = (sin(re) * 0.5) * fma(im, im, 2.0);
	} else {
		tmp = 0.5 * pow(pow(re, 4.0), 0.25);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if ((im <= 1100.0) || !(im <= 2.02e+149))
		tmp = Float64(Float64(sin(re) * 0.5) * fma(im, im, 2.0));
	else
		tmp = Float64(0.5 * ((re ^ 4.0) ^ 0.25));
	end
	return tmp
end
code[re_, im_] := If[Or[LessEqual[im, 1100.0], N[Not[LessEqual[im, 2.02e+149]], $MachinePrecision]], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Power[N[Power[re, 4.0], $MachinePrecision], 0.25], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1100 \lor \neg \left(im \leq 2.02 \cdot 10^{+149}\right):\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot {\left({re}^{4}\right)}^{0.25}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 1100 or 2.02e149 < 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 81.2%

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

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

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

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

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

    if 1100 < im < 2.02e149

    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 re around 0 65.6%

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Applied egg-rr16.8%

      \[\leadsto 0.5 \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]
    6. Step-by-step derivation
      1. log1p-expm1-u2.0%

        \[\leadsto 0.5 \cdot \color{blue}{re} \]
      2. add-sqr-sqrt1.1%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{re} \cdot \sqrt{re}\right)} \]
      3. sqrt-unprod20.5%

        \[\leadsto 0.5 \cdot \color{blue}{\sqrt{re \cdot re}} \]
      4. pow220.5%

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{re}^{2}}} \]
    7. Applied egg-rr20.5%

      \[\leadsto 0.5 \cdot \color{blue}{\sqrt{{re}^{2}}} \]
    8. Step-by-step derivation
      1. pow1/220.5%

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

        \[\leadsto 0.5 \cdot \color{blue}{\left({\left({re}^{2}\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left({re}^{2}\right)}^{\left(\frac{0.5}{2}\right)}\right)} \]
      3. pow-prod-down32.2%

        \[\leadsto 0.5 \cdot \color{blue}{{\left({re}^{2} \cdot {re}^{2}\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. pow-prod-up32.2%

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

        \[\leadsto 0.5 \cdot {\left({re}^{\color{blue}{4}}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. metadata-eval32.2%

        \[\leadsto 0.5 \cdot {\left({re}^{4}\right)}^{\color{blue}{0.25}} \]
    9. Applied egg-rr32.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1100 \lor \neg \left(im \leq 2.02 \cdot 10^{+149}\right):\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {\left({re}^{4}\right)}^{0.25}\\ \end{array} \]

Alternative 7: 61.1% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 700:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.55 \cdot 10^{+92}:\\ \;\;\;\;0.5 \cdot {\left({re}^{3}\right)}^{0.3333333333333333}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 + {im}^{2}\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 700.0)
   (sin re)
   (if (<= im 3.55e+92)
     (* 0.5 (pow (pow re 3.0) 0.3333333333333333))
     (* 0.5 (* re (+ 2.0 (pow im 2.0)))))))
double code(double re, double im) {
	double tmp;
	if (im <= 700.0) {
		tmp = sin(re);
	} else if (im <= 3.55e+92) {
		tmp = 0.5 * pow(pow(re, 3.0), 0.3333333333333333);
	} else {
		tmp = 0.5 * (re * (2.0 + pow(im, 2.0)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 700.0d0) then
        tmp = sin(re)
    else if (im <= 3.55d+92) then
        tmp = 0.5d0 * ((re ** 3.0d0) ** 0.3333333333333333d0)
    else
        tmp = 0.5d0 * (re * (2.0d0 + (im ** 2.0d0)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 700.0) {
		tmp = Math.sin(re);
	} else if (im <= 3.55e+92) {
		tmp = 0.5 * Math.pow(Math.pow(re, 3.0), 0.3333333333333333);
	} else {
		tmp = 0.5 * (re * (2.0 + Math.pow(im, 2.0)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 700.0:
		tmp = math.sin(re)
	elif im <= 3.55e+92:
		tmp = 0.5 * math.pow(math.pow(re, 3.0), 0.3333333333333333)
	else:
		tmp = 0.5 * (re * (2.0 + math.pow(im, 2.0)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 700.0)
		tmp = sin(re);
	elseif (im <= 3.55e+92)
		tmp = Float64(0.5 * ((re ^ 3.0) ^ 0.3333333333333333));
	else
		tmp = Float64(0.5 * Float64(re * Float64(2.0 + (im ^ 2.0))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 700.0)
		tmp = sin(re);
	elseif (im <= 3.55e+92)
		tmp = 0.5 * ((re ^ 3.0) ^ 0.3333333333333333);
	else
		tmp = 0.5 * (re * (2.0 + (im ^ 2.0)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 700.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.55e+92], N[(0.5 * N[Power[N[Power[re, 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re * N[(2.0 + N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 700:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 3.55 \cdot 10^{+92}:\\
\;\;\;\;0.5 \cdot {\left({re}^{3}\right)}^{0.3333333333333333}\\

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


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

    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 63.0%

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

    if 700 < im < 3.55e92

    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 re around 0 57.1%

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Applied egg-rr15.4%

      \[\leadsto 0.5 \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]
    6. Step-by-step derivation
      1. log1p-expm1-u1.9%

        \[\leadsto 0.5 \cdot \color{blue}{re} \]
      2. add-cbrt-cube15.3%

        \[\leadsto 0.5 \cdot \color{blue}{\sqrt[3]{\left(re \cdot re\right) \cdot re}} \]
      3. pow1/334.2%

        \[\leadsto 0.5 \cdot \color{blue}{{\left(\left(re \cdot re\right) \cdot re\right)}^{0.3333333333333333}} \]
      4. pow334.2%

        \[\leadsto 0.5 \cdot {\color{blue}{\left({re}^{3}\right)}}^{0.3333333333333333} \]
    7. Applied egg-rr34.2%

      \[\leadsto 0.5 \cdot \color{blue}{{\left({re}^{3}\right)}^{0.3333333333333333}} \]

    if 3.55e92 < 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 78.8%

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

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

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

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

      \[\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 57.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 700:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.55 \cdot 10^{+92}:\\ \;\;\;\;0.5 \cdot {\left({re}^{3}\right)}^{0.3333333333333333}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 + {im}^{2}\right)\right)\\ \end{array} \]

Alternative 8: 61.3% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 660:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 5.2 \cdot 10^{+89}:\\ \;\;\;\;0.5 \cdot {\left({re}^{4}\right)}^{0.25}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 + {im}^{2}\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 660.0)
   (sin re)
   (if (<= im 5.2e+89)
     (* 0.5 (pow (pow re 4.0) 0.25))
     (* 0.5 (* re (+ 2.0 (pow im 2.0)))))))
double code(double re, double im) {
	double tmp;
	if (im <= 660.0) {
		tmp = sin(re);
	} else if (im <= 5.2e+89) {
		tmp = 0.5 * pow(pow(re, 4.0), 0.25);
	} else {
		tmp = 0.5 * (re * (2.0 + pow(im, 2.0)));
	}
	return tmp;
}
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 if (im <= 5.2d+89) then
        tmp = 0.5d0 * ((re ** 4.0d0) ** 0.25d0)
    else
        tmp = 0.5d0 * (re * (2.0d0 + (im ** 2.0d0)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 660.0) {
		tmp = Math.sin(re);
	} else if (im <= 5.2e+89) {
		tmp = 0.5 * Math.pow(Math.pow(re, 4.0), 0.25);
	} else {
		tmp = 0.5 * (re * (2.0 + Math.pow(im, 2.0)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 660.0:
		tmp = math.sin(re)
	elif im <= 5.2e+89:
		tmp = 0.5 * math.pow(math.pow(re, 4.0), 0.25)
	else:
		tmp = 0.5 * (re * (2.0 + math.pow(im, 2.0)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 660.0)
		tmp = sin(re);
	elseif (im <= 5.2e+89)
		tmp = Float64(0.5 * ((re ^ 4.0) ^ 0.25));
	else
		tmp = Float64(0.5 * Float64(re * Float64(2.0 + (im ^ 2.0))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 660.0)
		tmp = sin(re);
	elseif (im <= 5.2e+89)
		tmp = 0.5 * ((re ^ 4.0) ^ 0.25);
	else
		tmp = 0.5 * (re * (2.0 + (im ^ 2.0)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 660.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 5.2e+89], N[(0.5 * N[Power[N[Power[re, 4.0], $MachinePrecision], 0.25], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re * N[(2.0 + N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 660:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 5.2 \cdot 10^{+89}:\\
\;\;\;\;0.5 \cdot {\left({re}^{4}\right)}^{0.25}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 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 63.0%

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

    if 660 < im < 5.2000000000000001e89

    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 re around 0 60.0%

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

      \[\leadsto 0.5 \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]
    6. Step-by-step derivation
      1. log1p-expm1-u2.0%

        \[\leadsto 0.5 \cdot \color{blue}{re} \]
      2. add-sqr-sqrt1.1%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{re} \cdot \sqrt{re}\right)} \]
      3. sqrt-unprod26.6%

        \[\leadsto 0.5 \cdot \color{blue}{\sqrt{re \cdot re}} \]
      4. pow226.6%

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{re}^{2}}} \]
    7. Applied egg-rr26.6%

      \[\leadsto 0.5 \cdot \color{blue}{\sqrt{{re}^{2}}} \]
    8. Step-by-step derivation
      1. pow1/226.6%

        \[\leadsto 0.5 \cdot \color{blue}{{\left({re}^{2}\right)}^{0.5}} \]
      2. sqr-pow26.6%

        \[\leadsto 0.5 \cdot \color{blue}{\left({\left({re}^{2}\right)}^{\left(\frac{0.5}{2}\right)} \cdot {\left({re}^{2}\right)}^{\left(\frac{0.5}{2}\right)}\right)} \]
      3. pow-prod-down36.0%

        \[\leadsto 0.5 \cdot \color{blue}{{\left({re}^{2} \cdot {re}^{2}\right)}^{\left(\frac{0.5}{2}\right)}} \]
      4. pow-prod-up36.0%

        \[\leadsto 0.5 \cdot {\color{blue}{\left({re}^{\left(2 + 2\right)}\right)}}^{\left(\frac{0.5}{2}\right)} \]
      5. metadata-eval36.0%

        \[\leadsto 0.5 \cdot {\left({re}^{\color{blue}{4}}\right)}^{\left(\frac{0.5}{2}\right)} \]
      6. metadata-eval36.0%

        \[\leadsto 0.5 \cdot {\left({re}^{4}\right)}^{\color{blue}{0.25}} \]
    9. Applied egg-rr36.0%

      \[\leadsto 0.5 \cdot \color{blue}{{\left({re}^{4}\right)}^{0.25}} \]

    if 5.2000000000000001e89 < 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 77.3%

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

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

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

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

      \[\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 56.7%

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

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

Alternative 9: 62.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 1950:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 9.6 \cdot 10^{+114}:\\ \;\;\;\;0.5 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 + {im}^{2}\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 1950.0)
   (sin re)
   (if (<= im 9.6e+114)
     (* 0.5 (log1p (expm1 re)))
     (* 0.5 (* re (+ 2.0 (pow im 2.0)))))))
double code(double re, double im) {
	double tmp;
	if (im <= 1950.0) {
		tmp = sin(re);
	} else if (im <= 9.6e+114) {
		tmp = 0.5 * log1p(expm1(re));
	} else {
		tmp = 0.5 * (re * (2.0 + pow(im, 2.0)));
	}
	return tmp;
}
public static double code(double re, double im) {
	double tmp;
	if (im <= 1950.0) {
		tmp = Math.sin(re);
	} else if (im <= 9.6e+114) {
		tmp = 0.5 * Math.log1p(Math.expm1(re));
	} else {
		tmp = 0.5 * (re * (2.0 + Math.pow(im, 2.0)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 1950.0:
		tmp = math.sin(re)
	elif im <= 9.6e+114:
		tmp = 0.5 * math.log1p(math.expm1(re))
	else:
		tmp = 0.5 * (re * (2.0 + math.pow(im, 2.0)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 1950.0)
		tmp = sin(re);
	elseif (im <= 9.6e+114)
		tmp = Float64(0.5 * log1p(expm1(re)));
	else
		tmp = Float64(0.5 * Float64(re * Float64(2.0 + (im ^ 2.0))));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 1950.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 9.6e+114], N[(0.5 * N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re * N[(2.0 + N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1950:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 9.6 \cdot 10^{+114}:\\
\;\;\;\;0.5 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\

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


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

    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 62.7%

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

    if 1950 < im < 9.6e114

    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 re around 0 69.2%

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Applied egg-rr16.7%

      \[\leadsto 0.5 \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]

    if 9.6e114 < 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 89.2%

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

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

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

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

      \[\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 65.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1950:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 9.6 \cdot 10^{+114}:\\ \;\;\;\;0.5 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 + {im}^{2}\right)\right)\\ \end{array} \]

Alternative 10: 60.5% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 360000000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+136}:\\ \;\;\;\;-0.5 \cdot {re}^{2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 + {im}^{2}\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 360000000.0)
   (sin re)
   (if (<= im 4.4e+136)
     (* -0.5 (pow re 2.0))
     (* 0.5 (* re (+ 2.0 (pow im 2.0)))))))
double code(double re, double im) {
	double tmp;
	if (im <= 360000000.0) {
		tmp = sin(re);
	} else if (im <= 4.4e+136) {
		tmp = -0.5 * pow(re, 2.0);
	} else {
		tmp = 0.5 * (re * (2.0 + pow(im, 2.0)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 360000000.0d0) then
        tmp = sin(re)
    else if (im <= 4.4d+136) then
        tmp = (-0.5d0) * (re ** 2.0d0)
    else
        tmp = 0.5d0 * (re * (2.0d0 + (im ** 2.0d0)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 360000000.0) {
		tmp = Math.sin(re);
	} else if (im <= 4.4e+136) {
		tmp = -0.5 * Math.pow(re, 2.0);
	} else {
		tmp = 0.5 * (re * (2.0 + Math.pow(im, 2.0)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 360000000.0:
		tmp = math.sin(re)
	elif im <= 4.4e+136:
		tmp = -0.5 * math.pow(re, 2.0)
	else:
		tmp = 0.5 * (re * (2.0 + math.pow(im, 2.0)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 360000000.0)
		tmp = sin(re);
	elseif (im <= 4.4e+136)
		tmp = Float64(-0.5 * (re ^ 2.0));
	else
		tmp = Float64(0.5 * Float64(re * Float64(2.0 + (im ^ 2.0))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 360000000.0)
		tmp = sin(re);
	elseif (im <= 4.4e+136)
		tmp = -0.5 * (re ^ 2.0);
	else
		tmp = 0.5 * (re * (2.0 + (im ^ 2.0)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 360000000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 4.4e+136], N[(-0.5 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re * N[(2.0 + N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 360000000:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 4.4 \cdot 10^{+136}:\\
\;\;\;\;-0.5 \cdot {re}^{2}\\

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


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

    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 61.2%

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

    if 3.6e8 < im < 4.3999999999999999e136

    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 3.7%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 - -1 \cdot \cos re} \]
    8. Taylor expanded in re around 0 10.8%

      \[\leadsto \color{blue}{-0.5 \cdot {re}^{2}} \]

    if 4.3999999999999999e136 < 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 89.2%

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

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

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

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

      \[\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 65.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 360000000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+136}:\\ \;\;\;\;-0.5 \cdot {re}^{2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 + {im}^{2}\right)\right)\\ \end{array} \]

Alternative 11: 52.9% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 380000000:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot {re}^{2}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 380000000.0) (sin re) (* -0.5 (pow re 2.0))))
double code(double re, double im) {
	double tmp;
	if (im <= 380000000.0) {
		tmp = sin(re);
	} else {
		tmp = -0.5 * pow(re, 2.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 380000000.0d0) then
        tmp = sin(re)
    else
        tmp = (-0.5d0) * (re ** 2.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 380000000.0) {
		tmp = Math.sin(re);
	} else {
		tmp = -0.5 * Math.pow(re, 2.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 380000000.0:
		tmp = math.sin(re)
	else:
		tmp = -0.5 * math.pow(re, 2.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 380000000.0)
		tmp = sin(re);
	else
		tmp = Float64(-0.5 * (re ^ 2.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 380000000.0)
		tmp = sin(re);
	else
		tmp = -0.5 * (re ^ 2.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 380000000.0], N[Sin[re], $MachinePrecision], N[(-0.5 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 380000000:\\
\;\;\;\;\sin re\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot {re}^{2}\\


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

    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 61.2%

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

    if 3.8e8 < 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 61.2%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 - -1 \cdot \cos re} \]
    8. Taylor expanded in re around 0 15.2%

      \[\leadsto \color{blue}{-0.5 \cdot {re}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification49.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 380000000:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot {re}^{2}\\ \end{array} \]

Alternative 12: 50.2% accurate, 3.1× speedup?

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

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

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

    \[\leadsto \color{blue}{\sin re} \]
  5. Final simplification46.6%

    \[\leadsto \sin re \]

Alternative 13: 26.0% accurate, 61.8× speedup?

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

\\
0.5 \cdot \left(re + re\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. 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 re around 0 62.9%

    \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
  5. Applied egg-rr27.0%

    \[\leadsto 0.5 \cdot \color{blue}{\left(re + re\right)} \]
  6. Final simplification27.0%

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

Alternative 14: 6.7% accurate, 103.0× speedup?

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

\\
re \cdot 0.5
\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. Taylor expanded in re around 0 62.9%

    \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
  5. Applied egg-rr17.6%

    \[\leadsto 0.5 \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]
  6. Taylor expanded in re around 0 6.9%

    \[\leadsto 0.5 \cdot \color{blue}{re} \]
  7. Final simplification6.9%

    \[\leadsto re \cdot 0.5 \]

Reproduce

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