math.sin on complex, real part

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 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: 72.6% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 1.65 \cdot 10^{-5}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;\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}:\\ \;\;\;\;\sin re \cdot \left(0.041666666666666664 \cdot {im}^{4}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 1.65e-5)
   (sin re)
   (if (<= im 1.15e+77)
     (*
      (* 0.5 re)
      (+
       (exp im)
       (+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
     (* (sin re) (* 0.041666666666666664 (pow im 4.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 1.65e-5) {
		tmp = sin(re);
	} else if (im <= 1.15e+77) {
		tmp = (0.5 * re) * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
	} else {
		tmp = sin(re) * (0.041666666666666664 * pow(im, 4.0));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 1.65d-5) then
        tmp = sin(re)
    else if (im <= 1.15d+77) then
        tmp = (0.5d0 * re) * (exp(im) + (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
    else
        tmp = sin(re) * (0.041666666666666664d0 * (im ** 4.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 1.65e-5) {
		tmp = Math.sin(re);
	} else if (im <= 1.15e+77) {
		tmp = (0.5 * re) * (Math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
	} else {
		tmp = Math.sin(re) * (0.041666666666666664 * Math.pow(im, 4.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 1.65e-5:
		tmp = math.sin(re)
	elif im <= 1.15e+77:
		tmp = (0.5 * re) * (math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))))
	else:
		tmp = math.sin(re) * (0.041666666666666664 * math.pow(im, 4.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 1.65e-5)
		tmp = sin(re);
	elseif (im <= 1.15e+77)
		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(sin(re) * Float64(0.041666666666666664 * (im ^ 4.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 1.65e-5)
		tmp = sin(re);
	elseif (im <= 1.15e+77)
		tmp = (0.5 * re) * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
	else
		tmp = sin(re) * (0.041666666666666664 * (im ^ 4.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 1.65e-5], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.15e+77], 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[(N[Sin[re], $MachinePrecision] * N[(0.041666666666666664 * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.65 \cdot 10^{-5}:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;\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}:\\
\;\;\;\;\sin re \cdot \left(0.041666666666666664 \cdot {im}^{4}\right)\\


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

    1. Initial program 100.0%

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

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

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

    if 1.6500000000000001e-5 < im < 1.14999999999999997e77

    1. Initial program 99.9%

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot re\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 1.14999999999999997e77 < 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 91.8%

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

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

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

        \[\leadsto \mathsf{fma}\left({im}^{2}, \color{blue}{\left(0.041666666666666664 \cdot {im}^{2}\right) \cdot \sin re} + 0.5 \cdot \sin re, \sin re\right) \]
      4. distribute-rgt-out91.8%

        \[\leadsto \mathsf{fma}\left({im}^{2}, \color{blue}{\sin re \cdot \left(0.041666666666666664 \cdot {im}^{2} + 0.5\right)}, \sin re\right) \]
      5. *-commutative91.8%

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

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left({im}^{4} \cdot \sin re\right)} \]
    9. Step-by-step derivation
      1. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(0.041666666666666664 \cdot {im}^{4}\right) \cdot \sin re} \]
    10. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.65 \cdot 10^{-5}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;\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}:\\ \;\;\;\;\sin re \cdot \left(0.041666666666666664 \cdot {im}^{4}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 87.2% accurate, 1.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(e^{im} + 3\right)\\


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

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

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

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

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

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

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

    if 2.10000000000000009 < 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. Applied egg-rr100.0%

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

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

Alternative 4: 74.2% accurate, 1.5× speedup?

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

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

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


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

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

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

    if 1.1499999999999999 < 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. Applied egg-rr100.0%

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

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

Alternative 5: 72.0% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.1 \cdot 10^{-5}:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 1.05 \cdot 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}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\


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

    1. Initial program 100.0%

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

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

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

    if 1.1e-5 < im < 1.0500000000000001e103

    1. Initial program 99.9%

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot re\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 1.0500000000000001e103 < 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. Applied egg-rr100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.1 \cdot 10^{-5}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.05 \cdot 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}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 72.1% accurate, 2.4× speedup?

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

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

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

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


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

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

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

    if 2.89999999999999991 < im < 1.0500000000000001e103

    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-rr100.0%

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

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

    if 1.0500000000000001e103 < 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. Applied egg-rr100.0%

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

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

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

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

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

Alternative 7: 71.2% accurate, 2.5× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

    if 3.7000000000000002 < im < 1.8999999999999999e154

    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-rr100.0%

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

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

    if 1.8999999999999999e154 < 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. Applied egg-rr100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.7:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.9 \cdot 10^{+154}:\\ \;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(4 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 68.1% accurate, 2.8× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

    if 6.20000000000000018 < 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. Applied egg-rr100.0%

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

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

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

Alternative 9: 61.0% accurate, 2.8× speedup?

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

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

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


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

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

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

    if 1.1000000000000001e42 < 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 59.5%

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left({im}^{2} \cdot re\right)} \]
    10. Step-by-step derivation
      1. *-commutative45.7%

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

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

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

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

Alternative 10: 54.3% accurate, 2.8× speedup?

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

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

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


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

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

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

    if 3.35000000000000024e89 < 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 70.7%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(re, -28, re\right)} \cdot \mathsf{fma}\left(im, im, 2\right) \]
    10. Step-by-step derivation
      1. fma-undefine29.3%

        \[\leadsto \color{blue}{\left(re \cdot -28 + re\right)} \cdot \mathsf{fma}\left(im, im, 2\right) \]
      2. *-rgt-identity29.3%

        \[\leadsto \left(re \cdot -28 + \color{blue}{re \cdot 1}\right) \cdot \mathsf{fma}\left(im, im, 2\right) \]
      3. distribute-lft-out29.3%

        \[\leadsto \color{blue}{\left(re \cdot \left(-28 + 1\right)\right)} \cdot \mathsf{fma}\left(im, im, 2\right) \]
      4. metadata-eval29.3%

        \[\leadsto \left(re \cdot \color{blue}{-27}\right) \cdot \mathsf{fma}\left(im, im, 2\right) \]
    11. Simplified29.3%

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

      \[\leadsto \color{blue}{-27 \cdot \left({im}^{2} \cdot re\right)} \]
    13. Step-by-step derivation
      1. *-commutative29.3%

        \[\leadsto \color{blue}{\left({im}^{2} \cdot re\right) \cdot -27} \]
      2. *-commutative29.3%

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

        \[\leadsto \color{blue}{re \cdot \left({im}^{2} \cdot -27\right)} \]
    14. Simplified29.3%

      \[\leadsto \color{blue}{re \cdot \left({im}^{2} \cdot -27\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 53.1% accurate, 2.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{re \cdot 15}\\


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

    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.6%

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

    if 5.2e17 < 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 re around 0 68.3%

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

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

      \[\leadsto re + 0.5 \cdot \left(\color{blue}{-28} \cdot re\right) \]
    8. Step-by-step derivation
      1. flip-+1.5%

        \[\leadsto \color{blue}{\frac{re \cdot re - \left(0.5 \cdot \left(-28 \cdot re\right)\right) \cdot \left(0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)}} \]
      2. difference-of-squares11.5%

        \[\leadsto \frac{\color{blue}{\left(re + 0.5 \cdot \left(-28 \cdot re\right)\right) \cdot \left(re - 0.5 \cdot \left(-28 \cdot re\right)\right)}}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      3. *-un-lft-identity11.5%

        \[\leadsto \frac{\left(\color{blue}{1 \cdot re} + 0.5 \cdot \left(-28 \cdot re\right)\right) \cdot \left(re - 0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      4. associate-*r*11.5%

        \[\leadsto \frac{\left(1 \cdot re + \color{blue}{\left(0.5 \cdot -28\right) \cdot re}\right) \cdot \left(re - 0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      5. distribute-rgt-out11.5%

        \[\leadsto \frac{\color{blue}{\left(re \cdot \left(1 + 0.5 \cdot -28\right)\right)} \cdot \left(re - 0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      6. metadata-eval11.5%

        \[\leadsto \frac{\left(re \cdot \left(1 + \color{blue}{-14}\right)\right) \cdot \left(re - 0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      7. metadata-eval11.5%

        \[\leadsto \frac{\left(re \cdot \color{blue}{-13}\right) \cdot \left(re - 0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      8. *-un-lft-identity11.5%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(\color{blue}{1 \cdot re} - 0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      9. associate-*r*11.5%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(1 \cdot re - \color{blue}{\left(0.5 \cdot -28\right) \cdot re}\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      10. distribute-rgt-out--11.5%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \color{blue}{\left(re \cdot \left(1 - 0.5 \cdot -28\right)\right)}}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      11. metadata-eval11.5%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot \left(1 - \color{blue}{-14}\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      12. metadata-eval11.5%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot \color{blue}{15}\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      13. *-un-lft-identity11.5%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{\color{blue}{1 \cdot re} - 0.5 \cdot \left(-28 \cdot re\right)} \]
      14. associate-*r*11.5%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{1 \cdot re - \color{blue}{\left(0.5 \cdot -28\right) \cdot re}} \]
      15. distribute-rgt-out--11.5%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{\color{blue}{re \cdot \left(1 - 0.5 \cdot -28\right)}} \]
      16. metadata-eval11.5%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{re \cdot \left(1 - \color{blue}{-14}\right)} \]
      17. metadata-eval11.5%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{re \cdot \color{blue}{15}} \]
    9. Applied egg-rr11.5%

      \[\leadsto \color{blue}{\frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{re \cdot 15}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 28.6% accurate, 19.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 3.15:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{re \cdot 15}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 3.15) re (/ (* (* re -13.0) (* re 15.0)) (* re 15.0))))
double code(double re, double im) {
	double tmp;
	if (re <= 3.15) {
		tmp = re;
	} else {
		tmp = ((re * -13.0) * (re * 15.0)) / (re * 15.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 3.15d0) then
        tmp = re
    else
        tmp = ((re * (-13.0d0)) * (re * 15.0d0)) / (re * 15.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 3.15) {
		tmp = re;
	} else {
		tmp = ((re * -13.0) * (re * 15.0)) / (re * 15.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 3.15:
		tmp = re
	else:
		tmp = ((re * -13.0) * (re * 15.0)) / (re * 15.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 3.15)
		tmp = re;
	else
		tmp = Float64(Float64(Float64(re * -13.0) * Float64(re * 15.0)) / Float64(re * 15.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 3.15)
		tmp = re;
	else
		tmp = ((re * -13.0) * (re * 15.0)) / (re * 15.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 3.15], re, N[(N[(N[(re * -13.0), $MachinePrecision] * N[(re * 15.0), $MachinePrecision]), $MachinePrecision] / N[(re * 15.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.15:\\
\;\;\;\;re\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{re \cdot 15}\\


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

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

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

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

    if 3.14999999999999991 < 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 re around 0 26.2%

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

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

      \[\leadsto re + 0.5 \cdot \left(\color{blue}{-28} \cdot re\right) \]
    8. Step-by-step derivation
      1. flip-+2.1%

        \[\leadsto \color{blue}{\frac{re \cdot re - \left(0.5 \cdot \left(-28 \cdot re\right)\right) \cdot \left(0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)}} \]
      2. difference-of-squares7.7%

        \[\leadsto \frac{\color{blue}{\left(re + 0.5 \cdot \left(-28 \cdot re\right)\right) \cdot \left(re - 0.5 \cdot \left(-28 \cdot re\right)\right)}}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      3. *-un-lft-identity7.7%

        \[\leadsto \frac{\left(\color{blue}{1 \cdot re} + 0.5 \cdot \left(-28 \cdot re\right)\right) \cdot \left(re - 0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      4. associate-*r*7.7%

        \[\leadsto \frac{\left(1 \cdot re + \color{blue}{\left(0.5 \cdot -28\right) \cdot re}\right) \cdot \left(re - 0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      5. distribute-rgt-out7.7%

        \[\leadsto \frac{\color{blue}{\left(re \cdot \left(1 + 0.5 \cdot -28\right)\right)} \cdot \left(re - 0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      6. metadata-eval7.7%

        \[\leadsto \frac{\left(re \cdot \left(1 + \color{blue}{-14}\right)\right) \cdot \left(re - 0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      7. metadata-eval7.7%

        \[\leadsto \frac{\left(re \cdot \color{blue}{-13}\right) \cdot \left(re - 0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      8. *-un-lft-identity7.7%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(\color{blue}{1 \cdot re} - 0.5 \cdot \left(-28 \cdot re\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      9. associate-*r*7.7%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(1 \cdot re - \color{blue}{\left(0.5 \cdot -28\right) \cdot re}\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      10. distribute-rgt-out--7.7%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \color{blue}{\left(re \cdot \left(1 - 0.5 \cdot -28\right)\right)}}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      11. metadata-eval7.7%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot \left(1 - \color{blue}{-14}\right)\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      12. metadata-eval7.7%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot \color{blue}{15}\right)}{re - 0.5 \cdot \left(-28 \cdot re\right)} \]
      13. *-un-lft-identity7.7%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{\color{blue}{1 \cdot re} - 0.5 \cdot \left(-28 \cdot re\right)} \]
      14. associate-*r*7.7%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{1 \cdot re - \color{blue}{\left(0.5 \cdot -28\right) \cdot re}} \]
      15. distribute-rgt-out--7.7%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{\color{blue}{re \cdot \left(1 - 0.5 \cdot -28\right)}} \]
      16. metadata-eval7.7%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{re \cdot \left(1 - \color{blue}{-14}\right)} \]
      17. metadata-eval7.7%

        \[\leadsto \frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{re \cdot \color{blue}{15}} \]
    9. Applied egg-rr7.7%

      \[\leadsto \color{blue}{\frac{\left(re \cdot -13\right) \cdot \left(re \cdot 15\right)}{re \cdot 15}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 26.4% accurate, 51.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 1.45 \cdot 10^{-15}:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (re im) :precision binary64 (if (<= re 1.45e-15) re 1.0))
double code(double re, double im) {
	double tmp;
	if (re <= 1.45e-15) {
		tmp = re;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 1.45d-15) then
        tmp = re
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 1.45e-15) {
		tmp = re;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 1.45e-15:
		tmp = re
	else:
		tmp = 1.0
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 1.45e-15)
		tmp = re;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 1.45e-15)
		tmp = re;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 1.45e-15], re, 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.45 \cdot 10^{-15}:\\
\;\;\;\;re\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 1.45000000000000009e-15

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

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

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

    if 1.45000000000000009e-15 < 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 90.2%

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

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

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

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

        \[\leadsto \mathsf{fma}\left({im}^{2}, \color{blue}{\sin re \cdot \left(0.041666666666666664 \cdot {im}^{2} + 0.5\right)}, \sin re\right) \]
      5. *-commutative90.2%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left({im}^{2}, \sin re \cdot \left({im}^{2} \cdot 0.041666666666666664 + 0.5\right), \sin re\right)} \]
    8. Applied egg-rr7.2%

      \[\leadsto \color{blue}{\frac{\sin re}{\sin re + \left(\sin re - \sin re\right)}} \]
    9. Step-by-step derivation
      1. +-inverses7.2%

        \[\leadsto \frac{\sin re}{\sin re + \color{blue}{0}} \]
      2. +-rgt-identity7.2%

        \[\leadsto \frac{\sin re}{\color{blue}{\sin re}} \]
      3. *-inverses7.2%

        \[\leadsto \color{blue}{1} \]
    10. Simplified7.2%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 14: 4.8% accurate, 309.0× speedup?

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

\\
1
\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 84.4%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left({im}^{2}, \sin re \cdot \left({im}^{2} \cdot 0.041666666666666664 + 0.5\right), \sin re\right)} \]
  8. Applied egg-rr4.5%

    \[\leadsto \color{blue}{\frac{\sin re}{\sin re + \left(\sin re - \sin re\right)}} \]
  9. Step-by-step derivation
    1. +-inverses4.5%

      \[\leadsto \frac{\sin re}{\sin re + \color{blue}{0}} \]
    2. +-rgt-identity4.5%

      \[\leadsto \frac{\sin re}{\color{blue}{\sin re}} \]
    3. *-inverses4.5%

      \[\leadsto \color{blue}{1} \]
  10. Simplified4.5%

    \[\leadsto \color{blue}{1} \]
  11. Add Preprocessing

Reproduce

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