math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 7.8s
Alternatives: 19
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 19 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.4% accurate, 1.4× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

    if 6 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(e^{im} + \color{blue}{1}\right) \cdot \left(0.5 \cdot re\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 90.9%

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

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

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

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

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

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

      \[\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)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification78.2%

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

Alternative 3: 75.0% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 73.9% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 71.9% accurate, 2.4× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(t\_1 + 2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 4.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 72.4%

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

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

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

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

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

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

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

    if 4.5 < im < 1e103

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e103 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 85.3% accurate, 2.4× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.20000000000000018 < im < 1e103

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e103 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 72.6% accurate, 2.4× speedup?

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

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

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

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


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

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

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

    if 4.4000000000000004 < im < 1e103

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e103 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 71.6% accurate, 2.5× speedup?

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

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

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


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

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

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

    if 6.4000000000000004 < 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. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(e^{im} + \color{blue}{1}\right) \cdot \left(0.5 \cdot re\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. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

Alternative 9: 68.5% accurate, 2.8× speedup?

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

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

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


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

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

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

    if 4.79999999999999982 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 63.9% accurate, 2.9× speedup?

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

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

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


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

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

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

    if 1.02000000000000003e-8 < 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 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 44.1% accurate, 14.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 44.1% accurate, 16.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 43.9% accurate, 18.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 47.8% accurate, 20.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 47.5% accurate, 23.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 29.5% accurate, 30.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.05 \cdot 10^{+107}:\\
\;\;\;\;re\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.05e107 < 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 85.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(re \cdot im\right)} \cdot -0.5 \]
    13. Simplified7.4%

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

Alternative 17: 32.5% accurate, 34.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 18: 26.8% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{re} \]
  12. Add Preprocessing

Alternative 19: 3.0% accurate, 309.0× speedup?

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

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

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

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

    \[\leadsto \color{blue}{\log \left({1}^{\sin re}\right)} \]
  6. Step-by-step derivation
    1. pow-base-12.8%

      \[\leadsto \log \color{blue}{1} \]
    2. metadata-eval2.8%

      \[\leadsto \color{blue}{0} \]
  7. Simplified2.8%

    \[\leadsto \color{blue}{0} \]
  8. Add Preprocessing

Reproduce

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