math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 12.1s
Alternatives: 18
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 18 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: 74.9% 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 76.3%

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

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

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

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

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

Alternative 3: 74.0% 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 76.3%

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

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

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

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

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

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

Alternative 4: 72.2% accurate, 2.3× speedup?

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

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

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

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


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

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

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

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

    if 1.8500000000000001 < im < 1.01999999999999991e103

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.01999999999999991e103 < 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)} \]
    10. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

Alternative 5: 89.6% accurate, 2.3× speedup?

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

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

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

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


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

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

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

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

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

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

    if 1.8500000000000001 < im < 1.01999999999999991e103

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.01999999999999991e103 < 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)} \]
    10. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

Alternative 6: 71.8% 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 0.041:\\ \;\;\;\;t\_0 \cdot \left(\left(1 - im\right) + \left(1 + t\_1\right)\right)\\ \mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{im} + \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(2 + t\_1\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 0.041)
     (* t_0 (+ (- 1.0 im) (+ 1.0 t_1)))
     (if (<= im 1.02e+103)
       (*
        (* 0.5 re)
        (+
         (exp im)
         (+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
       (* t_0 (+ 2.0 t_1))))))
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 <= 0.041) {
		tmp = t_0 * ((1.0 - im) + (1.0 + t_1));
	} else if (im <= 1.02e+103) {
		tmp = (0.5 * re) * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
	} else {
		tmp = t_0 * (2.0 + t_1);
	}
	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 <= 0.041d0) then
        tmp = t_0 * ((1.0d0 - im) + (1.0d0 + t_1))
    else if (im <= 1.02d+103) then
        tmp = (0.5d0 * re) * (exp(im) + (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
    else
        tmp = t_0 * (2.0d0 + t_1)
    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 <= 0.041) {
		tmp = t_0 * ((1.0 - im) + (1.0 + t_1));
	} else if (im <= 1.02e+103) {
		tmp = (0.5 * re) * (Math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
	} else {
		tmp = t_0 * (2.0 + t_1);
	}
	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 <= 0.041:
		tmp = t_0 * ((1.0 - im) + (1.0 + t_1))
	elif im <= 1.02e+103:
		tmp = (0.5 * re) * (math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))))
	else:
		tmp = t_0 * (2.0 + t_1)
	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 <= 0.041)
		tmp = Float64(t_0 * Float64(Float64(1.0 - im) + Float64(1.0 + t_1)));
	elseif (im <= 1.02e+103)
		tmp = Float64(Float64(0.5 * re) * Float64(exp(im) + Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0)))));
	else
		tmp = Float64(t_0 * Float64(2.0 + t_1));
	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 <= 0.041)
		tmp = t_0 * ((1.0 - im) + (1.0 + t_1));
	elseif (im <= 1.02e+103)
		tmp = (0.5 * re) * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
	else
		tmp = t_0 * (2.0 + t_1);
	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, 0.041], N[(t$95$0 * N[(N[(1.0 - im), $MachinePrecision] + N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.02e+103], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(2.0 + t$95$1), $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 0.041:\\
\;\;\;\;t\_0 \cdot \left(\left(1 - im\right) + \left(1 + t\_1\right)\right)\\

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

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


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

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

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

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

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

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

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

    if 0.0410000000000000017 < im < 1.01999999999999991e103

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.01999999999999991e103 < 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)} \]
    10. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

Alternative 7: 85.1% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq 1.85:\\
\;\;\;\;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 1.02 \cdot 10^{+103}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{im} + \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\right)\\

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


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

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

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

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

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

      \[\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 83.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) \]
    9. Step-by-step derivation
      1. *-commutative87.3%

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

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

    if 1.8500000000000001 < im < 1.01999999999999991e103

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.01999999999999991e103 < 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)} \]
    10. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

Alternative 8: 85.1% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq 1.85:\\
\;\;\;\;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 1.02 \cdot 10^{+103}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{im} + \left(1 + im \cdot \left(0.5 \cdot im + -1\right)\right)\right)\\

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


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

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

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

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

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

      \[\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 83.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) \]
    9. Step-by-step derivation
      1. *-commutative87.3%

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

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

    if 1.8500000000000001 < im < 1.01999999999999991e103

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.01999999999999991e103 < 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)} \]
    10. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

Alternative 9: 72.4% accurate, 2.4× speedup?

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

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

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

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


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

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

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

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

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

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

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

    if 1.8500000000000001 < im < 1.01999999999999991e103

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.01999999999999991e103 < 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)} \]
    10. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

