math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 10.0s
Alternatives: 20
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 20 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: 63.4% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -0.16666666666666666\right)\right)\\ t_1 := 0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+19}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+61}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+208}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;im \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot {re}^{2}\right)\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+239}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;im \leq 6.6 \cdot 10^{+252} \lor \neg \left(im \leq 6.6 \cdot 10^{+273}\right):\\ \;\;\;\;t\_0\\ \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
 (let* ((t_0 (log1p (expm1 (* re -0.16666666666666666))))
        (t_1 (* 0.041666666666666664 (* re (pow im 4.0)))))
   (if (<= im 2.6e-15)
     (sin re)
     (if (<= im 3.3e+19)
       (log1p (expm1 re))
       (if (<= im 3.3e+61)
         t_0
         (if (<= im 2.7e+208)
           t_1
           (if (<= im 1.58e+227)
             (* re (+ 1.0 (* -0.16666666666666666 (pow re 2.0))))
             (if (<= im 6.5e+239)
               t_1
               (if (or (<= im 6.6e+252) (not (<= im 6.6e+273)))
                 t_0
                 (* (fma im im 2.0) (* 0.5 re)))))))))))
double code(double re, double im) {
	double t_0 = log1p(expm1((re * -0.16666666666666666)));
	double t_1 = 0.041666666666666664 * (re * pow(im, 4.0));
	double tmp;
	if (im <= 2.6e-15) {
		tmp = sin(re);
	} else if (im <= 3.3e+19) {
		tmp = log1p(expm1(re));
	} else if (im <= 3.3e+61) {
		tmp = t_0;
	} else if (im <= 2.7e+208) {
		tmp = t_1;
	} else if (im <= 1.58e+227) {
		tmp = re * (1.0 + (-0.16666666666666666 * pow(re, 2.0)));
	} else if (im <= 6.5e+239) {
		tmp = t_1;
	} else if ((im <= 6.6e+252) || !(im <= 6.6e+273)) {
		tmp = t_0;
	} else {
		tmp = fma(im, im, 2.0) * (0.5 * re);
	}
	return tmp;
}
function code(re, im)
	t_0 = log1p(expm1(Float64(re * -0.16666666666666666)))
	t_1 = Float64(0.041666666666666664 * Float64(re * (im ^ 4.0)))
	tmp = 0.0
	if (im <= 2.6e-15)
		tmp = sin(re);
	elseif (im <= 3.3e+19)
		tmp = log1p(expm1(re));
	elseif (im <= 3.3e+61)
		tmp = t_0;
	elseif (im <= 2.7e+208)
		tmp = t_1;
	elseif (im <= 1.58e+227)
		tmp = Float64(re * Float64(1.0 + Float64(-0.16666666666666666 * (re ^ 2.0))));
	elseif (im <= 6.5e+239)
		tmp = t_1;
	elseif ((im <= 6.6e+252) || !(im <= 6.6e+273))
		tmp = t_0;
	else
		tmp = Float64(fma(im, im, 2.0) * Float64(0.5 * re));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[Log[1 + N[(Exp[N[(re * -0.16666666666666666), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(0.041666666666666664 * N[(re * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 2.6e-15], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.3e+19], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 3.3e+61], t$95$0, If[LessEqual[im, 2.7e+208], t$95$1, If[LessEqual[im, 1.58e+227], N[(re * N[(1.0 + N[(-0.16666666666666666 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.5e+239], t$95$1, If[Or[LessEqual[im, 6.6e+252], N[Not[LessEqual[im, 6.6e+273]], $MachinePrecision]], t$95$0, N[(N[(im * im + 2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -0.16666666666666666\right)\right)\\
t_1 := 0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\
\mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 3.3 \cdot 10^{+19}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\

\mathbf{elif}\;im \leq 3.3 \cdot 10^{+61}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;im \leq 2.7 \cdot 10^{+208}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;im \leq 6.5 \cdot 10^{+239}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;im \leq 6.6 \cdot 10^{+252} \lor \neg \left(im \leq 6.6 \cdot 10^{+273}\right):\\
\;\;\;\;t\_0\\

\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 6 regimes
  2. if im < 2.60000000000000004e-15

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 2.60000000000000004e-15 < im < 3.3e19

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    6. Applied egg-rr44.3%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]

    if 3.3e19 < im < 3.2999999999999998e61 or 6.5e239 < im < 6.6000000000000002e252 or 6.59999999999999971e273 < 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.9%

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

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

        \[\leadsto re \cdot \color{blue}{\left(-0.16666666666666666 \cdot {re}^{2} + 1\right)} \]
      2. distribute-rgt-in54.7%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {re}^{2}\right) \cdot re + 1 \cdot re} \]
      3. *-lft-identity54.7%

        \[\leadsto \left(-0.16666666666666666 \cdot {re}^{2}\right) \cdot re + \color{blue}{re} \]
      4. associate-*l*54.7%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({re}^{2} \cdot re\right)} + re \]
      5. fma-define54.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {re}^{2} \cdot re, re\right)} \]
      6. pow-plus54.7%

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, \color{blue}{{re}^{\left(2 + 1\right)}}, re\right) \]
      7. metadata-eval54.7%

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, {re}^{\color{blue}{3}}, re\right) \]
    8. Simplified54.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {re}^{3}, re\right)} \]
    9. Taylor expanded in re around inf 54.3%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {re}^{3}} \]
    10. Applied egg-rr65.0%

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

    if 3.2999999999999998e61 < im < 2.7e208 or 1.57999999999999994e227 < im < 6.5e239

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left({im}^{4} \cdot \sin re\right)} \]
    9. Taylor expanded in re around 0 69.0%

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

    if 2.7e208 < im < 1.57999999999999994e227

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

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

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

        \[\leadsto re \cdot \left(1 + \color{blue}{{re}^{2} \cdot -0.16666666666666666}\right) \]
    8. Simplified60.9%

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

    if 6.6000000000000002e252 < im < 6.59999999999999971e273

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+19}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 3.3 \cdot 10^{+61}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -0.16666666666666666\right)\right)\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+208}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{elif}\;im \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot {re}^{2}\right)\\ \mathbf{elif}\;im \leq 6.5 \cdot 10^{+239}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{elif}\;im \leq 6.6 \cdot 10^{+252} \lor \neg \left(im \leq 6.6 \cdot 10^{+273}\right):\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 83.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.2:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 2.75 \cdot 10^{+26}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+62}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 0.2)
   (* (* 0.5 (sin re)) (fma im im 2.0))
   (if (<= im 2.75e+26)
     (log1p (expm1 re))
     (if (<= im 1.15e+62)
       (log1p (expm1 (* re -0.16666666666666666)))
       (* 0.041666666666666664 (* (sin re) (pow im 4.0)))))))
