math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 7.6s
Alternatives: 22
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 22 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

\\
\left(0.5 \cdot \sin re\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-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. cancel-sign-sub100.0%

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

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

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

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

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

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

Alternative 2: 85.6% accurate, 1.4× speedup?

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

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

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

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


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

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

    if 0.23999999999999999 < im < 1e103

    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-in99.9%

        \[\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. cancel-sign-sub99.9%

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

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

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

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

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

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

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

    if 1e103 < 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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \color{blue}{\left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)}\right) \]
    11. Taylor expanded in re around inf 100.0%

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

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

Alternative 3: 85.5% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;im \leq 10^{+103}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{im} + \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\\

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


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

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

    if 0.880000000000000004 < im < 1e103

    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-in99.9%

        \[\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. cancel-sign-sub99.9%

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

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

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

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

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

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

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

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

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

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

    if 1e103 < 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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \color{blue}{\left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)}\right) \]
    11. Taylor expanded in re around inf 100.0%

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

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

Alternative 4: 74.7% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + \left(1 - im\right)\right) \]
  9. Add Preprocessing

Alternative 5: 85.2% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.0002:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\

\mathbf{elif}\;im \leq 10^{+103}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{im} + \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\color{blue}{\left(1 - im\right)} + e^{im}\right) \]
    7. Simplified59.8%

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

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

    if 2.0000000000000001e-4 < im < 1e103

    1. Initial program 99.8%

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

        \[\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. cancel-sign-sub99.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} + e^{im}\right) \]
    7. Simplified65.6%

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

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

    if 1e103 < 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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \color{blue}{\left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)}\right) \]
    11. Taylor expanded in re around inf 100.0%

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

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

Alternative 6: 85.2% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.2:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\

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

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. distribute-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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

    if 5.20000000000000018 < im < 1e103

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(re \cdot 0.5\right) \cdot \color{blue}{\left(\left(e^{im} - 1\right) - im\right)} \]
      4. expm1-define65.2%

        \[\leadsto \left(re \cdot 0.5\right) \cdot \left(\color{blue}{\mathsf{expm1}\left(im\right)} - im\right) \]
    12. Simplified65.2%

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

    if 1e103 < 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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \color{blue}{\left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)}\right) \]
    11. Taylor expanded in re around inf 100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 5.2:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\ \mathbf{elif}\;im \leq 10^{+103}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{expm1}\left(im\right) - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 84.1% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 6.5 \lor \neg \left(im \leq 1.85 \cdot 10^{+154}\right):\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{expm1}\left(im\right) - im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im 6.5) (not (<= im 1.85e+154)))
   (* 0.5 (* (sin re) (- (+ 2.0 (* im (+ 1.0 (* 0.5 im)))) im)))
   (* (* 0.5 re) (- (expm1 im) im))))
double code(double re, double im) {
	double tmp;
	if ((im <= 6.5) || !(im <= 1.85e+154)) {
		tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
	} else {
		tmp = (0.5 * re) * (expm1(im) - im);
	}
	return tmp;
}
public static double code(double re, double im) {
	double tmp;
	if ((im <= 6.5) || !(im <= 1.85e+154)) {
		tmp = 0.5 * (Math.sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
	} else {
		tmp = (0.5 * re) * (Math.expm1(im) - im);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= 6.5) or not (im <= 1.85e+154):
		tmp = 0.5 * (math.sin(re) * ((2.0 + (im * (1.0 + (0.5 * im)))) - im))
	else:
		tmp = (0.5 * re) * (math.expm1(im) - im)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= 6.5) || !(im <= 1.85e+154))
		tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) - im)));
	else
		tmp = Float64(Float64(0.5 * re) * Float64(expm1(im) - im));
	end
	return tmp
end
code[re_, im_] := If[Or[LessEqual[im, 6.5], N[Not[LessEqual[im, 1.85e+154]], $MachinePrecision]], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(Exp[im] - 1), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 6.5 \lor \neg \left(im \leq 1.85 \cdot 10^{+154}\right):\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 6.5 or 1.84999999999999997e154 < 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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.5 < im < 1.84999999999999997e154

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(\left(1 + e^{im}\right) - im\right)\right)} \]
    9. Simplified68.4%

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

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

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

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

        \[\leadsto \left(re \cdot 0.5\right) \cdot \color{blue}{\left(\left(e^{im} - 1\right) - im\right)} \]
      4. expm1-define68.4%

        \[\leadsto \left(re \cdot 0.5\right) \cdot \left(\color{blue}{\mathsf{expm1}\left(im\right)} - im\right) \]
    12. Simplified68.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 6.5 \lor \neg \left(im \leq 1.85 \cdot 10^{+154}\right):\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{expm1}\left(im\right) - im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 84.1% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := im \cdot \left(1 + 0.5 \cdot im\right)\\ \mathbf{if}\;im \leq 7:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + t\_0\right)\right)\\ \mathbf{elif}\;im \leq 1.85 \cdot 10^{+154}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{expm1}\left(im\right) - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + t\_0\right) - im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* im (+ 1.0 (* 0.5 im)))))
   (if (<= im 7.0)
     (* (* 0.5 (sin re)) (+ (- 1.0 im) (+ 1.0 t_0)))
     (if (<= im 1.85e+154)
       (* (* 0.5 re) (- (expm1 im) im))
       (* 0.5 (* (sin re) (- (+ 2.0 t_0) im)))))))
