math.sin on complex, real part

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

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot {im}^{2}\\


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

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

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

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

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

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

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

    if 0.0054999999999999997 < im < 1.34000000000000001e154

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

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

    if 1.34000000000000001e154 < 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 \color{blue}{\sin re + 0.5 \cdot \left({im}^{2} \cdot \sin re\right)} \]
    6. Taylor expanded in im around inf 100.0%

      \[\leadsto \color{blue}{0.5 \cdot \left({im}^{2} \cdot \sin re\right)} \]
    7. 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 \]
      3. associate-*r*100.0%

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

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

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

Alternative 3: 66.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 680:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.34 \cdot 10^{+154}:\\ \;\;\;\;\sqrt[3]{{re}^{-12}}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot {im}^{2}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 680.0)
   (sin re)
   (if (<= im 1.34e+154)
     (cbrt (pow re -12.0))
     (* (* 0.5 (sin re)) (pow im 2.0)))))
double code(double re, double im) {
	double tmp;
	if (im <= 680.0) {
		tmp = sin(re);
	} else if (im <= 1.34e+154) {
		tmp = cbrt(pow(re, -12.0));
	} else {
		tmp = (0.5 * sin(re)) * pow(im, 2.0);
	}
	return tmp;
}
public static double code(double re, double im) {
	double tmp;
	if (im <= 680.0) {
		tmp = Math.sin(re);
	} else if (im <= 1.34e+154) {
		tmp = Math.cbrt(Math.pow(re, -12.0));
	} else {
		tmp = (0.5 * Math.sin(re)) * Math.pow(im, 2.0);
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 680.0)
		tmp = sin(re);
	elseif (im <= 1.34e+154)
		tmp = cbrt((re ^ -12.0));
	else
		tmp = Float64(Float64(0.5 * sin(re)) * (im ^ 2.0));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 680.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.34e+154], N[Power[N[Power[re, -12.0], $MachinePrecision], 1/3], $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 1.34 \cdot 10^{+154}:\\
\;\;\;\;\sqrt[3]{{re}^{-12}}\\

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


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

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

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

    if 680 < im < 1.34000000000000001e154

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

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

      \[\leadsto \color{blue}{e^{\log re \cdot -4}} \]
    7. Step-by-step derivation
      1. add-cbrt-cube27.5%

        \[\leadsto \color{blue}{\sqrt[3]{\left(e^{\log re \cdot -4} \cdot e^{\log re \cdot -4}\right) \cdot e^{\log re \cdot -4}}} \]
      2. pow1/327.5%

        \[\leadsto \color{blue}{{\left(\left(e^{\log re \cdot -4} \cdot e^{\log re \cdot -4}\right) \cdot e^{\log re \cdot -4}\right)}^{0.3333333333333333}} \]
      3. pow327.5%

        \[\leadsto {\color{blue}{\left({\left(e^{\log re \cdot -4}\right)}^{3}\right)}}^{0.3333333333333333} \]
      4. exp-to-pow28.1%

        \[\leadsto {\left({\color{blue}{\left({re}^{-4}\right)}}^{3}\right)}^{0.3333333333333333} \]
      5. pow-pow28.1%

        \[\leadsto {\color{blue}{\left({re}^{\left(-4 \cdot 3\right)}\right)}}^{0.3333333333333333} \]
      6. metadata-eval28.1%

        \[\leadsto {\left({re}^{\color{blue}{-12}}\right)}^{0.3333333333333333} \]
    8. Applied egg-rr28.1%

      \[\leadsto \color{blue}{{\left({re}^{-12}\right)}^{0.3333333333333333}} \]
    9. Step-by-step derivation
      1. unpow1/328.1%

        \[\leadsto \color{blue}{\sqrt[3]{{re}^{-12}}} \]
    10. Simplified28.1%

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

    if 1.34000000000000001e154 < 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 \color{blue}{\sin re + 0.5 \cdot \left({im}^{2} \cdot \sin re\right)} \]
    6. Taylor expanded in im around inf 100.0%

      \[\leadsto \color{blue}{0.5 \cdot \left({im}^{2} \cdot \sin re\right)} \]
    7. 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 \]
      3. associate-*r*100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 680:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.34 \cdot 10^{+154}:\\ \;\;\;\;\sqrt[3]{{re}^{-12}}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot {im}^{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 78.2% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \sin re\\ \mathbf{if}\;im \leq 820:\\ \;\;\;\;t\_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 1.34 \cdot 10^{+154}:\\ \;\;\;\;\sqrt[3]{{re}^{-12}}\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot {im}^{2}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (sin re))))
   (if (<= im 820.0)
     (* t_0 (fma im im 2.0))
     (if (<= im 1.34e+154) (cbrt (pow re -12.0)) (* t_0 (pow im 2.0))))))
