math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 6.7s
Alternatives: 11
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 11 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: 85.9% accurate, 1.4× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if 7.79999999999999982 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if 1.14999999999999997e77 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + {im}^{2} \cdot 0.08333333333333333\right)\right)} \]
    7. Taylor expanded in im around inf 100.0%

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

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

Alternative 3: 70.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 620:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;\sqrt{{re}^{-8}}\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 620.0)
   (sin re)
   (if (<= im 1.15e+77)
     (sqrt (pow re -8.0))
     (* 0.041666666666666664 (* (sin re) (pow im 4.0))))))
double code(double re, double im) {
	double tmp;
	if (im <= 620.0) {
		tmp = sin(re);
	} else if (im <= 1.15e+77) {
		tmp = sqrt(pow(re, -8.0));
	} else {
		tmp = 0.041666666666666664 * (sin(re) * pow(im, 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 <= 620.0d0) then
        tmp = sin(re)
    else if (im <= 1.15d+77) then
        tmp = sqrt((re ** (-8.0d0)))
    else
        tmp = 0.041666666666666664d0 * (sin(re) * (im ** 4.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 620.0) {
		tmp = Math.sin(re);
	} else if (im <= 1.15e+77) {
		tmp = Math.sqrt(Math.pow(re, -8.0));
	} else {
		tmp = 0.041666666666666664 * (Math.sin(re) * Math.pow(im, 4.0));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 620.0:
		tmp = math.sin(re)
	elif im <= 1.15e+77:
		tmp = math.sqrt(math.pow(re, -8.0))
	else:
		tmp = 0.041666666666666664 * (math.sin(re) * math.pow(im, 4.0))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 620.0)
		tmp = sin(re);
	elseif (im <= 1.15e+77)
		tmp = sqrt((re ^ -8.0));
	else
		tmp = Float64(0.041666666666666664 * Float64(sin(re) * (im ^ 4.0)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 620.0)
		tmp = sin(re);
	elseif (im <= 1.15e+77)
		tmp = sqrt((re ^ -8.0));
	else
		tmp = 0.041666666666666664 * (sin(re) * (im ^ 4.0));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 620.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.15e+77], N[Sqrt[N[Power[re, -8.0], $MachinePrecision]], $MachinePrecision], N[(0.041666666666666664 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;\sqrt{{re}^{-8}}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 620 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{e^{\log re \cdot -4}} \cdot \sqrt{e^{\log re \cdot -4}}} \]
      2. sqrt-unprod22.2%

        \[\leadsto \color{blue}{\sqrt{e^{\log re \cdot -4} \cdot e^{\log re \cdot -4}}} \]
      3. exp-to-pow22.2%

        \[\leadsto \sqrt{\color{blue}{{re}^{-4}} \cdot e^{\log re \cdot -4}} \]
      4. exp-to-pow22.5%

        \[\leadsto \sqrt{{re}^{-4} \cdot \color{blue}{{re}^{-4}}} \]
      5. pow-prod-up22.5%

        \[\leadsto \sqrt{\color{blue}{{re}^{\left(-4 + -4\right)}}} \]
      6. metadata-eval22.5%

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

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

    if 1.14999999999999997e77 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + {im}^{2} \cdot 0.08333333333333333\right)\right)} \]
    7. Taylor expanded in im around inf 100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 620:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;\sqrt{{re}^{-8}}\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 82.6% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;\sqrt{{re}^{-8}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 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 86.4%

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

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

    if 720 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{e^{\log re \cdot -4}} \cdot \sqrt{e^{\log re \cdot -4}}} \]
      2. sqrt-unprod22.2%

        \[\leadsto \color{blue}{\sqrt{e^{\log re \cdot -4} \cdot e^{\log re \cdot -4}}} \]
      3. exp-to-pow22.2%

        \[\leadsto \sqrt{\color{blue}{{re}^{-4}} \cdot e^{\log re \cdot -4}} \]
      4. exp-to-pow22.5%

        \[\leadsto \sqrt{{re}^{-4} \cdot \color{blue}{{re}^{-4}}} \]
      5. pow-prod-up22.5%

        \[\leadsto \sqrt{\color{blue}{{re}^{\left(-4 + -4\right)}}} \]
      6. metadata-eval22.5%

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

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

    if 1.14999999999999997e77 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + {im}^{2} \cdot 0.08333333333333333\right)\right)} \]
    7. Taylor expanded in im around inf 100.0%

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

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