double code(double re, double im) {
	double t_0 = im * (1.0 + (0.5 * im));
	double tmp;
	if (im <= 7.0) {
		tmp = (0.5 * sin(re)) * ((1.0 - im) + (1.0 + t_0));
	} else if (im <= 1.85e+154) {
		tmp = (0.5 * re) * (expm1(im) - im);
	} else {
		tmp = 0.5 * (sin(re) * ((2.0 + t_0) - im));
	}
	return tmp;
}
public static double code(double re, double im) {
	double t_0 = im * (1.0 + (0.5 * im));
	double tmp;
	if (im <= 7.0) {
		tmp = (0.5 * Math.sin(re)) * ((1.0 - im) + (1.0 + t_0));
	} else if (im <= 1.85e+154) {
		tmp = (0.5 * re) * (Math.expm1(im) - im);
	} else {
		tmp = 0.5 * (Math.sin(re) * ((2.0 + t_0) - im));
	}
	return tmp;
}
def code(re, im):
	t_0 = im * (1.0 + (0.5 * im))
	tmp = 0
	if im <= 7.0:
		tmp = (0.5 * math.sin(re)) * ((1.0 - im) + (1.0 + t_0))
	elif im <= 1.85e+154:
		tmp = (0.5 * re) * (math.expm1(im) - im)
	else:
		tmp = 0.5 * (math.sin(re) * ((2.0 + t_0) - im))
	return tmp
function code(re, im)
	t_0 = Float64(im * Float64(1.0 + Float64(0.5 * im)))
	tmp = 0.0
	if (im <= 7.0)
		tmp = Float64(Float64(0.5 * sin(re)) * Float64(Float64(1.0 - im) + Float64(1.0 + t_0)));
	elseif (im <= 1.85e+154)
		tmp = Float64(Float64(0.5 * re) * Float64(expm1(im) - im));
	else
		tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + t_0) - im)));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 7.0], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.85e+154], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(Exp[im] - 1), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + t$95$0), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := im \cdot \left(1 + 0.5 \cdot im\right)\\
\mathbf{if}\;im \leq 7:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + t\_0\right)\right)\\

\mathbf{elif}\;im \leq 1.85 \cdot 10^{+154}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{expm1}\left(im\right) - im\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + t\_0\right) - im\right)\right)\\


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

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

    if 7 < im < 1.84999999999999997e154

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(\left(1 + e^{im}\right) - im\right)\right)} \]
    9. Simplified68.4%

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

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

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

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

        \[\leadsto \left(re \cdot 0.5\right) \cdot \color{blue}{\left(\left(e^{im} - 1\right) - im\right)} \]
      4. expm1-define68.4%

        \[\leadsto \left(re \cdot 0.5\right) \cdot \left(\color{blue}{\mathsf{expm1}\left(im\right)} - im\right) \]
    12. Simplified68.4%

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

    if 1.84999999999999997e154 < 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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 7:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.85 \cdot 10^{+154}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{expm1}\left(im\right) - im\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 65.5% accurate, 2.7× speedup?

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

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

\mathbf{elif}\;im \leq 3.8 \cdot 10^{+90}:\\
\;\;\;\;\left(im - e^{im}\right) - -1\\

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


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

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

    if 2.2e8 < im < 3.8000000000000001e90

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.8000000000000001e90 < 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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot 0.16666666666666666}\right)\right)\right)\right) \]
    10. Simplified92.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 220000000:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.8 \cdot 10^{+90}:\\ \;\;\;\;\left(im - e^{im}\right) - -1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 68.0% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 4.9:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{expm1}\left(im\right) - im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 4.9) (sin re) (* (* 0.5 re) (- (expm1 im) im))))
