math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 5.8s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + \color{blue}{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: 87.6% accurate, 1.5× speedup?

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

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

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


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

    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. neg-sub0100.0%

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

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

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

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

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

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

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

    if 1.30000000000000004 < 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. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

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

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

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

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

Alternative 3: 74.9% accurate, 1.5× speedup?

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

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

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


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

    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. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 67.5%

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

    if 0.69999999999999996 < 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. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.7:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot e^{im}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 68.5% accurate, 2.8× speedup?

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

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

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


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

    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. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 67.5%

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

    if 25 < 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. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

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

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0}\right) \]
    6. Taylor expanded in re around 0 63.5%

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

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot re\right)} \]
    8. Simplified63.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 25:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;e^{im} \cdot \left(0.5 \cdot re\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 53.7% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 650:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {re}^{-2}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 650.0) (sin re) (* 0.5 (pow re -2.0))))
double code(double re, double im) {
	double tmp;
	if (im <= 650.0) {
		tmp = sin(re);
	} else {
		tmp = 0.5 * pow(re, -2.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 650.0d0) then
        tmp = sin(re)
    else
        tmp = 0.5d0 * (re ** (-2.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 = 0.5 * Math.pow(re, -2.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 650.0:
		tmp = math.sin(re)
	else:
		tmp = 0.5 * math.pow(re, -2.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 650.0)
		tmp = sin(re);
	else
		tmp = Float64(0.5 * (re ^ -2.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 650.0)
		tmp = sin(re);
	else
		tmp = 0.5 * (re ^ -2.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 650.0], N[Sin[re], $MachinePrecision], N[(0.5 * N[Power[re, -2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;0.5 \cdot {re}^{-2}\\


\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. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 67.5%

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

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

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

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

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

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

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

Alternative 6: 53.4% accurate, 2.9× speedup?

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

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

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


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

    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. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 67.5%

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

    if 370 < 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. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

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

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0}\right) \]
    6. Taylor expanded in re around 0 63.5%

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

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot re\right)} \]
    8. Simplified63.5%

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

      \[\leadsto \color{blue}{0.5 \cdot re + 0.5 \cdot \left(im \cdot re\right)} \]
    10. Step-by-step derivation
      1. distribute-lft-out10.2%

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

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

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

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

Alternative 7: 29.8% accurate, 25.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 25:\\ \;\;\;\;0.5 \cdot \left(re + re\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re + re \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 25.0) (* 0.5 (+ re re)) (* 0.5 (+ re (* re im)))))
double code(double re, double im) {
	double tmp;
	if (im <= 25.0) {
		tmp = 0.5 * (re + re);
	} else {
		tmp = 0.5 * (re + (re * im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 25.0d0) then
        tmp = 0.5d0 * (re + re)
    else
        tmp = 0.5d0 * (re + (re * im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 25.0) {
		tmp = 0.5 * (re + re);
	} else {
		tmp = 0.5 * (re + (re * im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 25.0:
		tmp = 0.5 * (re + re)
	else:
		tmp = 0.5 * (re + (re * im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 25.0)
		tmp = Float64(0.5 * Float64(re + re));
	else
		tmp = Float64(0.5 * Float64(re + Float64(re * im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 25.0)
		tmp = 0.5 * (re + re);
	else
		tmp = 0.5 * (re + (re * im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 25.0], N[(0.5 * N[(re + re), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re + N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 25:\\
\;\;\;\;0.5 \cdot \left(re + re\right)\\

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


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

    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. neg-sub0100.0%

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

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

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

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

    if 25 < 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. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

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

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0}\right) \]
    6. Taylor expanded in re around 0 63.5%

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

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

        \[\leadsto \color{blue}{e^{im} \cdot \left(0.5 \cdot re\right)} \]
    8. Simplified63.5%

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

      \[\leadsto \color{blue}{0.5 \cdot re + 0.5 \cdot \left(im \cdot re\right)} \]
    10. Step-by-step derivation
      1. distribute-lft-out10.2%

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

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

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

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

Alternative 8: 27.6% accurate, 30.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq 920000000000:\\
\;\;\;\;0.5 \cdot \left(re + re\right)\\

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


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

    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. neg-sub0100.0%

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

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

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

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

    if 9.2e11 < 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. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 71.2%

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

      \[\leadsto \sin re + 0.5 \cdot \color{blue}{-2} \]
    7. Taylor expanded in re around 0 6.4%

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

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

Alternative 9: 7.6% accurate, 38.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq 920000000000:\\
\;\;\;\;0.5 \cdot re\\

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


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

    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. neg-sub0100.0%

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\log \left(e^{re}\right)} \]
    7. Step-by-step derivation
      1. rem-log-exp8.3%

        \[\leadsto 0.5 \cdot \color{blue}{re} \]
    8. Simplified8.3%

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

    if 9.2e11 < 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. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*r*100.0%

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

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

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

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

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

        \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
      10. exp-diff100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
      11. associate-*l/100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
      12. exp-0100.0%

        \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0 71.2%

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

      \[\leadsto \sin re + 0.5 \cdot \color{blue}{-2} \]
    7. Taylor expanded in re around 0 6.4%

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

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

Alternative 10: 4.6% 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. +-commutative100.0%

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

      \[\leadsto \color{blue}{\left(e^{im} \cdot 0.5\right) \cdot \sin re} + e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) \]
    4. associate-*r*100.0%

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

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

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

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

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

      \[\leadsto \sin re \cdot \color{blue}{\mathsf{fma}\left(0.5, e^{im}, e^{0 - im} \cdot 0.5\right)} \]
    10. exp-diff100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0}}{e^{im}}} \cdot 0.5\right) \]
    11. associate-*l/100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{\frac{e^{0} \cdot 0.5}{e^{im}}}\right) \]
    12. exp-0100.0%

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{\color{blue}{1} \cdot 0.5}{e^{im}}\right) \]
    13. metadata-eval100.0%

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

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in im around 0 74.8%

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

    \[\leadsto \sin re + 0.5 \cdot \color{blue}{-2} \]
  7. Taylor expanded in re around 0 4.8%

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

    \[\leadsto -1 \]
  9. Add Preprocessing

Reproduce

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