double code(double re, double im) {
	double tmp;
	if (im <= 0.2) {
		tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
	} else if (im <= 2.75e+26) {
		tmp = log1p(expm1(re));
	} else if (im <= 1.15e+62) {
		tmp = log1p(expm1((re * -0.16666666666666666)));
	} else {
		tmp = 0.041666666666666664 * (sin(re) * pow(im, 4.0));
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 0.2)
		tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0));
	elseif (im <= 2.75e+26)
		tmp = log1p(expm1(re));
	elseif (im <= 1.15e+62)
		tmp = log1p(expm1(Float64(re * -0.16666666666666666)));
	else
		tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0)));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 0.2], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 2.75e+26], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 1.15e+62], N[Log[1 + N[(Exp[N[(re * -0.16666666666666666), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], N[(0.041666666666666664 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 2.75 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\

\mathbf{elif}\;im \leq 1.15 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -0.16666666666666666\right)\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.20000000000000001 < im < 2.7499999999999998e26

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]

    if 2.7499999999999998e26 < im < 1.14999999999999992e62

    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 \color{blue}{\sin re} \]
    6. Taylor expanded in re around 0 41.5%

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

        \[\leadsto re \cdot \color{blue}{\left(-0.16666666666666666 \cdot {re}^{2} + 1\right)} \]
      2. distribute-rgt-in41.5%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {re}^{2}\right) \cdot re + 1 \cdot re} \]
      3. *-lft-identity41.5%

        \[\leadsto \left(-0.16666666666666666 \cdot {re}^{2}\right) \cdot re + \color{blue}{re} \]
      4. associate-*l*41.5%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({re}^{2} \cdot re\right)} + re \]
      5. fma-define41.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {re}^{2} \cdot re, re\right)} \]
      6. pow-plus41.5%

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, \color{blue}{{re}^{\left(2 + 1\right)}}, re\right) \]
      7. metadata-eval41.5%

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, {re}^{\color{blue}{3}}, re\right) \]
    8. Simplified41.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {re}^{3}, re\right)} \]
    9. Taylor expanded in re around inf 41.0%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {re}^{3}} \]
    10. Applied egg-rr50.5%

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

    if 1.14999999999999992e62 < 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 92.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.2:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 2.75 \cdot 10^{+26}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+62}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 70.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+21}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+62}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 2.6e-15)
   (sin re)
   (if (<= im 1.1e+21)
     (log1p (expm1 re))
     (if (<= im 1.15e+62)
       (log1p (expm1 (* re -0.16666666666666666)))
       (* 0.041666666666666664 (* (sin re) (pow im 4.0)))))))
double code(double re, double im) {
	double tmp;
	if (im <= 2.6e-15) {
		tmp = sin(re);
	} else if (im <= 1.1e+21) {
		tmp = log1p(expm1(re));
	} else if (im <= 1.15e+62) {
		tmp = log1p(expm1((re * -0.16666666666666666)));
	} else {
		tmp = 0.041666666666666664 * (sin(re) * pow(im, 4.0));
	}
	return tmp;
}
public static double code(double re, double im) {
	double tmp;
	if (im <= 2.6e-15) {
		tmp = Math.sin(re);
	} else if (im <= 1.1e+21) {
		tmp = Math.log1p(Math.expm1(re));
	} else if (im <= 1.15e+62) {
		tmp = Math.log1p(Math.expm1((re * -0.16666666666666666)));
	} else {
		tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 2.6e-15:
		tmp = math.sin(re)
	elif im <= 1.1e+21:
		tmp = math.log1p(math.expm1(re))
	elif im <= 1.15e+62:
		tmp = math.log1p(math.expm1((re * -0.16666666666666666)))
	else:
		tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 2.6e-15)
		tmp = sin(re);
	elseif (im <= 1.1e+21)
		tmp = log1p(expm1(re));
	elseif (im <= 1.15e+62)
		tmp = log1p(expm1(Float64(re * -0.16666666666666666)));
	else
		tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0)));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 2.6e-15], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.1e+21], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 1.15e+62], N[Log[1 + N[(Exp[N[(re * -0.16666666666666666), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], N[(0.041666666666666664 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 1.1 \cdot 10^{+21}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\

\mathbf{elif}\;im \leq 1.15 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -0.16666666666666666\right)\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 2.60000000000000004e-15 < im < 1.1e21

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    6. Applied egg-rr44.3%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]

    if 1.1e21 < im < 1.14999999999999992e62

    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 \color{blue}{\sin re} \]
    6. Taylor expanded in re around 0 41.5%

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

        \[\leadsto re \cdot \color{blue}{\left(-0.16666666666666666 \cdot {re}^{2} + 1\right)} \]
      2. distribute-rgt-in41.5%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {re}^{2}\right) \cdot re + 1 \cdot re} \]
      3. *-lft-identity41.5%

        \[\leadsto \left(-0.16666666666666666 \cdot {re}^{2}\right) \cdot re + \color{blue}{re} \]
      4. associate-*l*41.5%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({re}^{2} \cdot re\right)} + re \]
      5. fma-define41.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {re}^{2} \cdot re, re\right)} \]
      6. pow-plus41.5%

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, \color{blue}{{re}^{\left(2 + 1\right)}}, re\right) \]
      7. metadata-eval41.5%

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, {re}^{\color{blue}{3}}, re\right) \]
    8. Simplified41.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {re}^{3}, re\right)} \]
    9. Taylor expanded in re around inf 41.0%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {re}^{3}} \]
    10. Applied egg-rr50.5%

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

    if 1.14999999999999992e62 < 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 92.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.1 \cdot 10^{+21}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+62}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re \cdot -0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 86.0% accurate, 1.4× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.101999999999999993 < im < 4.20000000000000011e66

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

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

    if 4.20000000000000011e66 < 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 92.5%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 65.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.9 \cdot 10^{+19}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 2.45 \cdot 10^{+67}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+208}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{elif}\;im \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot {re}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 2.6e-15)
   (sin re)
   (if (<= im 1.9e+19)
     (log1p (expm1 re))
     (if (<= im 2.45e+67)
       (pow re -4.0)
       (if (<= im 2.3e+208)
         (* 0.041666666666666664 (* re (pow im 4.0)))
         (if (<= im 1.58e+227)
           (* re (+ 1.0 (* -0.16666666666666666 (pow re 2.0))))
           (* 0.5 (* re (pow im 2.0)))))))))
