math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 7.3s
Alternatives: 13
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (sin re)) (+ (exp im) (exp (- im)))))
double code(double re, double im) {
	return (0.5 * sin(re)) * (exp(im) + exp(-im));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * sin(re)) * (exp(im) + exp(-im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.sin(re)) * (Math.exp(im) + Math.exp(-im));
}
def code(re, im):
	return (0.5 * math.sin(re)) * (math.exp(im) + math.exp(-im))
function code(re, im)
	return Float64(Float64(0.5 * sin(re)) * Float64(exp(im) + exp(Float64(-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. +-commutative100.0%

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

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

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

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

Alternative 2: 84.3% accurate, 1.4× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

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

    if 0.23000000000000001 < im < 1.34000000000000001e154

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 1.34000000000000001e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 64.1% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;im \leq 1.8 \cdot 10^{+151}:\\
\;\;\;\;\left(re + 8\right) + {re}^{3} \cdot -0.16666666666666666\\

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


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

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

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

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

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

    if 60 < im < 1.8e151

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin re + \color{blue}{8} \]
    9. Taylor expanded in re around 0 25.8%

      \[\leadsto \color{blue}{8 + \left(re + -0.16666666666666666 \cdot {re}^{3}\right)} \]
    10. Step-by-step derivation
      1. associate-+r+25.8%

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

        \[\leadsto \color{blue}{\left(re + 8\right)} + -0.16666666666666666 \cdot {re}^{3} \]
      3. *-commutative25.8%

        \[\leadsto \left(re + 8\right) + \color{blue}{{re}^{3} \cdot -0.16666666666666666} \]
    11. Simplified25.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 60:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+151}:\\ \;\;\;\;\left(re + 8\right) + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot {im}^{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 77.6% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;im \leq 2.15 \cdot 10^{+151}:\\
\;\;\;\;\left(re + 8\right) + {re}^{3} \cdot -0.16666666666666666\\

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


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

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

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

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

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

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

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

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

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

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

    if 60 < im < 2.14999999999999991e151

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin re + \color{blue}{8} \]
    9. Taylor expanded in re around 0 25.8%

      \[\leadsto \color{blue}{8 + \left(re + -0.16666666666666666 \cdot {re}^{3}\right)} \]
    10. Step-by-step derivation
      1. associate-+r+25.8%

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

        \[\leadsto \color{blue}{\left(re + 8\right)} + -0.16666666666666666 \cdot {re}^{3} \]
      3. *-commutative25.8%

        \[\leadsto \left(re + 8\right) + \color{blue}{{re}^{3} \cdot -0.16666666666666666} \]
    11. Simplified25.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 60:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\ \mathbf{elif}\;im \leq 2.15 \cdot 10^{+151}:\\ \;\;\;\;\left(re + 8\right) + {re}^{3} \cdot -0.16666666666666666\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot {im}^{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 61.1% accurate, 2.6× speedup?

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

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

\mathbf{elif}\;im \leq 1.08 \cdot 10^{+129}:\\
\;\;\;\;\left(re + 8\right) + {re}^{3} \cdot -0.16666666666666666\\

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


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

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

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

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

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

    if 60 < im < 1.08e129

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

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

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

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

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

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

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

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

      \[\leadsto \sin re + \color{blue}{8} \]
    9. Taylor expanded in re around 0 24.0%

      \[\leadsto \color{blue}{8 + \left(re + -0.16666666666666666 \cdot {re}^{3}\right)} \]
    10. Step-by-step derivation
      1. associate-+r+24.0%

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

        \[\leadsto \color{blue}{\left(re + 8\right)} + -0.16666666666666666 \cdot {re}^{3} \]
      3. *-commutative24.0%

        \[\leadsto \left(re + 8\right) + \color{blue}{{re}^{3} \cdot -0.16666666666666666} \]
    11. Simplified24.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 60.4% accurate, 2.8× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 60.4% accurate, 2.8× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re + 0.5 \cdot \left({im}^{2} \cdot re\right)} \]
    9. Taylor expanded in im around inf 41.5%

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

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

Alternative 8: 57.7% accurate, 2.9× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto re + 0.5 \cdot \left(re \cdot \color{blue}{\left(im \cdot im\right)} - 0\right) \]
      7. associate-*r*32.5%

        \[\leadsto re + 0.5 \cdot \left(\color{blue}{\left(re \cdot im\right) \cdot im} - 0\right) \]
      8. fma-neg32.5%

        \[\leadsto re + 0.5 \cdot \color{blue}{\mathsf{fma}\left(re \cdot im, im, -0\right)} \]
      9. metadata-eval32.5%

        \[\leadsto re + 0.5 \cdot \mathsf{fma}\left(re \cdot im, im, \color{blue}{0}\right) \]
    10. Applied egg-rr32.5%

      \[\leadsto re + 0.5 \cdot \color{blue}{\mathsf{fma}\left(re \cdot im, im, 0\right)} \]
    11. Step-by-step derivation
      1. fma-undefine32.5%

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

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

        \[\leadsto re + 0.5 \cdot \left(\color{blue}{\left(im \cdot re\right)} \cdot im\right) \]
    12. Applied egg-rr32.5%

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

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

