math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 7.5s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 84.9% accurate, 1.4× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.00640000000000000031 < im < 1.4e154

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

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

    if 1.4e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 65.2% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;im \leq 3.8 \cdot 10^{+152}:\\
\;\;\;\;\sqrt{{re}^{-4}}\\

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


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

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

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

    if 4.9e16 < im < 3.8e152

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

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

      \[\leadsto \color{blue}{{\sin re}^{-2}} \]
    7. Taylor expanded in re around 0 17.1%

      \[\leadsto \color{blue}{\frac{1}{{re}^{2}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt17.1%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{re}^{2}}} \cdot \sqrt{\frac{1}{{re}^{2}}}} \]
      2. sqrt-unprod24.5%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{re}^{2}} \cdot \frac{1}{{re}^{2}}}} \]
      3. pow-flip24.5%

        \[\leadsto \sqrt{\color{blue}{{re}^{\left(-2\right)}} \cdot \frac{1}{{re}^{2}}} \]
      4. metadata-eval24.5%

        \[\leadsto \sqrt{{re}^{\color{blue}{-2}} \cdot \frac{1}{{re}^{2}}} \]
      5. pow-flip24.5%

        \[\leadsto \sqrt{{re}^{-2} \cdot \color{blue}{{re}^{\left(-2\right)}}} \]
      6. metadata-eval24.5%

        \[\leadsto \sqrt{{re}^{-2} \cdot {re}^{\color{blue}{-2}}} \]
      7. pow-prod-up24.5%

        \[\leadsto \sqrt{\color{blue}{{re}^{\left(-2 + -2\right)}}} \]
      8. metadata-eval24.5%

        \[\leadsto \sqrt{{re}^{\color{blue}{-4}}} \]
    9. Applied egg-rr24.5%

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

    if 3.8e152 < 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 97.2%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.9 \cdot 10^{+16}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.8 \cdot 10^{+152}:\\ \;\;\;\;\sqrt{{re}^{-4}}\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 78.1% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;im \leq 3.8 \cdot 10^{+152}:\\