double code(double re, double im) {
	double tmp;
	if (im <= 2.6e-15) {
		tmp = sin(re);
	} else if (im <= 1.9e+19) {
		tmp = log1p(expm1(re));
	} else if (im <= 2.45e+67) {
		tmp = pow(re, -4.0);
	} else if (im <= 2.3e+208) {
		tmp = 0.041666666666666664 * (re * pow(im, 4.0));
	} else if (im <= 1.58e+227) {
		tmp = re * (1.0 + (-0.16666666666666666 * pow(re, 2.0)));
	} else {
		tmp = 0.5 * (re * pow(im, 2.0));
	}
	return tmp;
}
public static double code(double re, double im) {
	double tmp;
	if (im <= 2.6e-15) {
		tmp = Math.sin(re);
	} else if (im <= 1.9e+19) {
		tmp = Math.log1p(Math.expm1(re));
	} else if (im <= 2.45e+67) {
		tmp = Math.pow(re, -4.0);
	} else if (im <= 2.3e+208) {
		tmp = 0.041666666666666664 * (re * Math.pow(im, 4.0));
	} else if (im <= 1.58e+227) {
		tmp = re * (1.0 + (-0.16666666666666666 * Math.pow(re, 2.0)));
	} else {
		tmp = 0.5 * (re * Math.pow(im, 2.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 2.6e-15:
		tmp = math.sin(re)
	elif im <= 1.9e+19:
		tmp = math.log1p(math.expm1(re))
	elif im <= 2.45e+67:
		tmp = math.pow(re, -4.0)
	elif im <= 2.3e+208:
		tmp = 0.041666666666666664 * (re * math.pow(im, 4.0))
	elif im <= 1.58e+227:
		tmp = re * (1.0 + (-0.16666666666666666 * math.pow(re, 2.0)))
	else:
		tmp = 0.5 * (re * math.pow(im, 2.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 2.6e-15)
		tmp = sin(re);
	elseif (im <= 1.9e+19)
		tmp = log1p(expm1(re));
	elseif (im <= 2.45e+67)
		tmp = re ^ -4.0;
	elseif (im <= 2.3e+208)
		tmp = Float64(0.041666666666666664 * Float64(re * (im ^ 4.0)));
	elseif (im <= 1.58e+227)
		tmp = Float64(re * Float64(1.0 + Float64(-0.16666666666666666 * (re ^ 2.0))));
	else
		tmp = Float64(0.5 * Float64(re * (im ^ 2.0)));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 2.6e-15], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.9e+19], N[Log[1 + N[(Exp[re] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[im, 2.45e+67], N[Power[re, -4.0], $MachinePrecision], If[LessEqual[im, 2.3e+208], N[(0.041666666666666664 * N[(re * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.58e+227], N[(re * N[(1.0 + N[(-0.16666666666666666 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 1.9 \cdot 10^{+19}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\

\mathbf{elif}\;im \leq 2.45 \cdot 10^{+67}:\\
\;\;\;\;{re}^{-4}\\

\mathbf{elif}\;im \leq 2.3 \cdot 10^{+208}:\\
\;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if im < 2.60000000000000004e-15

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 2.60000000000000004e-15 < im < 1.9e19

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    6. Applied egg-rr44.3%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]

    if 1.9e19 < im < 2.44999999999999995e67

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

      \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    6. Applied egg-rr21.5%

      \[\leadsto \color{blue}{{re}^{-4}} \]

    if 2.44999999999999995e67 < im < 2.3e208

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left({im}^{4} \cdot \sin re\right)} \]
    9. Taylor expanded in re around 0 64.6%

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

    if 2.3e208 < im < 1.57999999999999994e227

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

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

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

        \[\leadsto re \cdot \left(1 + \color{blue}{{re}^{2} \cdot -0.16666666666666666}\right) \]
    8. Simplified60.9%

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

    if 1.57999999999999994e227 < 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 64.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 2.6 \cdot 10^{-15}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.9 \cdot 10^{+19}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)\\ \mathbf{elif}\;im \leq 2.45 \cdot 10^{+67}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 2.3 \cdot 10^{+208}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{elif}\;im \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot {re}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 55.8% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.056:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.1 \cdot 10^{+83}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 9 \cdot 10^{+109}:\\ \;\;\;\;{re}^{6}\\ \mathbf{elif}\;im \leq 9.6 \cdot 10^{+144} \lor \neg \left(im \leq 4.5 \cdot 10^{+158}\right) \land \left(im \leq 6.8 \cdot 10^{+198} \lor \neg \left(im \leq 1.72 \cdot 10^{+227}\right) \land im \leq 1.85 \cdot 10^{+239}\right):\\ \;\;\;\;{re}^{-4}\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 0.056)
   (sin re)
   (if (<= im 3.1e+83)
     (pow re -4.0)
     (if (<= im 9e+109)
       (pow re 6.0)
       (if (or (<= im 9.6e+144)
               (and (not (<= im 4.5e+158))
                    (or (<= im 6.8e+198)
                        (and (not (<= im 1.72e+227)) (<= im 1.85e+239)))))
         (pow re -4.0)
         (* -0.16666666666666666 (pow re 3.0)))))))
double code(double re, double im) {
	double tmp;
	if (im <= 0.056) {
		tmp = sin(re);
	} else if (im <= 3.1e+83) {
		tmp = pow(re, -4.0);
	} else if (im <= 9e+109) {
		tmp = pow(re, 6.0);
	} else if ((im <= 9.6e+144) || (!(im <= 4.5e+158) && ((im <= 6.8e+198) || (!(im <= 1.72e+227) && (im <= 1.85e+239))))) {
		tmp = pow(re, -4.0);
	} else {
		tmp = -0.16666666666666666 * pow(re, 3.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 0.056d0) then
        tmp = sin(re)
    else if (im <= 3.1d+83) then
        tmp = re ** (-4.0d0)
    else if (im <= 9d+109) then
        tmp = re ** 6.0d0
    else if ((im <= 9.6d+144) .or. (.not. (im <= 4.5d+158)) .and. (im <= 6.8d+198) .or. (.not. (im <= 1.72d+227)) .and. (im <= 1.85d+239)) then
        tmp = re ** (-4.0d0)
    else
        tmp = (-0.16666666666666666d0) * (re ** 3.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 0.056) {
		tmp = Math.sin(re);
	} else if (im <= 3.1e+83) {
		tmp = Math.pow(re, -4.0);
	} else if (im <= 9e+109) {
		tmp = Math.pow(re, 6.0);
	} else if ((im <= 9.6e+144) || (!(im <= 4.5e+158) && ((im <= 6.8e+198) || (!(im <= 1.72e+227) && (im <= 1.85e+239))))) {
		tmp = Math.pow(re, -4.0);
	} else {
		tmp = -0.16666666666666666 * Math.pow(re, 3.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 0.056:
		tmp = math.sin(re)
	elif im <= 3.1e+83:
		tmp = math.pow(re, -4.0)
	elif im <= 9e+109:
		tmp = math.pow(re, 6.0)
	elif (im <= 9.6e+144) or (not (im <= 4.5e+158) and ((im <= 6.8e+198) or (not (im <= 1.72e+227) and (im <= 1.85e+239)))):
		tmp = math.pow(re, -4.0)
	else:
		tmp = -0.16666666666666666 * math.pow(re, 3.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 0.056)
		tmp = sin(re);
	elseif (im <= 3.1e+83)
		tmp = re ^ -4.0;
	elseif (im <= 9e+109)
		tmp = re ^ 6.0;
	elseif ((im <= 9.6e+144) || (!(im <= 4.5e+158) && ((im <= 6.8e+198) || (!(im <= 1.72e+227) && (im <= 1.85e+239)))))
		tmp = re ^ -4.0;
	else
		tmp = Float64(-0.16666666666666666 * (re ^ 3.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 0.056)
		tmp = sin(re);
	elseif (im <= 3.1e+83)
		tmp = re ^ -4.0;
	elseif (im <= 9e+109)
		tmp = re ^ 6.0;
	elseif ((im <= 9.6e+144) || (~((im <= 4.5e+158)) && ((im <= 6.8e+198) || (~((im <= 1.72e+227)) && (im <= 1.85e+239)))))
		tmp = re ^ -4.0;
	else
		tmp = -0.16666666666666666 * (re ^ 3.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 0.056], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.1e+83], N[Power[re, -4.0], $MachinePrecision], If[LessEqual[im, 9e+109], N[Power[re, 6.0], $MachinePrecision], If[Or[LessEqual[im, 9.6e+144], And[N[Not[LessEqual[im, 4.5e+158]], $MachinePrecision], Or[LessEqual[im, 6.8e+198], And[N[Not[LessEqual[im, 1.72e+227]], $MachinePrecision], LessEqual[im, 1.85e+239]]]]], N[Power[re, -4.0], $MachinePrecision], N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 3.1 \cdot 10^{+83}:\\
\;\;\;\;{re}^{-4}\\

\mathbf{elif}\;im \leq 9 \cdot 10^{+109}:\\
\;\;\;\;{re}^{6}\\

\mathbf{elif}\;im \leq 9.6 \cdot 10^{+144} \lor \neg \left(im \leq 4.5 \cdot 10^{+158}\right) \land \left(im \leq 6.8 \cdot 10^{+198} \lor \neg \left(im \leq 1.72 \cdot 10^{+227}\right) \land im \leq 1.85 \cdot 10^{+239}\right):\\
\;\;\;\;{re}^{-4}\\

\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\


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

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

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

    if 0.0560000000000000012 < im < 3.09999999999999992e83 or 8.9999999999999992e109 < im < 9.6000000000000002e144 or 4.50000000000000046e158 < im < 6.8000000000000001e198 or 1.71999999999999995e227 < im < 1.84999999999999999e239

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

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

      \[\leadsto \color{blue}{{re}^{-4}} \]

    if 3.09999999999999992e83 < im < 8.9999999999999992e109

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]
    7. Applied egg-rr50.0%

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

    if 9.6000000000000002e144 < im < 4.50000000000000046e158 or 6.8000000000000001e198 < im < 1.71999999999999995e227 or 1.84999999999999999e239 < 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 \color{blue}{\sin re} \]
    6. Taylor expanded in re around 0 40.6%

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

        \[\leadsto re \cdot \color{blue}{\left(-0.16666666666666666 \cdot {re}^{2} + 1\right)} \]
      2. distribute-rgt-in40.6%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {re}^{2}\right) \cdot re + 1 \cdot re} \]
      3. *-lft-identity40.6%

        \[\leadsto \left(-0.16666666666666666 \cdot {re}^{2}\right) \cdot re + \color{blue}{re} \]
      4. associate-*l*40.6%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({re}^{2} \cdot re\right)} + re \]
      5. fma-define40.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {re}^{2} \cdot re, re\right)} \]
      6. pow-plus40.6%

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, \color{blue}{{re}^{\left(2 + 1\right)}}, re\right) \]
      7. metadata-eval40.6%

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, {re}^{\color{blue}{3}}, re\right) \]
    8. Simplified40.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {re}^{3}, re\right)} \]
    9. Taylor expanded in re around inf 40.3%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {re}^{3}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification54.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.056:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.1 \cdot 10^{+83}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 9 \cdot 10^{+109}:\\ \;\;\;\;{re}^{6}\\ \mathbf{elif}\;im \leq 9.6 \cdot 10^{+144} \lor \neg \left(im \leq 4.5 \cdot 10^{+158}\right) \land \left(im \leq 6.8 \cdot 10^{+198} \lor \neg \left(im \leq 1.72 \cdot 10^{+227}\right) \land im \leq 1.85 \cdot 10^{+239}\right):\\ \;\;\;\;{re}^{-4}\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 65.2% accurate, 2.4× speedup?

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

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