Alternative 9: 42.1% accurate, 34.3× speedup?

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

\\
re + 0.5 \cdot \left(im \cdot \left(re \cdot im\right)\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. +-commutative100.0%

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

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

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

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

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

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

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

      \[\leadsto re + 0.5 \cdot \color{blue}{\mathsf{fma}\left({im}^{2}, re, 0\right)} \]
    3. metadata-eval41.3%

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

      \[\leadsto re + 0.5 \cdot \color{blue}{\left({im}^{2} \cdot re - 0\right)} \]
    5. *-commutative41.3%

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

      \[\leadsto re + 0.5 \cdot \left(re \cdot \color{blue}{\left(im \cdot im\right)} - 0\right) \]
    7. associate-*r*36.5%

      \[\leadsto re + 0.5 \cdot \left(\color{blue}{\left(re \cdot im\right) \cdot im} - 0\right) \]
    8. fma-neg36.5%

      \[\leadsto re + 0.5 \cdot \color{blue}{\mathsf{fma}\left(re \cdot im, im, -0\right)} \]
    9. metadata-eval36.5%

      \[\leadsto re + 0.5 \cdot \mathsf{fma}\left(re \cdot im, im, \color{blue}{0}\right) \]
  10. Applied egg-rr36.5%

    \[\leadsto re + 0.5 \cdot \color{blue}{\mathsf{fma}\left(re \cdot im, im, 0\right)} \]
  11. Step-by-step derivation
    1. fma-undefine36.5%

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

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

      \[\leadsto re + 0.5 \cdot \left(\color{blue}{\left(im \cdot re\right)} \cdot im\right) \]
  12. Applied egg-rr36.5%

    \[\leadsto re + 0.5 \cdot \color{blue}{\left(\left(im \cdot re\right) \cdot im\right)} \]
  13. Final simplification36.5%

    \[\leadsto re + 0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right) \]
  14. Add Preprocessing

Alternative 10: 27.2% accurate, 51.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;0.5\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 380000000000:\\ \;\;\;\;re\\ \mathbf{else}:\\ \;\;\;\;0.5\\ \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. +-commutative100.0%

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

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

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

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

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

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

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

    \[\leadsto \sin re + \color{blue}{-1} \]
  9. Taylor expanded in re around 0 5.6%

    \[\leadsto \color{blue}{-1} \]
  10. Final simplification5.6%

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

Alternative 12: 4.3% accurate, 309.0× speedup?

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

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

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

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

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

    \[\leadsto \color{blue}{0.25} \]
  6. Final simplification4.5%

    \[\leadsto 0.25 \]
  7. Add Preprocessing

Alternative 13: 4.5% accurate, 309.0× speedup?

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.5} \]
  6. Final simplification4.6%

    \[\leadsto 0.5 \]
  7. Add Preprocessing

Reproduce

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