Alternative 5: 65.6% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;im \leq 5.1 \cdot 10^{+76}:\\
\;\;\;\;\sqrt{{re}^{-8}}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 750 < im < 5.1000000000000002e76

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{e^{\log re \cdot -4}} \cdot \sqrt{e^{\log re \cdot -4}}} \]
      2. sqrt-unprod22.2%

        \[\leadsto \color{blue}{\sqrt{e^{\log re \cdot -4} \cdot e^{\log re \cdot -4}}} \]
      3. exp-to-pow22.2%

        \[\leadsto \sqrt{\color{blue}{{re}^{-4}} \cdot e^{\log re \cdot -4}} \]
      4. exp-to-pow22.5%

        \[\leadsto \sqrt{{re}^{-4} \cdot \color{blue}{{re}^{-4}}} \]
      5. pow-prod-up22.5%

        \[\leadsto \sqrt{\color{blue}{{re}^{\left(-4 + -4\right)}}} \]
      6. metadata-eval22.5%

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

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

    if 5.1000000000000002e76 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + {im}^{2} \cdot 0.08333333333333333\right)\right)} \]
    7. Taylor expanded in im around inf 100.0%

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left({im}^{4} \cdot re\right)} \]
    9. Step-by-step derivation
      1. *-commutative72.7%

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

        \[\leadsto \color{blue}{{im}^{4} \cdot \left(re \cdot 0.041666666666666664\right)} \]
    10. Simplified72.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 750:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 5.1 \cdot 10^{+76}:\\ \;\;\;\;\sqrt{{re}^{-8}}\\ \mathbf{else}:\\ \;\;\;\;{im}^{4} \cdot \left(re \cdot 0.041666666666666664\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 65.5% accurate, 2.7× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 750 < im < 2.6000000000000001e74

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if 2.6000000000000001e74 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + {im}^{2} \cdot 0.08333333333333333\right)\right)} \]
    7. Taylor expanded in im around inf 100.0%

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left({im}^{4} \cdot re\right)} \]
    9. Step-by-step derivation
      1. *-commutative72.7%

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

        \[\leadsto \color{blue}{{im}^{4} \cdot \left(re \cdot 0.041666666666666664\right)} \]
    10. Simplified72.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 750:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 2.6 \cdot 10^{+74}:\\ \;\;\;\;{re}^{-4}\\ \mathbf{else}:\\ \;\;\;\;{im}^{4} \cdot \left(re \cdot 0.041666666666666664\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 55.3% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 650:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{{re}^{4}}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 650.0) (sin re) (/ 1.0 (pow re 4.0))))
double code(double re, double im) {
	double tmp;
	if (im <= 650.0) {
		tmp = sin(re);
	} else {
		tmp = 1.0 / 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 <= 650.0d0) then
        tmp = sin(re)
    else
        tmp = 1.0d0 / (re ** 4.0d0)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 650.0) {
		tmp = Math.sin(re);
	} else {
		tmp = 1.0 / Math.pow(re, 4.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 650.0:
		tmp = math.sin(re)
	else:
		tmp = 1.0 / math.pow(re, 4.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 650.0)
		tmp = sin(re);
	else
		tmp = Float64(1.0 / (re ^ 4.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 650.0)
		tmp = sin(re);
	else
		tmp = 1.0 / (re ^ 4.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 650.0], N[Sin[re], $MachinePrecision], N[(1.0 / N[Power[re, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 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 68.4%

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

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

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

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

      \[\leadsto \color{blue}{e^{\log re \cdot -4}} \]
    8. Taylor expanded in re around 0 11.6%

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

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

Alternative 8: 55.3% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 500:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;{re}^{-4}\\ \end{array} \end{array} \]
(FPCore (re im) :precision binary64 (if (<= im 500.0) (sin re) (pow re -4.0)))
double code(double re, double im) {
	double tmp;
	if (im <= 500.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 <= 500.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 <= 500.0) {
		tmp = Math.sin(re);
	} else {
		tmp = Math.pow(re, -4.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 500.0:
		tmp = math.sin(re)
	else:
		tmp = math.pow(re, -4.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 500.0)
		tmp = sin(re);
	else
		tmp = re ^ -4.0;
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 500.0)
		tmp = sin(re);
	else
		tmp = re ^ -4.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 500.0], N[Sin[re], $MachinePrecision], N[Power[re, -4.0], $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 51.0% 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 53.5%

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

    \[\leadsto \sin re \]
  7. Add Preprocessing

Alternative 10: 27.7% accurate, 51.4× speedup?

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

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

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


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

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

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

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

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

    if 8e12 < re

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + {im}^{2} \cdot 0.08333333333333333\right)\right)} \]
    7. Applied egg-rr7.1%

      \[\leadsto \color{blue}{\frac{\sin re}{\sin re + \left(\sin re - \sin re\right)}} \]
    8. Step-by-step derivation
      1. +-inverses7.1%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 8000000000000:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 4.7% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + {im}^{2} \cdot 0.08333333333333333\right)\right)} \]
  7. Applied egg-rr4.7%

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

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

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

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

    \[\leadsto \color{blue}{1} \]
  10. Final simplification4.7%

    \[\leadsto 1 \]
  11. Add Preprocessing

Reproduce

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