\mathbf{elif}\;im \leq 1.7 \cdot 10^{+49}:\\
\;\;\;\;{re}^{-4}\\

\mathbf{elif}\;im \leq 2.7 \cdot 10^{+208}:\\
\;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\

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

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


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

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

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

    if 0.0560000000000000012 < im < 1.7e49

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

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

      \[\leadsto \color{blue}{{re}^{-4}} \]

    if 1.7e49 < im < 2.7e208

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left({im}^{4} \cdot \sin re\right)} \]
    9. Taylor expanded in re around 0 56.8%

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

    if 2.7e208 < im < 1.57999999999999994e227

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

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

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

        \[\leadsto re \cdot \left(1 + \color{blue}{{re}^{2} \cdot -0.16666666666666666}\right) \]
    8. Simplified60.9%

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

    if 1.57999999999999994e227 < 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 64.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.056:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+49}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+208}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{elif}\;im \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot {re}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 65.2% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.056:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+49}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+208} \lor \neg \left(im \leq 1.58 \cdot 10^{+227}\right):\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 0.056)
   (sin re)
   (if (<= im 1.7e+49)
     (pow re -4.0)
     (if (or (<= im 2.7e+208) (not (<= im 1.58e+227)))
       (* 0.041666666666666664 (* re (pow im 4.0)))
       (* -0.16666666666666666 (pow re 3.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 0.056) {
		tmp = sin(re);
	} else if (im <= 1.7e+49) {
		tmp = pow(re, -4.0);
	} else if ((im <= 2.7e+208) || !(im <= 1.58e+227)) {
		tmp = 0.041666666666666664 * (re * pow(im, 4.0));
	} else {
		tmp = -0.16666666666666666 * pow(re, 3.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 0.056d0) then
        tmp = sin(re)
    else if (im <= 1.7d+49) then
        tmp = re ** (-4.0d0)
    else if ((im <= 2.7d+208) .or. (.not. (im <= 1.58d+227))) then
        tmp = 0.041666666666666664d0 * (re * (im ** 4.0d0))
    else
        tmp = (-0.16666666666666666d0) * (re ** 3.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 0.056) {
		tmp = Math.sin(re);
	} else if (im <= 1.7e+49) {
		tmp = Math.pow(re, -4.0);
	} else if ((im <= 2.7e+208) || !(im <= 1.58e+227)) {
		tmp = 0.041666666666666664 * (re * Math.pow(im, 4.0));
	} else {
		tmp = -0.16666666666666666 * Math.pow(re, 3.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 0.056:
		tmp = math.sin(re)
	elif im <= 1.7e+49:
		tmp = math.pow(re, -4.0)
	elif (im <= 2.7e+208) or not (im <= 1.58e+227):
		tmp = 0.041666666666666664 * (re * math.pow(im, 4.0))
	else:
		tmp = -0.16666666666666666 * math.pow(re, 3.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 0.056)
		tmp = sin(re);
	elseif (im <= 1.7e+49)
		tmp = re ^ -4.0;
	elseif ((im <= 2.7e+208) || !(im <= 1.58e+227))
		tmp = Float64(0.041666666666666664 * Float64(re * (im ^ 4.0)));
	else
		tmp = Float64(-0.16666666666666666 * (re ^ 3.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 0.056)
		tmp = sin(re);
	elseif (im <= 1.7e+49)
		tmp = re ^ -4.0;
	elseif ((im <= 2.7e+208) || ~((im <= 1.58e+227)))
		tmp = 0.041666666666666664 * (re * (im ^ 4.0));
	else
		tmp = -0.16666666666666666 * (re ^ 3.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 0.056], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.7e+49], N[Power[re, -4.0], $MachinePrecision], If[Or[LessEqual[im, 2.7e+208], N[Not[LessEqual[im, 1.58e+227]], $MachinePrecision]], N[(0.041666666666666664 * N[(re * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 1.7 \cdot 10^{+49}:\\
\;\;\;\;{re}^{-4}\\

\mathbf{elif}\;im \leq 2.7 \cdot 10^{+208} \lor \neg \left(im \leq 1.58 \cdot 10^{+227}\right):\\
\;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\

\mathbf{else}:\\
\;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\


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

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

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

    if 0.0560000000000000012 < im < 1.7e49

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

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

      \[\leadsto \color{blue}{{re}^{-4}} \]

    if 1.7e49 < im < 2.7e208 or 1.57999999999999994e227 < 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 84.6%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left({im}^{4} \cdot \sin re\right)} \]
    9. Taylor expanded in re around 0 59.5%

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

    if 2.7e208 < im < 1.57999999999999994e227

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

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

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

        \[\leadsto re \cdot \color{blue}{\left(-0.16666666666666666 \cdot {re}^{2} + 1\right)} \]
      2. distribute-rgt-in60.9%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {re}^{2}\right) \cdot re + 1 \cdot re} \]
      3. *-lft-identity60.9%

        \[\leadsto \left(-0.16666666666666666 \cdot {re}^{2}\right) \cdot re + \color{blue}{re} \]
      4. associate-*l*60.9%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({re}^{2} \cdot re\right)} + re \]
      5. fma-define60.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {re}^{2} \cdot re, re\right)} \]
      6. pow-plus60.9%

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, \color{blue}{{re}^{\left(2 + 1\right)}}, re\right) \]
      7. metadata-eval60.9%

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, {re}^{\color{blue}{3}}, re\right) \]
    8. Simplified60.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {re}^{3}, re\right)} \]
    9. Taylor expanded in re around inf 60.6%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {re}^{3}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification59.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.056:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+49}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+208} \lor \neg \left(im \leq 1.58 \cdot 10^{+227}\right):\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 65.2% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.056:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+49}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+208}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{elif}\;im \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 0.056)
   (sin re)
   (if (<= im 1.7e+49)
     (pow re -4.0)
     (if (<= im 2.7e+208)
       (* 0.041666666666666664 (* re (pow im 4.0)))
       (if (<= im 1.58e+227)
         (* -0.16666666666666666 (pow re 3.0))
         (* 0.5 (* re (pow im 2.0))))))))