Alternative 10: 67.8% accurate, 2.6× speedup?

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

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

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


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

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

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

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

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

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

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

    if 1.8500000000000001 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 67.8% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 1.82:\\ \;\;\;\;\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 1.82) (sin re) (* (+ (exp im) 1.0) (* 0.5 re))))
double code(double re, double im) {
	double tmp;
	if (im <= 1.82) {
		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 <= 1.82d0) 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 <= 1.82) {
		tmp = Math.sin(re);
	} else {
		tmp = (Math.exp(im) + 1.0) * (0.5 * re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 1.82:
		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 <= 1.82)
		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 <= 1.82)
		tmp = sin(re);
	else
		tmp = (exp(im) + 1.0) * (0.5 * re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 1.82], 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 1.82:\\
\;\;\;\;\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 < 1.82000000000000006

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

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

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

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

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

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

    if 1.82000000000000006 < 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 98.7%

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

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

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

      \[\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 79.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*79.7%

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

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

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

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

      \[\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 12: 63.2% accurate, 2.9× speedup?

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

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

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


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

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

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

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

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

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

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

    if 1.8500000000000001 < 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 98.7%

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

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

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

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

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

      \[\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. Step-by-step derivation
      1. *-commutative70.8%

        \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot 0.16666666666666666}\right)\right)\right) \]
    11. Simplified70.8%

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

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

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

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

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

Alternative 13: 40.9% accurate, 11.4× speedup?

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

\\
\left(0.5 \cdot re\right) \cdot \left(\left(1 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) + \left(1 + im \cdot \left(0.5 \cdot im + -1\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 74.3%

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

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

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

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

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

    \[\leadsto \left(re \cdot 0.5\right) \cdot \left(\left(1 + \color{blue}{im \cdot \left(0.5 \cdot im - 1\right)}\right) + \left(1 + im \cdot \left(1 + im \cdot \left(0.5 + 0.16666666666666666 \cdot im\right)\right)\right)\right) \]
  11. Final simplification44.9%

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

Alternative 14: 44.0% 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 76.3%

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

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

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

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

    \[\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*51.4%

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

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

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

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

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

    \[\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. Final simplification47.6%

    \[\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) \]
  13. Add Preprocessing

Alternative 15: 43.7% accurate, 18.2× speedup?

\[\begin{array}{l} \\ \left(0.5 \cdot re\right) \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (*
  (* 0.5 re)
  (+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))
double code(double re, double im) {
	return (0.5 * re) * (2.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) * (2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end function
public static double code(double re, double im) {
	return (0.5 * re) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
def code(re, im):
	return (0.5 * re) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))
function code(re, im)
	return Float64(Float64(0.5 * re) * Float64(2.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) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(0.5 \cdot re\right) \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\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 76.3%

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

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

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

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

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

    \[\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. Step-by-step derivation
    1. *-commutative68.7%

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot 0.16666666666666666}\right)\right)\right) \]
  11. Simplified68.7%

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

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

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

    \[\leadsto \color{blue}{\left(re \cdot 0.5\right)} \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) \]
  15. Final simplification47.4%

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

Alternative 16: 29.1% accurate, 30.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 5.3 \cdot 10^{+91}:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(im \cdot -0.5\right)\\ \end{array} \end{array} \]
(FPCore (re im) :precision binary64 (if (<= re 5.3e+91) re (* re (* im -0.5))))
double code(double re, double im) {
	double tmp;
	if (re <= 5.3e+91) {
		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 <= 5.3d+91) 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 <= 5.3e+91) {
		tmp = re;
	} else {
		tmp = re * (im * -0.5);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 5.3e+91:
		tmp = re
	else:
		tmp = re * (im * -0.5)
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 5.3e+91)
		tmp = re;
	else
		tmp = Float64(re * Float64(im * -0.5));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 5.3e+91)
		tmp = re;
	else
		tmp = re * (im * -0.5);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 5.3e+91], re, N[(re * N[(im * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

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

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

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

    if 5.29999999999999997e91 < 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 69.6%

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

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

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

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

      \[\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*33.4%

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

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

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

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

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

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

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

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

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

Alternative 17: 32.0% accurate, 34.3× speedup?

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

\\
\left(0.5 \cdot re\right) \cdot \left(1 + \left(im + 1\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 76.3%

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

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

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

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

    \[\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*51.4%

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

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

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

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

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

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

    \[\leadsto \left(\left(1 + im\right) + \color{blue}{1}\right) \cdot \left(0.5 \cdot re\right) \]
  13. Final simplification34.9%

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

Alternative 18: 26.3% 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 54.3%

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

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

Reproduce

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