double code(double re, double im) {
	double tmp;
	if (im <= 4.9) {
		tmp = sin(re);
	} else {
		tmp = (0.5 * re) * (expm1(im) - im);
	}
	return tmp;
}
public static double code(double re, double im) {
	double tmp;
	if (im <= 4.9) {
		tmp = Math.sin(re);
	} else {
		tmp = (0.5 * re) * (Math.expm1(im) - im);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 4.9:
		tmp = math.sin(re)
	else:
		tmp = (0.5 * re) * (math.expm1(im) - im)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 4.9)
		tmp = sin(re);
	else
		tmp = Float64(Float64(0.5 * re) * Float64(expm1(im) - im));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 4.9], N[Sin[re], $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(Exp[im] - 1), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

    if 4.9000000000000004 < 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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(\left(1 + e^{im}\right) - im\right)\right)} \]
    9. Simplified66.7%

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

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

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

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

        \[\leadsto \left(re \cdot 0.5\right) \cdot \color{blue}{\left(\left(e^{im} - 1\right) - im\right)} \]
      4. expm1-define66.7%

        \[\leadsto \left(re \cdot 0.5\right) \cdot \left(\color{blue}{\mathsf{expm1}\left(im\right)} - im\right) \]
    12. Simplified66.7%

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

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

Alternative 11: 63.2% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.3 \cdot 10^{+34}:\\
\;\;\;\;\sin re\\

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


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

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

    if 3.29999999999999988e34 < 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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \color{blue}{\left(1 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right)}\right) \]
    9. Step-by-step derivation
      1. *-commutative79.1%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot 0.16666666666666666}\right)\right)\right)\right) \]
    10. Simplified79.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.3 \cdot 10^{+34}:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 50.4% accurate, 14.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 2.3:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) - im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 2.3)
   (* 0.5 (* re (- (+ 2.0 (* im (+ 1.0 (* 0.5 im)))) im)))
   (*
    0.5
    (* re (- (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))) im)))))
double code(double re, double im) {
	double tmp;
	if (im <= 2.3) {
		tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
	} else {
		tmp = 0.5 * (re * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) - im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 2.3d0) then
        tmp = 0.5d0 * (re * ((2.0d0 + (im * (1.0d0 + (0.5d0 * im)))) - im))
    else
        tmp = 0.5d0 * (re * ((im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))) - im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 2.3) {
		tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
	} else {
		tmp = 0.5 * (re * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) - im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 2.3:
		tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im))
	else:
		tmp = 0.5 * (re * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) - im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 2.3)
		tmp = Float64(0.5 * Float64(re * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) - im)));
	else
		tmp = Float64(0.5 * Float64(re * Float64(Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))) - im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 2.3)
		tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (0.5 * im)))) - im));
	else
		tmp = 0.5 * (re * ((im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))) - im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 2.3], N[(0.5 * N[(re * N[(N[(2.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re * N[(N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.3:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\

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


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

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.2999999999999998 < 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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(\left(1 + e^{im}\right) - im\right)\right)} \]
    9. Simplified66.7%

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

      \[\leadsto \left(re \cdot 0.5\right) \cdot \left(-1 + \left(\color{blue}{\left(1 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right)} - im\right)\right) \]
    11. Step-by-step derivation
      1. *-commutative68.1%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot 0.16666666666666666}\right)\right)\right)\right) \]
    12. Simplified47.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.3:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right) - im\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 44.3% accurate, 14.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \color{blue}{\left(1 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right)}\right) \]
  9. Step-by-step derivation
    1. *-commutative60.3%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot 0.16666666666666666}\right)\right)\right)\right) \]
  10. Simplified60.3%

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

    \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\right) \]
  12. Add Preprocessing

Alternative 14: 44.3% accurate, 16.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \color{blue}{\left(1 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right)}\right) \]
  9. Step-by-step derivation
    1. *-commutative60.3%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(\left(1 - im\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot 0.16666666666666666}\right)\right)\right)\right) \]
  10. Simplified60.3%

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

    \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right) - im\right)\right)} \]
  12. Final simplification42.5%

    \[\leadsto 0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\right) \]
  13. Add Preprocessing

Alternative 15: 47.9% accurate, 20.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + 0.5 \cdot im\right)\right) - im\right)\right)} \]
  10. Add Preprocessing