double code(double re, double im) {
	double tmp;
	if (im <= 0.056) {
		tmp = sin(re);
	} else if (im <= 1.7e+49) {
		tmp = pow(re, -4.0);
	} else if (im <= 2.7e+208) {
		tmp = 0.041666666666666664 * (re * pow(im, 4.0));
	} else if (im <= 1.58e+227) {
		tmp = -0.16666666666666666 * pow(re, 3.0);
	} 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 <= 0.056d0) then
        tmp = sin(re)
    else if (im <= 1.7d+49) then
        tmp = re ** (-4.0d0)
    else if (im <= 2.7d+208) then
        tmp = 0.041666666666666664d0 * (re * (im ** 4.0d0))
    else if (im <= 1.58d+227) then
        tmp = (-0.16666666666666666d0) * (re ** 3.0d0)
    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 <= 0.056) {
		tmp = Math.sin(re);
	} else if (im <= 1.7e+49) {
		tmp = Math.pow(re, -4.0);
	} else if (im <= 2.7e+208) {
		tmp = 0.041666666666666664 * (re * Math.pow(im, 4.0));
	} else if (im <= 1.58e+227) {
		tmp = -0.16666666666666666 * Math.pow(re, 3.0);
	} else {
		tmp = 0.5 * (re * Math.pow(im, 2.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 0.056:
		tmp = math.sin(re)
	elif im <= 1.7e+49:
		tmp = math.pow(re, -4.0)
	elif im <= 2.7e+208:
		tmp = 0.041666666666666664 * (re * math.pow(im, 4.0))
	elif im <= 1.58e+227:
		tmp = -0.16666666666666666 * math.pow(re, 3.0)
	else:
		tmp = 0.5 * (re * math.pow(im, 2.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 0.056)
		tmp = sin(re);
	elseif (im <= 1.7e+49)
		tmp = re ^ -4.0;
	elseif (im <= 2.7e+208)
		tmp = Float64(0.041666666666666664 * Float64(re * (im ^ 4.0)));
	elseif (im <= 1.58e+227)
		tmp = Float64(-0.16666666666666666 * (re ^ 3.0));
	else
		tmp = Float64(0.5 * Float64(re * (im ^ 2.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 0.056)
		tmp = sin(re);
	elseif (im <= 1.7e+49)
		tmp = re ^ -4.0;
	elseif (im <= 2.7e+208)
		tmp = 0.041666666666666664 * (re * (im ^ 4.0));
	elseif (im <= 1.58e+227)
		tmp = -0.16666666666666666 * (re ^ 3.0);
	else
		tmp = 0.5 * (re * (im ^ 2.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 0.056], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.7e+49], N[Power[re, -4.0], $MachinePrecision], If[LessEqual[im, 2.7e+208], N[(0.041666666666666664 * N[(re * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.58e+227], N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 1.7 \cdot 10^{+49}:\\
\;\;\;\;{re}^{-4}\\

\mathbf{elif}\;im \leq 2.7 \cdot 10^{+208}:\\
\;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\

\mathbf{elif}\;im \leq 1.58 \cdot 10^{+227}:\\
\;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\

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


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

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

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

    if 0.0560000000000000012 < im < 1.7e49

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

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

      \[\leadsto \color{blue}{{re}^{-4}} \]

    if 1.7e49 < im < 2.7e208

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left({im}^{4} \cdot \sin re\right)} \]
    9. Taylor expanded in re around 0 56.8%

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

    if 2.7e208 < im < 1.57999999999999994e227

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

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

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

        \[\leadsto re \cdot \color{blue}{\left(-0.16666666666666666 \cdot {re}^{2} + 1\right)} \]
      2. distribute-rgt-in60.9%

        \[\leadsto \color{blue}{\left(-0.16666666666666666 \cdot {re}^{2}\right) \cdot re + 1 \cdot re} \]
      3. *-lft-identity60.9%

        \[\leadsto \left(-0.16666666666666666 \cdot {re}^{2}\right) \cdot re + \color{blue}{re} \]
      4. associate-*l*60.9%

        \[\leadsto \color{blue}{-0.16666666666666666 \cdot \left({re}^{2} \cdot re\right)} + re \]
      5. fma-define60.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {re}^{2} \cdot re, re\right)} \]
      6. pow-plus60.9%

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, \color{blue}{{re}^{\left(2 + 1\right)}}, re\right) \]
      7. metadata-eval60.9%

        \[\leadsto \mathsf{fma}\left(-0.16666666666666666, {re}^{\color{blue}{3}}, re\right) \]
    8. Simplified60.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.16666666666666666, {re}^{3}, re\right)} \]
    9. Taylor expanded in re around inf 60.6%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {re}^{3}} \]

    if 1.57999999999999994e227 < 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 64.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.056:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+49}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 2.7 \cdot 10^{+208}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{elif}\;im \leq 1.58 \cdot 10^{+227}:\\ \;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 55.8% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.056:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.6 \cdot 10^{+83} \lor \neg \left(im \leq 5 \cdot 10^{+108}\right):\\ \;\;\;\;{re}^{-4}\\ \mathbf{else}:\\ \;\;\;\;{re}^{6}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 0.056)
   (sin re)
   (if (or (<= im 3.6e+83) (not (<= im 5e+108))) (pow re -4.0) (pow re 6.0))))
