math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 7.3s
Alternatives: 10
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 10 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. Final simplification100.0%

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

Alternative 2: 64.5% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := {\sin re}^{-2}\\
\mathbf{if}\;im \leq 700:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 1.52 \cdot 10^{+85}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;im \leq 2.9 \cdot 10^{+147}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot {im}^{2}\\

\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if 700 < im < 1.52e85 or 2.8999999999999998e147 < im < 1.35000000000000003e154

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re} \]
    9. Applied egg-rr8.6%

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

    if 1.52e85 < im < 2.8999999999999998e147

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35000000000000003e154 < 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 \color{blue}{\left(2 + {im}^{2}\right)} \]
    6. Step-by-step derivation
      1. +-commutative100.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot {im}^{2}\right) \cdot \sin re} \]
      2. *-commutative100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 700:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.52 \cdot 10^{+85}:\\ \;\;\;\;{\sin re}^{-2}\\ \mathbf{elif}\;im \leq 2.9 \cdot 10^{+147}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot {im}^{2}\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;{\sin re}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 77.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\sin re}^{-2}\\ \mathbf{if}\;im \leq 8000:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+85}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq 4.5 \cdot 10^{+146}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot {im}^{2}\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (pow (sin re) -2.0)))
   (if (<= im 8000.0)
     (* (* 0.5 (sin re)) (fma im im 2.0))
     (if (<= im 1.6e+85)
       t_0
       (if (<= im 4.5e+146)
         (* (* 0.5 re) (pow im 2.0))
         (if (<= im 1.35e+154) t_0 (* (sin re) (* 0.5 (pow im 2.0)))))))))
double code(double re, double im) {
	double t_0 = pow(sin(re), -2.0);
	double tmp;
	if (im <= 8000.0) {
		tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
	} else if (im <= 1.6e+85) {
		tmp = t_0;
	} else if (im <= 4.5e+146) {
		tmp = (0.5 * re) * pow(im, 2.0);
	} else if (im <= 1.35e+154) {
		tmp = t_0;
	} else {
		tmp = sin(re) * (0.5 * pow(im, 2.0));
	}
	return tmp;
}
function code(re, im)
	t_0 = sin(re) ^ -2.0
	tmp = 0.0
	if (im <= 8000.0)
		tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0));
	elseif (im <= 1.6e+85)
		tmp = t_0;
	elseif (im <= 4.5e+146)
		tmp = Float64(Float64(0.5 * re) * (im ^ 2.0));
	elseif (im <= 1.35e+154)
		tmp = t_0;
	else
		tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0)));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[Power[N[Sin[re], $MachinePrecision], -2.0], $MachinePrecision]}, If[LessEqual[im, 8000.0], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.6e+85], t$95$0, If[LessEqual[im, 4.5e+146], N[(N[(0.5 * re), $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], t$95$0, N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 1.6 \cdot 10^{+85}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;im \leq 4.5 \cdot 10^{+146}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot {im}^{2}\\

\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t\_0\\

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


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

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

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

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

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

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

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

    if 8e3 < im < 1.60000000000000009e85 or 4.50000000000000026e146 < im < 1.35000000000000003e154

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re} \]
    9. Applied egg-rr8.6%

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

    if 1.60000000000000009e85 < im < 4.50000000000000026e146

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35000000000000003e154 < 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 \color{blue}{\left(2 + {im}^{2}\right)} \]
    6. Step-by-step derivation
      1. +-commutative100.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot {im}^{2}\right) \cdot \sin re} \]
      2. *-commutative100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 8000:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+85}:\\ \;\;\;\;{\sin re}^{-2}\\ \mathbf{elif}\;im \leq 4.5 \cdot 10^{+146}:\\ \;\;\;\;\left(0.5 \cdot re\right) \cdot {im}^{2}\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;{\sin re}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 84.2% accurate, 1.4× speedup?

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

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

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

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


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

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

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

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

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

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

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

    if 0.0400000000000000008 < im < 1.35000000000000003e154

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

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

    if 1.35000000000000003e154 < 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 \color{blue}{\left(2 + {im}^{2}\right)} \]
    6. Step-by-step derivation
      1. +-commutative100.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(0.5 \cdot {im}^{2}\right) \cdot \sin re} \]
      2. *-commutative100.0%

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

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

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

Alternative 5: 61.1% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;im \leq 1.52 \cdot 10^{+85}:\\
\;\;\;\;{\sin re}^{-2}\\

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


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

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

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

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

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

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

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

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

    if 550 < im < 1.52e85

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin re} \]
    9. Applied egg-rr9.7%

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

    if 1.52e85 < 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 71.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 61.1% accurate, 2.6× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

    if 1.1e12 < im < 1.5e85

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

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

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

        \[\leadsto \left(0.5 \cdot \left(re \cdot \left(1 + -0.16666666666666666 \cdot \color{blue}{\left(re \cdot re\right)}\right)\right)\right) \cdot 2 \]
    8. Applied egg-rr24.6%

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

    if 1.5e85 < 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 71.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 61.1% accurate, 2.7× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

    if 1.1e12 < im < 1.60000000000000009e85

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

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

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

        \[\leadsto \left(0.5 \cdot \left(re \cdot \left(1 + -0.16666666666666666 \cdot \color{blue}{\left(re \cdot re\right)}\right)\right)\right) \cdot 2 \]
    8. Applied egg-rr24.6%

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

    if 1.60000000000000009e85 < 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 71.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 54.1% accurate, 2.9× speedup?

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

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

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


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

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

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

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

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

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

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

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

    if 1.1e12 < 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 2.8%

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

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

        \[\leadsto \left(0.5 \cdot \left(re \cdot \left(1 + -0.16666666666666666 \cdot \color{blue}{\left(re \cdot re\right)}\right)\right)\right) \cdot 2 \]
    8. Applied egg-rr12.3%

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

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

Alternative 9: 33.9% accurate, 23.8× speedup?

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

\\
2 \cdot \left(0.5 \cdot \left(re \cdot \left(1 + -0.16666666666666666 \cdot \left(re \cdot re\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 54.3%

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

    \[\leadsto \left(0.5 \cdot \color{blue}{\left(re \cdot \left(1 + -0.16666666666666666 \cdot {re}^{2}\right)\right)}\right) \cdot 2 \]
  7. Step-by-step derivation
    1. unpow235.4%

      \[\leadsto \left(0.5 \cdot \left(re \cdot \left(1 + -0.16666666666666666 \cdot \color{blue}{\left(re \cdot re\right)}\right)\right)\right) \cdot 2 \]
  8. Applied egg-rr35.4%

    \[\leadsto \left(0.5 \cdot \left(re \cdot \left(1 + -0.16666666666666666 \cdot \color{blue}{\left(re \cdot re\right)}\right)\right)\right) \cdot 2 \]
  9. Final simplification35.4%

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

Alternative 10: 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 76.5%

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

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

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

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

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

    \[\leadsto \color{blue}{\sin re} \]
  9. Taylor expanded in re around 0 30.1%

    \[\leadsto \color{blue}{re} \]
  10. Final simplification30.1%

    \[\leadsto re \]
  11. 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))))