Alternative 16: 29.5% accurate, 30.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq 2.75 \cdot 10^{+45}:\\
\;\;\;\;2 \cdot \left(0.5 \cdot re\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 2.75e45

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.5 \cdot re\right)} \cdot \left(e^{-im} + e^{im}\right) \]
    7. Simplified73.8%

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

      \[\leadsto \left(re \cdot 0.5\right) \cdot \color{blue}{2} \]

    if 2.75e45 < re

    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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(\left(1 + e^{im}\right) - im\right)\right)} \]
    9. Simplified27.5%

      \[\leadsto \color{blue}{\left(re \cdot 0.5\right) \cdot \left(-1 + \left(e^{im} - im\right)\right)} \]
    10. Taylor expanded in im around inf 18.9%

      \[\leadsto \color{blue}{-0.5 \cdot \left(im \cdot re\right)} \]
    11. Step-by-step derivation
      1. *-commutative18.9%

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

        \[\leadsto \color{blue}{\left(re \cdot im\right)} \cdot -0.5 \]
    12. Simplified18.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 2.75 \cdot 10^{+45}:\\ \;\;\;\;2 \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(re \cdot im\right) \cdot -0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 26.4% accurate, 61.8× speedup?

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

\\
2 \cdot \left(0.5 \cdot 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-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. cancel-sign-sub100.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(re \cdot 0.5\right) \cdot \color{blue}{2} \]
  9. Final simplification24.6%

    \[\leadsto 2 \cdot \left(0.5 \cdot re\right) \]
  10. Add Preprocessing

Alternative 18: 6.7% accurate, 103.0× speedup?

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

\\
re \cdot 2
\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. cancel-sign-sub100.0%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sin re + \sin re} \]
  6. Step-by-step derivation
    1. count-29.7%

      \[\leadsto \color{blue}{2 \cdot \sin re} \]
  7. Simplified9.7%

    \[\leadsto \color{blue}{2 \cdot \sin re} \]
  8. Taylor expanded in re around 0 6.7%

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

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

Alternative 19: 4.6% accurate, 309.0× speedup?

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

\\
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-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. cancel-sign-sub100.0%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sin re + \sin re} \]
  6. Step-by-step derivation
    1. count-29.7%

      \[\leadsto \color{blue}{2 \cdot \sin re} \]
  7. Simplified9.7%

    \[\leadsto \color{blue}{2 \cdot \sin re} \]
  8. Taylor expanded in re around 0 6.7%

    \[\leadsto \color{blue}{2 \cdot re} \]
  9. Applied egg-rr4.1%

    \[\leadsto \color{blue}{0.5} \]
  10. Add Preprocessing

Alternative 20: 4.4% accurate, 309.0× speedup?

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

\\
0.25
\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. cancel-sign-sub100.0%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sin re + \sin re} \]
  6. Step-by-step derivation
    1. count-29.7%

      \[\leadsto \color{blue}{2 \cdot \sin re} \]
  7. Simplified9.7%

    \[\leadsto \color{blue}{2 \cdot \sin re} \]
  8. Taylor expanded in re around 0 6.7%

    \[\leadsto \color{blue}{2 \cdot re} \]
  9. Applied egg-rr4.0%

    \[\leadsto \color{blue}{0.25} \]
  10. Add Preprocessing

Alternative 21: 4.5% accurate, 309.0× speedup?

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

\\
-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-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. cancel-sign-sub100.0%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sin re + \sin re} \]
  6. Step-by-step derivation
    1. count-29.7%

      \[\leadsto \color{blue}{2 \cdot \sin re} \]
  7. Simplified9.7%

    \[\leadsto \color{blue}{2 \cdot \sin re} \]
  8. Taylor expanded in re around 0 6.7%

    \[\leadsto \color{blue}{2 \cdot re} \]
  9. Applied egg-rr4.1%

    \[\leadsto \color{blue}{-0.5} \]
  10. Add Preprocessing

Alternative 22: 4.1% accurate, 309.0× speedup?

\[\begin{array}{l} \\ -6 \end{array} \]
(FPCore (re im) :precision binary64 -6.0)
double code(double re, double im) {
	return -6.0;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = -6.0d0
end function
public static double code(double re, double im) {
	return -6.0;
}
def code(re, im):
	return -6.0
function code(re, im)
	return -6.0
end
function tmp = code(re, im)
	tmp = -6.0;
end
code[re_, im_] := -6.0
\begin{array}{l}

\\
-6
\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. cancel-sign-sub100.0%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sin re + \sin re} \]
  6. Step-by-step derivation
    1. count-29.7%

      \[\leadsto \color{blue}{2 \cdot \sin re} \]
  7. Simplified9.7%

    \[\leadsto \color{blue}{2 \cdot \sin re} \]
  8. Taylor expanded in re around 0 6.7%

    \[\leadsto \color{blue}{2 \cdot re} \]
  9. Applied egg-rr3.7%

    \[\leadsto \color{blue}{-6} \]
  10. Add Preprocessing

Reproduce

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