double code(double re, double im) {
	double tmp;
	if (im <= 0.056) {
		tmp = sin(re);
	} else if ((im <= 3.6e+83) || !(im <= 5e+108)) {
		tmp = pow(re, -4.0);
	} else {
		tmp = pow(re, 6.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 0.056d0) then
        tmp = sin(re)
    else if ((im <= 3.6d+83) .or. (.not. (im <= 5d+108))) then
        tmp = re ** (-4.0d0)
    else
        tmp = re ** 6.0d0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 0.056) {
		tmp = Math.sin(re);
	} else if ((im <= 3.6e+83) || !(im <= 5e+108)) {
		tmp = Math.pow(re, -4.0);
	} else {
		tmp = Math.pow(re, 6.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 0.056:
		tmp = math.sin(re)
	elif (im <= 3.6e+83) or not (im <= 5e+108):
		tmp = math.pow(re, -4.0)
	else:
		tmp = math.pow(re, 6.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 0.056)
		tmp = sin(re);
	elseif ((im <= 3.6e+83) || !(im <= 5e+108))
		tmp = re ^ -4.0;
	else
		tmp = re ^ 6.0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 0.056)
		tmp = sin(re);
	elseif ((im <= 3.6e+83) || ~((im <= 5e+108)))
		tmp = re ^ -4.0;
	else
		tmp = re ^ 6.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 0.056], N[Sin[re], $MachinePrecision], If[Or[LessEqual[im, 3.6e+83], N[Not[LessEqual[im, 5e+108]], $MachinePrecision]], N[Power[re, -4.0], $MachinePrecision], N[Power[re, 6.0], $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 3.6 \cdot 10^{+83} \lor \neg \left(im \leq 5 \cdot 10^{+108}\right):\\
\;\;\;\;{re}^{-4}\\

\mathbf{else}:\\
\;\;\;\;{re}^{6}\\


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

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

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

    if 0.0560000000000000012 < im < 3.5999999999999997e83 or 4.99999999999999991e108 < 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 64.2%

      \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    6. Applied egg-rr26.3%

      \[\leadsto \color{blue}{{re}^{-4}} \]

    if 3.5999999999999997e83 < im < 4.99999999999999991e108

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]
    7. Applied egg-rr50.0%

      \[\leadsto \color{blue}{{re}^{6}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification52.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.056:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.6 \cdot 10^{+83} \lor \neg \left(im \leq 5 \cdot 10^{+108}\right):\\ \;\;\;\;{re}^{-4}\\ \mathbf{else}:\\ \;\;\;\;{re}^{6}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 55.6% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.056:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 4.1 \cdot 10^{+83} \lor \neg \left(im \leq 3.5 \cdot 10^{+112}\right):\\ \;\;\;\;{re}^{-4}\\ \mathbf{else}:\\ \;\;\;\;re \cdot re\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 0.056)
   (sin re)
   (if (or (<= im 4.1e+83) (not (<= im 3.5e+112))) (pow re -4.0) (* re re))))
double code(double re, double im) {
	double tmp;
	if (im <= 0.056) {
		tmp = sin(re);
	} else if ((im <= 4.1e+83) || !(im <= 3.5e+112)) {
		tmp = pow(re, -4.0);
	} else {
		tmp = 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 <= 0.056d0) then
        tmp = sin(re)
    else if ((im <= 4.1d+83) .or. (.not. (im <= 3.5d+112))) then
        tmp = re ** (-4.0d0)
    else
        tmp = re * re
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 0.056) {
		tmp = Math.sin(re);
	} else if ((im <= 4.1e+83) || !(im <= 3.5e+112)) {
		tmp = Math.pow(re, -4.0);
	} else {
		tmp = re * re;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 0.056:
		tmp = math.sin(re)
	elif (im <= 4.1e+83) or not (im <= 3.5e+112):
		tmp = math.pow(re, -4.0)
	else:
		tmp = re * re
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 0.056)
		tmp = sin(re);
	elseif ((im <= 4.1e+83) || !(im <= 3.5e+112))
		tmp = re ^ -4.0;
	else
		tmp = Float64(re * re);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 0.056)
		tmp = sin(re);
	elseif ((im <= 4.1e+83) || ~((im <= 3.5e+112)))
		tmp = re ^ -4.0;
	else
		tmp = re * re;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 0.056], N[Sin[re], $MachinePrecision], If[Or[LessEqual[im, 4.1e+83], N[Not[LessEqual[im, 3.5e+112]], $MachinePrecision]], N[Power[re, -4.0], $MachinePrecision], N[(re * re), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 4.1 \cdot 10^{+83} \lor \neg \left(im \leq 3.5 \cdot 10^{+112}\right):\\
\;\;\;\;{re}^{-4}\\

\mathbf{else}:\\
\;\;\;\;re \cdot re\\


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

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

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

    if 0.0560000000000000012 < im < 4.1000000000000001e83 or 3.49999999999999997e112 < 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 63.0%

      \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    6. Applied egg-rr25.5%

      \[\leadsto \color{blue}{{re}^{-4}} \]

    if 4.1000000000000001e83 < im < 3.49999999999999997e112

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

      \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    6. Applied egg-rr25.5%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]
    7. Applied egg-rr1.5%

      \[\leadsto \color{blue}{re \cdot re} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification51.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.056:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 4.1 \cdot 10^{+83} \lor \neg \left(im \leq 3.5 \cdot 10^{+112}\right):\\ \;\;\;\;{re}^{-4}\\ \mathbf{else}:\\ \;\;\;\;re \cdot re\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 53.6% accurate, 2.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;re \cdot re\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 2.60000000000000004e-15 < 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 62.8%

      \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    6. Applied egg-rr17.5%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]
    7. Applied egg-rr10.8%

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

Alternative 14: 29.3% accurate, 38.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.056:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;re \cdot re\\ \end{array} \end{array} \]
(FPCore (re im) :precision binary64 (if (<= im 0.056) re (* re re)))
double code(double re, double im) {
	double tmp;
	if (im <= 0.056) {
		tmp = re;
	} else {
		tmp = 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 <= 0.056d0) then
        tmp = re
    else
        tmp = re * re
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 0.056) {
		tmp = re;
	} else {
		tmp = re * re;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 0.056:
		tmp = re
	else:
		tmp = re * re
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 0.056)
		tmp = re;
	else
		tmp = Float64(re * re);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 0.056)
		tmp = re;
	else
		tmp = re * re;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 0.056], re, N[(re * re), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;re \cdot re\\


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

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

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

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

    if 0.0560000000000000012 < 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 62.2%

      \[\leadsto \left(0.5 \cdot \color{blue}{re}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    6. Applied egg-rr16.3%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(re\right)\right)} \]
    7. Applied egg-rr10.9%

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