double code(double re, double im) {
	double t_0 = 0.5 * sin(re);
	double tmp;
	if (im <= 820.0) {
		tmp = t_0 * fma(im, im, 2.0);
	} else if (im <= 1.34e+154) {
		tmp = cbrt(pow(re, -12.0));
	} else {
		tmp = t_0 * pow(im, 2.0);
	}
	return tmp;
}
function code(re, im)
	t_0 = Float64(0.5 * sin(re))
	tmp = 0.0
	if (im <= 820.0)
		tmp = Float64(t_0 * fma(im, im, 2.0));
	elseif (im <= 1.34e+154)
		tmp = cbrt((re ^ -12.0));
	else
		tmp = Float64(t_0 * (im ^ 2.0));
	end
	return tmp
end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 820.0], N[(t$95$0 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.34e+154], N[Power[N[Power[re, -12.0], $MachinePrecision], 1/3], $MachinePrecision], N[(t$95$0 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 1.34 \cdot 10^{+154}:\\
\;\;\;\;\sqrt[3]{{re}^{-12}}\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot {im}^{2}\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 820 < im < 1.34000000000000001e154

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

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

      \[\leadsto \color{blue}{e^{\log re \cdot -4}} \]
    7. Step-by-step derivation
      1. add-cbrt-cube27.5%

        \[\leadsto \color{blue}{\sqrt[3]{\left(e^{\log re \cdot -4} \cdot e^{\log re \cdot -4}\right) \cdot e^{\log re \cdot -4}}} \]
      2. pow1/327.5%

        \[\leadsto \color{blue}{{\left(\left(e^{\log re \cdot -4} \cdot e^{\log re \cdot -4}\right) \cdot e^{\log re \cdot -4}\right)}^{0.3333333333333333}} \]
      3. pow327.5%

        \[\leadsto {\color{blue}{\left({\left(e^{\log re \cdot -4}\right)}^{3}\right)}}^{0.3333333333333333} \]
      4. exp-to-pow28.1%

        \[\leadsto {\left({\color{blue}{\left({re}^{-4}\right)}}^{3}\right)}^{0.3333333333333333} \]
      5. pow-pow28.1%

        \[\leadsto {\color{blue}{\left({re}^{\left(-4 \cdot 3\right)}\right)}}^{0.3333333333333333} \]
      6. metadata-eval28.1%

        \[\leadsto {\left({re}^{\color{blue}{-12}}\right)}^{0.3333333333333333} \]
    8. Applied egg-rr28.1%

      \[\leadsto \color{blue}{{\left({re}^{-12}\right)}^{0.3333333333333333}} \]
    9. Step-by-step derivation
      1. unpow1/328.1%

        \[\leadsto \color{blue}{\sqrt[3]{{re}^{-12}}} \]
    10. Simplified28.1%

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

    if 1.34000000000000001e154 < 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 \color{blue}{\sin re + 0.5 \cdot \left({im}^{2} \cdot \sin re\right)} \]
    6. Taylor expanded in im around inf 100.0%

      \[\leadsto \color{blue}{0.5 \cdot \left({im}^{2} \cdot \sin re\right)} \]
    7. 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 \]
      3. associate-*r*100.0%

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

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

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

Alternative 5: 62.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 650:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+141}:\\ \;\;\;\;\sqrt[3]{{re}^{-12}}\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+243}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 6.8 \cdot 10^{+259}:\\ \;\;\;\;re \cdot \left(1 + {re}^{2} \cdot -0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 650.0)
   (sin re)
   (if (<= im 1.8e+141)
     (cbrt (pow re -12.0))
     (if (<= im 1.8e+243)
       (* (fma im im 2.0) (* 0.5 re))
       (if (<= im 6.8e+259)
         (* re (+ 1.0 (* (pow re 2.0) -0.16666666666666666)))
         (* re (* 0.5 (pow im 2.0))))))))