\;\;\;\;\sqrt{{re}^{-4}}\\

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


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

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

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

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

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

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

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

    if 4.9e16 < im < 3.8e152

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

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

      \[\leadsto \color{blue}{{\sin re}^{-2}} \]
    7. Taylor expanded in re around 0 17.1%

      \[\leadsto \color{blue}{\frac{1}{{re}^{2}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt17.1%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{re}^{2}}} \cdot \sqrt{\frac{1}{{re}^{2}}}} \]
      2. sqrt-unprod24.5%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{re}^{2}} \cdot \frac{1}{{re}^{2}}}} \]
      3. pow-flip24.5%

        \[\leadsto \sqrt{\color{blue}{{re}^{\left(-2\right)}} \cdot \frac{1}{{re}^{2}}} \]
      4. metadata-eval24.5%

        \[\leadsto \sqrt{{re}^{\color{blue}{-2}} \cdot \frac{1}{{re}^{2}}} \]
      5. pow-flip24.5%

        \[\leadsto \sqrt{{re}^{-2} \cdot \color{blue}{{re}^{\left(-2\right)}}} \]
      6. metadata-eval24.5%

        \[\leadsto \sqrt{{re}^{-2} \cdot {re}^{\color{blue}{-2}}} \]
      7. pow-prod-up24.5%

        \[\leadsto \sqrt{\color{blue}{{re}^{\left(-2 + -2\right)}}} \]
      8. metadata-eval24.5%

        \[\leadsto \sqrt{{re}^{\color{blue}{-4}}} \]
    9. Applied egg-rr24.5%

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

    if 3.8e152 < 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 97.2%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 82.0% accurate, 1.4× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 35 < im < 1.4e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin re\right)\right)}\right) \cdot \left(e^{-im} + e^{im}\right) \]
    6. Applied egg-rr51.2%

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

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

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

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

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

    if 1.4e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 62.5% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 4.9 \cdot 10^{+16}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2.75 \cdot 10^{+132}:\\ \;\;\;\;\sqrt{{re}^{-4}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 4.9e+16)
   (sin re)
   (if (<= im 2.75e+132) (sqrt (pow re -4.0)) (* 0.5 (* re (pow im 2.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 4.9e+16) {
		tmp = sin(re);
	} else if (im <= 2.75e+132) {
		tmp = sqrt(pow(re, -4.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 <= 4.9d+16) then
        tmp = sin(re)
    else if (im <= 2.75d+132) then
        tmp = sqrt((re ** (-4.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 <= 4.9e+16) {
		tmp = Math.sin(re);
	} else if (im <= 2.75e+132) {
		tmp = Math.sqrt(Math.pow(re, -4.0));
	} else {
		tmp = 0.5 * (re * Math.pow(im, 2.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 4.9e+16:
		tmp = math.sin(re)
	elif im <= 2.75e+132:
		tmp = math.sqrt(math.pow(re, -4.0))
	else:
		tmp = 0.5 * (re * math.pow(im, 2.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 4.9e+16)
		tmp = sin(re);
	elseif (im <= 2.75e+132)
		tmp = sqrt((re ^ -4.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 <= 4.9e+16)
		tmp = sin(re);
	elseif (im <= 2.75e+132)
		tmp = sqrt((re ^ -4.0));
	else
		tmp = 0.5 * (re * (im ^ 2.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 4.9e+16], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.75e+132], N[Sqrt[N[Power[re, -4.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 4.9 \cdot 10^{+16}:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 2.75 \cdot 10^{+132}:\\
\;\;\;\;\sqrt{{re}^{-4}}\\

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


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

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

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

    if 4.9e16 < im < 2.75e132

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

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

      \[\leadsto \color{blue}{{\sin re}^{-2}} \]
    7. Taylor expanded in re around 0 18.3%

      \[\leadsto \color{blue}{\frac{1}{{re}^{2}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt18.3%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{re}^{2}}} \cdot \sqrt{\frac{1}{{re}^{2}}}} \]
      2. sqrt-unprod23.6%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{re}^{2}} \cdot \frac{1}{{re}^{2}}}} \]
      3. pow-flip23.6%

        \[\leadsto \sqrt{\color{blue}{{re}^{\left(-2\right)}} \cdot \frac{1}{{re}^{2}}} \]
      4. metadata-eval23.6%

        \[\leadsto \sqrt{{re}^{\color{blue}{-2}} \cdot \frac{1}{{re}^{2}}} \]
      5. pow-flip23.6%

        \[\leadsto \sqrt{{re}^{-2} \cdot \color{blue}{{re}^{\left(-2\right)}}} \]
      6. metadata-eval23.6%

        \[\leadsto \sqrt{{re}^{-2} \cdot {re}^{\color{blue}{-2}}} \]
      7. pow-prod-up23.6%

        \[\leadsto \sqrt{\color{blue}{{re}^{\left(-2 + -2\right)}}} \]
      8. metadata-eval23.6%

        \[\leadsto \sqrt{{re}^{\color{blue}{-4}}} \]
    9. Applied egg-rr23.6%

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

    if 2.75e132 < 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 80.0%

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

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

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

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

        \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    8. Simplified74.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 74.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.9 \cdot 10^{+16}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2.75 \cdot 10^{+132}:\\ \;\;\;\;\sqrt{{re}^{-4}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 62.1% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 4.9 \cdot 10^{+16}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.06 \cdot 10^{+132}:\\ \;\;\;\;\frac{1}{{re}^{2}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 4.9e+16)
   (sin re)
   (if (<= im 1.06e+132) (/ 1.0 (pow re 2.0)) (* 0.5 (* re (pow im 2.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 4.9e+16) {
		tmp = sin(re);
	} else if (im <= 1.06e+132) {
		tmp = 1.0 / 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 <= 4.9d+16) then
        tmp = sin(re)
    else if (im <= 1.06d+132) then
        tmp = 1.0d0 / (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 <= 4.9e+16) {
		tmp = Math.sin(re);
	} else if (im <= 1.06e+132) {
		tmp = 1.0 / 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 <= 4.9e+16:
		tmp = math.sin(re)
	elif im <= 1.06e+132:
		tmp = 1.0 / 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 <= 4.9e+16)
		tmp = sin(re);
	elseif (im <= 1.06e+132)
		tmp = Float64(1.0 / (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 <= 4.9e+16)
		tmp = sin(re);
	elseif (im <= 1.06e+132)
		tmp = 1.0 / (re ^ 2.0);
	else
		tmp = 0.5 * (re * (im ^ 2.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 4.9e+16], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.06e+132], N[(1.0 / N[Power[re, 2.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 4.9 \cdot 10^{+16}:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 1.06 \cdot 10^{+132}:\\
\;\;\;\;\frac{1}{{re}^{2}}\\

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


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

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

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

    if 4.9e16 < im < 1.0599999999999999e132

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

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

      \[\leadsto \color{blue}{{\sin re}^{-2}} \]
    7. Taylor expanded in re around 0 18.3%

      \[\leadsto \color{blue}{\frac{1}{{re}^{2}}} \]

    if 1.0599999999999999e132 < 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 80.0%

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

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

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

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

        \[\leadsto \left(0.5 \cdot re\right) \cdot \color{blue}{\mathsf{fma}\left(im, im, 2\right)} \]
    8. Simplified74.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 74.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.9 \cdot 10^{+16}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.06 \cdot 10^{+132}:\\ \;\;\;\;\frac{1}{{re}^{2}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 53.7% accurate, 2.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{{re}^{2}}\\


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

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

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

    if 4.9e16 < 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.6%

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

      \[\leadsto \color{blue}{{\sin re}^{-2}} \]
    7. Taylor expanded in re around 0 17.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.9 \cdot 10^{+16}:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{{re}^{2}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 53.7% accurate, 2.9× speedup?

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

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

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


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

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

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

    if 4.9e16 < 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.6%

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

      \[\leadsto \color{blue}{{\sin re}^{-2}} \]
    7. Taylor expanded in re around 0 17.2%

      \[\leadsto \color{blue}{\frac{1}{{re}^{2}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt17.2%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{re}^{2}}} \cdot \sqrt{\frac{1}{{re}^{2}}}} \]
      2. sqrt-div17.2%

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{{re}^{2}}}} \cdot \sqrt{\frac{1}{{re}^{2}}} \]
      3. metadata-eval17.2%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{{re}^{2}}} \cdot \sqrt{\frac{1}{{re}^{2}}} \]
      4. sqrt-pow134.8%

        \[\leadsto \frac{1}{\color{blue}{{re}^{\left(\frac{2}{2}\right)}}} \cdot \sqrt{\frac{1}{{re}^{2}}} \]
      5. metadata-eval34.8%

        \[\leadsto \frac{1}{{re}^{\color{blue}{1}}} \cdot \sqrt{\frac{1}{{re}^{2}}} \]
      6. pow134.8%

        \[\leadsto \frac{1}{\color{blue}{re}} \cdot \sqrt{\frac{1}{{re}^{2}}} \]
      7. sqrt-div34.8%

        \[\leadsto \frac{1}{re} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{{re}^{2}}}} \]
      8. metadata-eval34.8%

        \[\leadsto \frac{1}{re} \cdot \frac{\color{blue}{1}}{\sqrt{{re}^{2}}} \]
      9. sqrt-pow117.2%

        \[\leadsto \frac{1}{re} \cdot \frac{1}{\color{blue}{{re}^{\left(\frac{2}{2}\right)}}} \]
      10. metadata-eval17.2%

        \[\leadsto \frac{1}{re} \cdot \frac{1}{{re}^{\color{blue}{1}}} \]
      11. pow117.2%

        \[\leadsto \frac{1}{re} \cdot \frac{1}{\color{blue}{re}} \]
    9. Applied egg-rr17.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.9 \cdot 10^{+16}:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{re} \cdot \frac{1}{re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 29.5% accurate, 25.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.9 \cdot 10^{+16}:\\
\;\;\;\;re\\

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


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

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

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

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

    if 4.9e16 < 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.6%

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

      \[\leadsto \color{blue}{{\sin re}^{-2}} \]
    7. Taylor expanded in re around 0 17.2%

      \[\leadsto \color{blue}{\frac{1}{{re}^{2}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt17.2%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{re}^{2}}} \cdot \sqrt{\frac{1}{{re}^{2}}}} \]
      2. sqrt-div17.2%

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{{re}^{2}}}} \cdot \sqrt{\frac{1}{{re}^{2}}} \]
      3. metadata-eval17.2%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{{re}^{2}}} \cdot \sqrt{\frac{1}{{re}^{2}}} \]
      4. sqrt-pow134.8%

        \[\leadsto \frac{1}{\color{blue}{{re}^{\left(\frac{2}{2}\right)}}} \cdot \sqrt{\frac{1}{{re}^{2}}} \]
      5. metadata-eval34.8%

        \[\leadsto \frac{1}{{re}^{\color{blue}{1}}} \cdot \sqrt{\frac{1}{{re}^{2}}} \]
      6. pow134.8%

        \[\leadsto \frac{1}{\color{blue}{re}} \cdot \sqrt{\frac{1}{{re}^{2}}} \]
      7. sqrt-div34.8%

        \[\leadsto \frac{1}{re} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{{re}^{2}}}} \]
      8. metadata-eval34.8%

        \[\leadsto \frac{1}{re} \cdot \frac{\color{blue}{1}}{\sqrt{{re}^{2}}} \]
      9. sqrt-pow117.2%

        \[\leadsto \frac{1}{re} \cdot \frac{1}{\color{blue}{{re}^{\left(\frac{2}{2}\right)}}} \]
      10. metadata-eval17.2%

        \[\leadsto \frac{1}{re} \cdot \frac{1}{{re}^{\color{blue}{1}}} \]
      11. pow117.2%

        \[\leadsto \frac{1}{re} \cdot \frac{1}{\color{blue}{re}} \]
    9. Applied egg-rr17.2%

      \[\leadsto \color{blue}{\frac{1}{re} \cdot \frac{1}{re}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification26.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.9 \cdot 10^{+16}:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{re} \cdot \frac{1}{re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 27.6% accurate, 51.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 5.4 \cdot 10^{-11}:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (re im) :precision binary64 (if (<= re 5.4e-11) re 1.0))
double code(double re, double im) {
	double tmp;
	if (re <= 5.4e-11) {
		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 <= 5.4d-11) 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 <= 5.4e-11) {
		tmp = re;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 5.4e-11:
		tmp = re
	else:
		tmp = 1.0
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 5.4e-11)
		tmp = re;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 5.4e-11)
		tmp = re;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 5.4e-11], re, 1.0]
\begin{array}{l}

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

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


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

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

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

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

    if 5.40000000000000009e-11 < 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. Applied egg-rr7.9%

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

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

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

        \[\leadsto \color{blue}{1} \]
    7. Simplified7.9%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification24.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 5.4 \cdot 10^{-11}:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 2.9% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0} \]
  8. Final simplification2.9%

    \[\leadsto 0 \]
  9. Add Preprocessing

Alternative 13: 4.8% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{1} \]
  8. Final simplification4.9%

    \[\leadsto 1 \]
  9. Add Preprocessing

Reproduce

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