Alternative 15: 26.6% accurate, 51.4× speedup?

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

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

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


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

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

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

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

    if 1.7500000000000002e-21 < re

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re\right)} - -4} \]
    7. Step-by-step derivation
      1. sub-neg2.5%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re\right)} + \left(--4\right)} \]
      2. metadata-eval2.5%

        \[\leadsto e^{\mathsf{log1p}\left(re\right)} + \color{blue}{4} \]
      3. +-commutative2.5%

        \[\leadsto \color{blue}{4 + e^{\mathsf{log1p}\left(re\right)}} \]
      4. log1p-undefine2.5%

        \[\leadsto 4 + e^{\color{blue}{\log \left(1 + re\right)}} \]
      5. rem-exp-log2.5%

        \[\leadsto 4 + \color{blue}{\left(1 + re\right)} \]
      6. +-commutative2.5%

        \[\leadsto 4 + \color{blue}{\left(re + 1\right)} \]
    8. Simplified2.5%

      \[\leadsto \color{blue}{4 + \left(re + 1\right)} \]
    9. Applied egg-rr7.9%

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

Alternative 16: 4.9% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1} \]
  7. Simplified4.0%

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

Alternative 17: 4.7% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re\right)} - -4} \]
  7. Step-by-step derivation
    1. sub-neg1.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re\right)} + \left(--4\right)} \]
    2. metadata-eval1.9%

      \[\leadsto e^{\mathsf{log1p}\left(re\right)} + \color{blue}{4} \]
    3. +-commutative1.9%

      \[\leadsto \color{blue}{4 + e^{\mathsf{log1p}\left(re\right)}} \]
    4. log1p-undefine1.9%

      \[\leadsto 4 + e^{\color{blue}{\log \left(1 + re\right)}} \]
    5. rem-exp-log2.7%

      \[\leadsto 4 + \color{blue}{\left(1 + re\right)} \]
    6. +-commutative2.7%

      \[\leadsto 4 + \color{blue}{\left(re + 1\right)} \]
  8. Simplified2.7%

    \[\leadsto \color{blue}{4 + \left(re + 1\right)} \]
  9. Applied egg-rr4.0%

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