double code(double re, double im) {
	double tmp;
	if (im <= 650.0) {
		tmp = sin(re);
	} else if (im <= 1.8e+141) {
		tmp = cbrt(pow(re, -12.0));
	} else if (im <= 1.8e+243) {
		tmp = fma(im, im, 2.0) * (0.5 * re);
	} else if (im <= 6.8e+259) {
		tmp = re * (1.0 + (pow(re, 2.0) * -0.16666666666666666));
	} else {
		tmp = re * (0.5 * pow(im, 2.0));
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 650.0)
		tmp = sin(re);
	elseif (im <= 1.8e+141)
		tmp = cbrt((re ^ -12.0));
	elseif (im <= 1.8e+243)
		tmp = Float64(fma(im, im, 2.0) * Float64(0.5 * re));
	elseif (im <= 6.8e+259)
		tmp = Float64(re * Float64(1.0 + Float64((re ^ 2.0) * -0.16666666666666666)));
	else
		tmp = Float64(re * Float64(0.5 * (im ^ 2.0)));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 650.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.8e+141], N[Power[N[Power[re, -12.0], $MachinePrecision], 1/3], $MachinePrecision], If[LessEqual[im, 1.8e+243], N[(N[(im * im + 2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.8e+259], N[(re * N[(1.0 + N[(N[Power[re, 2.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 1.8 \cdot 10^{+141}:\\
\;\;\;\;\sqrt[3]{{re}^{-12}}\\

\mathbf{elif}\;im \leq 1.8 \cdot 10^{+243}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\

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

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


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

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

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

    if 650 < im < 1.8000000000000001e141

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

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

      \[\leadsto \color{blue}{e^{\log re \cdot -4}} \]
    7. Step-by-step derivation
      1. add-cbrt-cube26.0%

        \[\leadsto \color{blue}{\sqrt[3]{\left(e^{\log re \cdot -4} \cdot e^{\log re \cdot -4}\right) \cdot e^{\log re \cdot -4}}} \]
      2. pow1/326.0%

        \[\leadsto \color{blue}{{\left(\left(e^{\log re \cdot -4} \cdot e^{\log re \cdot -4}\right) \cdot e^{\log re \cdot -4}\right)}^{0.3333333333333333}} \]
      3. pow326.0%

        \[\leadsto {\color{blue}{\left({\left(e^{\log re \cdot -4}\right)}^{3}\right)}}^{0.3333333333333333} \]
      4. exp-to-pow26.6%

        \[\leadsto {\left({\color{blue}{\left({re}^{-4}\right)}}^{3}\right)}^{0.3333333333333333} \]
      5. pow-pow26.6%

        \[\leadsto {\color{blue}{\left({re}^{\left(-4 \cdot 3\right)}\right)}}^{0.3333333333333333} \]
      6. metadata-eval26.6%

        \[\leadsto {\left({re}^{\color{blue}{-12}}\right)}^{0.3333333333333333} \]
    8. Applied egg-rr26.6%

      \[\leadsto \color{blue}{{\left({re}^{-12}\right)}^{0.3333333333333333}} \]
    9. Step-by-step derivation
      1. unpow1/326.6%

        \[\leadsto \color{blue}{\sqrt[3]{{re}^{-12}}} \]
    10. Simplified26.6%

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

    if 1.8000000000000001e141 < im < 1.7999999999999998e243

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

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

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

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

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

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

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

    if 1.7999999999999998e243 < im < 6.79999999999999979e259

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.79999999999999979e259 < 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 66.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 650:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+141}:\\ \;\;\;\;\sqrt[3]{{re}^{-12}}\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+243}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 6.8 \cdot 10^{+259}:\\ \;\;\;\;re \cdot \left(1 + {re}^{2} \cdot -0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 61.7% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 660:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+132}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+243}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 6.8 \cdot 10^{+259}:\\ \;\;\;\;re \cdot \left(1 + {re}^{2} \cdot -0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 660.0)
   (sin re)
   (if (<= im 1.7e+132)
     (pow re -4.0)
     (if (<= im 1.8e+243)
       (* (fma im im 2.0) (* 0.5 re))
       (if (<= im 6.8e+259)
         (* re (+ 1.0 (* (pow re 2.0) -0.16666666666666666)))
         (* re (* 0.5 (pow im 2.0))))))))
double code(double re, double im) {
	double tmp;
	if (im <= 660.0) {
		tmp = sin(re);
	} else if (im <= 1.7e+132) {
		tmp = pow(re, -4.0);
	} else if (im <= 1.8e+243) {
		tmp = fma(im, im, 2.0) * (0.5 * re);
	} else if (im <= 6.8e+259) {
		tmp = re * (1.0 + (pow(re, 2.0) * -0.16666666666666666));
	} else {
		tmp = re * (0.5 * pow(im, 2.0));
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 660.0)
		tmp = sin(re);
	elseif (im <= 1.7e+132)
		tmp = re ^ -4.0;
	elseif (im <= 1.8e+243)
		tmp = Float64(fma(im, im, 2.0) * Float64(0.5 * re));
	elseif (im <= 6.8e+259)
		tmp = Float64(re * Float64(1.0 + Float64((re ^ 2.0) * -0.16666666666666666)));
	else
		tmp = Float64(re * Float64(0.5 * (im ^ 2.0)));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 660.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.7e+132], N[Power[re, -4.0], $MachinePrecision], If[LessEqual[im, 1.8e+243], N[(N[(im * im + 2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.8e+259], N[(re * N[(1.0 + N[(N[Power[re, 2.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 1.8 \cdot 10^{+243}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\

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

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


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

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

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

    if 660 < im < 1.70000000000000013e132

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

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

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

    if 1.70000000000000013e132 < im < 1.7999999999999998e243

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

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

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

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

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

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

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

    if 1.7999999999999998e243 < im < 6.79999999999999979e259

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.79999999999999979e259 < 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 66.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 660:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+132}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+243}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 6.8 \cdot 10^{+259}:\\ \;\;\;\;re \cdot \left(1 + {re}^{2} \cdot -0.16666666666666666\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 61.7% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 720:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+130}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+243} \lor \neg \left(im \leq 6.8 \cdot 10^{+259}\right):\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 720.0)
   (sin re)
   (if (<= im 4.4e+130)
     (pow re -4.0)
     (if (or (<= im 1.8e+243) (not (<= im 6.8e+259)))
       (* re (* 0.5 (pow im 2.0)))
       (* -0.16666666666666666 (pow re 3.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 720.0) {
		tmp = sin(re);
	} else if (im <= 4.4e+130) {
		tmp = pow(re, -4.0);
	} else if ((im <= 1.8e+243) || !(im <= 6.8e+259)) {
		tmp = re * (0.5 * pow(im, 2.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 <= 720.0d0) then
        tmp = sin(re)
    else if (im <= 4.4d+130) then
        tmp = re ** (-4.0d0)
    else if ((im <= 1.8d+243) .or. (.not. (im <= 6.8d+259))) then
        tmp = re * (0.5d0 * (im ** 2.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 <= 720.0) {
		tmp = Math.sin(re);
	} else if (im <= 4.4e+130) {
		tmp = Math.pow(re, -4.0);
	} else if ((im <= 1.8e+243) || !(im <= 6.8e+259)) {
		tmp = re * (0.5 * Math.pow(im, 2.0));
	} else {
		tmp = -0.16666666666666666 * Math.pow(re, 3.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 720.0:
		tmp = math.sin(re)
	elif im <= 4.4e+130:
		tmp = math.pow(re, -4.0)
	elif (im <= 1.8e+243) or not (im <= 6.8e+259):
		tmp = re * (0.5 * math.pow(im, 2.0))
	else:
		tmp = -0.16666666666666666 * math.pow(re, 3.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 720.0)
		tmp = sin(re);
	elseif (im <= 4.4e+130)
		tmp = re ^ -4.0;
	elseif ((im <= 1.8e+243) || !(im <= 6.8e+259))
		tmp = Float64(re * Float64(0.5 * (im ^ 2.0)));
	else
		tmp = Float64(-0.16666666666666666 * (re ^ 3.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 720.0)
		tmp = sin(re);
	elseif (im <= 4.4e+130)
		tmp = re ^ -4.0;
	elseif ((im <= 1.8e+243) || ~((im <= 6.8e+259)))
		tmp = re * (0.5 * (im ^ 2.0));
	else
		tmp = -0.16666666666666666 * (re ^ 3.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 720.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 4.4e+130], N[Power[re, -4.0], $MachinePrecision], If[Or[LessEqual[im, 1.8e+243], N[Not[LessEqual[im, 6.8e+259]], $MachinePrecision]], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 1.8 \cdot 10^{+243} \lor \neg \left(im \leq 6.8 \cdot 10^{+259}\right):\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\

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


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

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

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

    if 720 < im < 4.39999999999999987e130

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

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

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

    if 4.39999999999999987e130 < im < 1.7999999999999998e243 or 6.79999999999999979e259 < 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 75.0%

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

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

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

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

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

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

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

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

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

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

    if 1.7999999999999998e243 < im < 6.79999999999999979e259

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re \cdot \left(1 + {re}^{2} \cdot -0.16666666666666666\right)} \]
    9. Taylor expanded in re around inf 67.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 720:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 4.4 \cdot 10^{+130}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+243} \lor \neg \left(im \leq 6.8 \cdot 10^{+259}\right):\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 61.7% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 780:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 9.8 \cdot 10^{+129}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+243}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 6.8 \cdot 10^{+259}:\\ \;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 780.0)
   (sin re)
   (if (<= im 9.8e+129)
     (pow re -4.0)
     (if (<= im 1.8e+243)
       (* (fma im im 2.0) (* 0.5 re))
       (if (<= im 6.8e+259)
         (* -0.16666666666666666 (pow re 3.0))
         (* re (* 0.5 (pow im 2.0))))))))
double code(double re, double im) {
	double tmp;
	if (im <= 780.0) {
		tmp = sin(re);
	} else if (im <= 9.8e+129) {
		tmp = pow(re, -4.0);
	} else if (im <= 1.8e+243) {
		tmp = fma(im, im, 2.0) * (0.5 * re);
	} else if (im <= 6.8e+259) {
		tmp = -0.16666666666666666 * pow(re, 3.0);
	} else {
		tmp = re * (0.5 * pow(im, 2.0));
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (im <= 780.0)
		tmp = sin(re);
	elseif (im <= 9.8e+129)
		tmp = re ^ -4.0;
	elseif (im <= 1.8e+243)
		tmp = Float64(fma(im, im, 2.0) * Float64(0.5 * re));
	elseif (im <= 6.8e+259)
		tmp = Float64(-0.16666666666666666 * (re ^ 3.0));
	else
		tmp = Float64(re * Float64(0.5 * (im ^ 2.0)));
	end
	return tmp
end
code[re_, im_] := If[LessEqual[im, 780.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 9.8e+129], N[Power[re, -4.0], $MachinePrecision], If[LessEqual[im, 1.8e+243], N[(N[(im * im + 2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 6.8e+259], N[(-0.16666666666666666 * N[Power[re, 3.0], $MachinePrecision]), $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;im \leq 1.8 \cdot 10^{+243}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\

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

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


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

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

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

    if 780 < im < 9.8e129

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

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

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

    if 9.8e129 < im < 1.7999999999999998e243

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

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

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

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

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

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

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

    if 1.7999999999999998e243 < im < 6.79999999999999979e259

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re \cdot \left(1 + {re}^{2} \cdot -0.16666666666666666\right)} \]
    9. Taylor expanded in re around inf 67.8%

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

    if 6.79999999999999979e259 < 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 66.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 780:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 9.8 \cdot 10^{+129}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+243}:\\ \;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\ \mathbf{elif}\;im \leq 6.8 \cdot 10^{+259}:\\ \;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 55.1% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 560:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+243} \lor \neg \left(im \leq 6.8 \cdot 10^{+259}\right):\\ \;\;\;\;{re}^{-4}\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 560.0)
   (sin re)
   (if (or (<= im 1.8e+243) (not (<= im 6.8e+259)))
     (pow re -4.0)
     (* -0.16666666666666666 (pow re 3.0)))))
double code(double re, double im) {
	double tmp;
	if (im <= 560.0) {
		tmp = sin(re);
	} else if ((im <= 1.8e+243) || !(im <= 6.8e+259)) {
		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 <= 560.0d0) then
        tmp = sin(re)
    else if ((im <= 1.8d+243) .or. (.not. (im <= 6.8d+259))) 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 <= 560.0) {
		tmp = Math.sin(re);
	} else if ((im <= 1.8e+243) || !(im <= 6.8e+259)) {
		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 <= 560.0:
		tmp = math.sin(re)
	elif (im <= 1.8e+243) or not (im <= 6.8e+259):
		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 <= 560.0)
		tmp = sin(re);
	elseif ((im <= 1.8e+243) || !(im <= 6.8e+259))
		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 <= 560.0)
		tmp = sin(re);
	elseif ((im <= 1.8e+243) || ~((im <= 6.8e+259)))
		tmp = re ^ -4.0;
	else
		tmp = -0.16666666666666666 * (re ^ 3.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 560.0], N[Sin[re], $MachinePrecision], If[Or[LessEqual[im, 1.8e+243], N[Not[LessEqual[im, 6.8e+259]], $MachinePrecision]], 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 560:\\
\;\;\;\;\sin re\\

\mathbf{elif}\;im \leq 1.8 \cdot 10^{+243} \lor \neg \left(im \leq 6.8 \cdot 10^{+259}\right):\\
\;\;\;\;{re}^{-4}\\

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


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

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

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

    if 560 < im < 1.7999999999999998e243 or 6.79999999999999979e259 < 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 74.2%

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

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

    if 1.7999999999999998e243 < im < 6.79999999999999979e259

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re \cdot \left(1 + {re}^{2} \cdot -0.16666666666666666\right)} \]
    9. Taylor expanded in re around inf 67.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 560:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+243} \lor \neg \left(im \leq 6.8 \cdot 10^{+259}\right):\\ \;\;\;\;{re}^{-4}\\ \mathbf{else}:\\ \;\;\;\;-0.16666666666666666 \cdot {re}^{3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 55.1% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 600:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;{re}^{-4}\\ \end{array} \end{array} \]
(FPCore (re im) :precision binary64 (if (<= im 600.0) (sin re) (pow re -4.0)))
double code(double re, double im) {
	double tmp;
	if (im <= 600.0) {
		tmp = sin(re);
	} else {
		tmp = pow(re, -4.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 600.0d0) then
        tmp = sin(re)
    else
        tmp = re ** (-4.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 600.0) {
		tmp = Math.sin(re);
	} else {
		tmp = Math.pow(re, -4.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 600.0:
		tmp = math.sin(re)
	else:
		tmp = math.pow(re, -4.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 600.0)
		tmp = sin(re);
	else
		tmp = re ^ -4.0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 600.0)
		tmp = sin(re);
	else
		tmp = re ^ -4.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 600.0], N[Sin[re], $MachinePrecision], N[Power[re, -4.0], $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;{re}^{-4}\\


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

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

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

    if 600 < 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 70.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 600:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;{re}^{-4}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 50.9% accurate, 3.1× speedup?

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sin re} \]
  6. Final simplification48.5%

    \[\leadsto \sin re \]
  7. 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-rr3.0%

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

      \[\leadsto \log \color{blue}{1} \]
    2. metadata-eval3.0%

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

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

    \[\leadsto 0 \]
  9. Add Preprocessing

Alternative 13: 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.5%

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

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

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

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

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

    \[\leadsto 1 \]
  9. Add Preprocessing

Alternative 14: 25.9% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{re} \]
  7. Final simplification26.1%

    \[\leadsto re \]
  8. Add Preprocessing

Reproduce

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