Alternative 18: 4.4% accurate, 309.0× speedup?

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

\\
0.125
\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 re around 0 58.9%

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

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re\right)} - -4} \]
  7. Step-by-step derivation
    1. sub-neg1.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re\right)} + \left(--4\right)} \]
    2. metadata-eval1.9%

      \[\leadsto e^{\mathsf{log1p}\left(re\right)} + \color{blue}{4} \]
    3. +-commutative1.9%

      \[\leadsto \color{blue}{4 + e^{\mathsf{log1p}\left(re\right)}} \]
    4. log1p-undefine1.9%

      \[\leadsto 4 + e^{\color{blue}{\log \left(1 + re\right)}} \]
    5. rem-exp-log2.7%

      \[\leadsto 4 + \color{blue}{\left(1 + re\right)} \]
    6. +-commutative2.7%

      \[\leadsto 4 + \color{blue}{\left(re + 1\right)} \]
  8. Simplified2.7%

    \[\leadsto \color{blue}{4 + \left(re + 1\right)} \]
  9. Applied egg-rr3.7%

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

Alternative 19: 4.7% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re\right)} - -4} \]
  7. Step-by-step derivation
    1. sub-neg1.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re\right)} + \left(--4\right)} \]
    2. metadata-eval1.9%

      \[\leadsto e^{\mathsf{log1p}\left(re\right)} + \color{blue}{4} \]
    3. +-commutative1.9%

      \[\leadsto \color{blue}{4 + e^{\mathsf{log1p}\left(re\right)}} \]
    4. log1p-undefine1.9%

      \[\leadsto 4 + e^{\color{blue}{\log \left(1 + re\right)}} \]
    5. rem-exp-log2.7%

      \[\leadsto 4 + \color{blue}{\left(1 + re\right)} \]
    6. +-commutative2.7%

      \[\leadsto 4 + \color{blue}{\left(re + 1\right)} \]
  8. Simplified2.7%

    \[\leadsto \color{blue}{4 + \left(re + 1\right)} \]
  9. Applied egg-rr5.1%

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

Alternative 20: 4.1% accurate, 309.0× speedup?

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

\\
-4
\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 re around 0 58.9%

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

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re\right)} - -4} \]
  7. Step-by-step derivation
    1. sub-neg1.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(re\right)} + \left(--4\right)} \]
    2. metadata-eval1.9%

      \[\leadsto e^{\mathsf{log1p}\left(re\right)} + \color{blue}{4} \]
    3. +-commutative1.9%

      \[\leadsto \color{blue}{4 + e^{\mathsf{log1p}\left(re\right)}} \]
    4. log1p-undefine1.9%

      \[\leadsto 4 + e^{\color{blue}{\log \left(1 + re\right)}} \]
    5. rem-exp-log2.7%

      \[\leadsto 4 + \color{blue}{\left(1 + re\right)} \]
    6. +-commutative2.7%

      \[\leadsto 4 + \color{blue}{\left(re + 1\right)} \]
  8. Simplified2.7%

    \[\leadsto \color{blue}{4 + \left(re + 1\right)} \]
  9. Applied egg-rr4.3%

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

Reproduce

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