math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 8.2s
Alternatives: 17
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 17 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. sub0-neg100.0%

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

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

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

Alternative 2: 86.1% accurate, 1.4× speedup?

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

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

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

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


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

    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. sub0-neg100.0%

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

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

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

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

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

    if 0.0580000000000000029 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
      3. exp-neg92.6%

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity92.6%

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

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

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

    if 1.14999999999999997e77 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)} \]
    8. Step-by-step derivation
      1. *-commutative100.0%

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

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

        \[\leadsto \color{blue}{{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)} \]
    9. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.058:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im + 2\right)\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;0.5 \cdot \left(\frac{re}{e^{im}} + re \cdot e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)\\ \end{array} \]

Alternative 3: 86.1% accurate, 1.4× speedup?

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

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

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

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


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

    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. sub0-neg100.0%

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

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

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

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

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

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

    if 0.104999999999999996 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
      3. exp-neg92.6%

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity92.6%

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

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

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

    if 1.14999999999999997e77 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)} \]
    8. Step-by-step derivation
      1. *-commutative100.0%

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

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

        \[\leadsto \color{blue}{{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)} \]
    9. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.105:\\ \;\;\;\;\sin re + 0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;0.5 \cdot \left(\frac{re}{e^{im}} + re \cdot e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)\\ \end{array} \]

Alternative 4: 86.1% accurate, 1.5× speedup?

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

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

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

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


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

    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. sub0-neg100.0%

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

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

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

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

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

    if 0.059999999999999998 < im < 1.14999999999999997e77

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
      3. exp-neg92.6%

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity92.6%

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{re}{e^{im}} + e^{im} \cdot re\right)\right)} \]
      2. expm1-udef46.2%

        \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{re}{e^{im}} + e^{im} \cdot re\right)} - 1\right)} \]
      3. +-commutative46.2%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{e^{im} \cdot re + \frac{re}{e^{im}}}\right)} - 1\right) \]
      4. *-commutative46.2%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{re \cdot e^{im}} + \frac{re}{e^{im}}\right)} - 1\right) \]
      5. div-inv46.2%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(re \cdot e^{im} + \color{blue}{re \cdot \frac{1}{e^{im}}}\right)} - 1\right) \]
      6. distribute-lft-out46.2%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{re \cdot \left(e^{im} + \frac{1}{e^{im}}\right)}\right)} - 1\right) \]
      7. rec-exp46.2%

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

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(re \cdot \color{blue}{\left(2 \cdot \cosh im\right)}\right)} - 1\right) \]
    9. Applied egg-rr46.2%

      \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(re \cdot \left(2 \cdot \cosh im\right)\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. expm1-def46.2%

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot \left(2 \cdot \cosh im\right)\right)\right)} \]
      2. expm1-log1p92.6%

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

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

    if 1.14999999999999997e77 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)} \]
    8. Step-by-step derivation
      1. *-commutative100.0%

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

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

        \[\leadsto \color{blue}{{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)} \]
    9. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.06:\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im + 2\right)\\ \mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 \cdot \cosh im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)\\ \end{array} \]

Alternative 5: 84.5% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.044 \lor \neg \left(im \leq 2.6 \cdot 10^{+152}\right):\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im + 2\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 \cdot \cosh im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im 0.044) (not (<= im 2.6e+152)))
   (* (* 0.5 (sin re)) (+ (* im im) 2.0))
   (* 0.5 (* re (* 2.0 (cosh im))))))
double code(double re, double im) {
	double tmp;
	if ((im <= 0.044) || !(im <= 2.6e+152)) {
		tmp = (0.5 * sin(re)) * ((im * im) + 2.0);
	} else {
		tmp = 0.5 * (re * (2.0 * cosh(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.044d0) .or. (.not. (im <= 2.6d+152))) then
        tmp = (0.5d0 * sin(re)) * ((im * im) + 2.0d0)
    else
        tmp = 0.5d0 * (re * (2.0d0 * cosh(im)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= 0.044) || !(im <= 2.6e+152)) {
		tmp = (0.5 * Math.sin(re)) * ((im * im) + 2.0);
	} else {
		tmp = 0.5 * (re * (2.0 * Math.cosh(im)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= 0.044) or not (im <= 2.6e+152):
		tmp = (0.5 * math.sin(re)) * ((im * im) + 2.0)
	else:
		tmp = 0.5 * (re * (2.0 * math.cosh(im)))
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= 0.044) || !(im <= 2.6e+152))
		tmp = Float64(Float64(0.5 * sin(re)) * Float64(Float64(im * im) + 2.0));
	else
		tmp = Float64(0.5 * Float64(re * Float64(2.0 * cosh(im))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= 0.044) || ~((im <= 2.6e+152)))
		tmp = (0.5 * sin(re)) * ((im * im) + 2.0);
	else
		tmp = 0.5 * (re * (2.0 * cosh(im)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, 0.044], N[Not[LessEqual[im, 2.6e+152]], $MachinePrecision]], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(re * N[(2.0 * N[Cosh[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.044 \lor \neg \left(im \leq 2.6 \cdot 10^{+152}\right):\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im + 2\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 0.043999999999999997 or 2.6000000000000001e152 < 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. sub0-neg100.0%

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

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

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

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

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

    if 0.043999999999999997 < im < 2.6000000000000001e152

    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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Step-by-step derivation
      1. distribute-rgt-in81.4%

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
      3. exp-neg81.4%

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity81.4%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{\color{blue}{re}}{e^{im}}\right) \]
    6. Simplified81.4%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{re}{e^{im}} + e^{im} \cdot re\right)} \]
    8. Step-by-step derivation
      1. expm1-log1p-u40.6%

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

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

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{e^{im} \cdot re + \frac{re}{e^{im}}}\right)} - 1\right) \]
      4. *-commutative40.6%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{re \cdot e^{im}} + \frac{re}{e^{im}}\right)} - 1\right) \]
      5. div-inv40.6%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(re \cdot e^{im} + \color{blue}{re \cdot \frac{1}{e^{im}}}\right)} - 1\right) \]
      6. distribute-lft-out40.6%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{re \cdot \left(e^{im} + \frac{1}{e^{im}}\right)}\right)} - 1\right) \]
      7. rec-exp40.6%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(re \cdot \left(e^{im} + \color{blue}{e^{-im}}\right)\right)} - 1\right) \]
      8. cosh-undef40.6%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(re \cdot \color{blue}{\left(2 \cdot \cosh im\right)}\right)} - 1\right) \]
    9. Applied egg-rr40.6%

      \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(re \cdot \left(2 \cdot \cosh im\right)\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. expm1-def40.6%

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot \left(2 \cdot \cosh im\right)\right)\right)} \]
      2. expm1-log1p81.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.044 \lor \neg \left(im \leq 2.6 \cdot 10^{+152}\right):\\ \;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(im \cdot im + 2\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 \cdot \cosh im\right)\right)\\ \end{array} \]

Alternative 6: 69.5% accurate, 2.8× speedup?

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

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

\mathbf{elif}\;im \leq 7 \cdot 10^{+215}:\\
\;\;\;\;0.5 \cdot \left(re \cdot \left(2 \cdot \cosh im\right)\right)\\

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


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

    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. sub0-neg100.0%

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

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

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

    if 0.0100000000000000002 < im < 6.99999999999999954e215

    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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Step-by-step derivation
      1. distribute-rgt-in81.5%

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
      3. exp-neg81.5%

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity81.5%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{\color{blue}{re}}{e^{im}}\right) \]
    6. Simplified81.5%

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{re}{e^{im}} + e^{im} \cdot re\right)\right)} \]
      2. expm1-udef37.2%

        \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{re}{e^{im}} + e^{im} \cdot re\right)} - 1\right)} \]
      3. +-commutative37.2%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{e^{im} \cdot re + \frac{re}{e^{im}}}\right)} - 1\right) \]
      4. *-commutative37.2%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{re \cdot e^{im}} + \frac{re}{e^{im}}\right)} - 1\right) \]
      5. div-inv37.2%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(re \cdot e^{im} + \color{blue}{re \cdot \frac{1}{e^{im}}}\right)} - 1\right) \]
      6. distribute-lft-out37.2%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{re \cdot \left(e^{im} + \frac{1}{e^{im}}\right)}\right)} - 1\right) \]
      7. rec-exp37.2%

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

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(re \cdot \color{blue}{\left(2 \cdot \cosh im\right)}\right)} - 1\right) \]
    9. Applied egg-rr37.2%

      \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(re \cdot \left(2 \cdot \cosh im\right)\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. expm1-def37.2%

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot \left(2 \cdot \cosh im\right)\right)\right)} \]
      2. expm1-log1p81.5%

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

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

    if 6.99999999999999954e215 < 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. sub0-neg100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(im \cdot im\right)} \cdot \left(0.5 \cdot \sin re\right) \]
      4. associate-*l*85.8%

        \[\leadsto \color{blue}{im \cdot \left(im \cdot \left(0.5 \cdot \sin re\right)\right)} \]
    9. Simplified85.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.01:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 7 \cdot 10^{+215}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 \cdot \cosh im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(\left(0.5 \cdot \sin re\right) \cdot im\right)\\ \end{array} \]

Alternative 7: 69.0% accurate, 2.8× speedup?

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

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

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


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

    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. sub0-neg100.0%

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

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

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

    if 0.0179999999999999986 < 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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Step-by-step derivation
      1. distribute-rgt-in80.7%

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
      3. exp-neg80.7%

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity80.7%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{\color{blue}{re}}{e^{im}}\right) \]
    6. Simplified80.7%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{re}{e^{im}} + e^{im} \cdot re\right)} \]
    8. Step-by-step derivation
      1. expm1-log1p-u41.9%

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{re}{e^{im}} + e^{im} \cdot re\right)\right)} \]
      2. expm1-udef41.9%

        \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{re}{e^{im}} + e^{im} \cdot re\right)} - 1\right)} \]
      3. +-commutative41.9%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{e^{im} \cdot re + \frac{re}{e^{im}}}\right)} - 1\right) \]
      4. *-commutative41.9%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{re \cdot e^{im}} + \frac{re}{e^{im}}\right)} - 1\right) \]
      5. div-inv41.9%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(re \cdot e^{im} + \color{blue}{re \cdot \frac{1}{e^{im}}}\right)} - 1\right) \]
      6. distribute-lft-out41.9%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{re \cdot \left(e^{im} + \frac{1}{e^{im}}\right)}\right)} - 1\right) \]
      7. rec-exp41.9%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(re \cdot \left(e^{im} + \color{blue}{e^{-im}}\right)\right)} - 1\right) \]
      8. cosh-undef41.9%

        \[\leadsto 0.5 \cdot \left(e^{\mathsf{log1p}\left(re \cdot \color{blue}{\left(2 \cdot \cosh im\right)}\right)} - 1\right) \]
    9. Applied egg-rr41.9%

      \[\leadsto 0.5 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(re \cdot \left(2 \cdot \cosh im\right)\right)} - 1\right)} \]
    10. Step-by-step derivation
      1. expm1-def41.9%

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re \cdot \left(2 \cdot \cosh im\right)\right)\right)} \]
      2. expm1-log1p80.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.018:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(2 \cdot \cosh im\right)\right)\\ \end{array} \]

Alternative 8: 65.5% accurate, 2.9× speedup?

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

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

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


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

    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. sub0-neg100.0%

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

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

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

    if 8.2e15 < 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. sub0-neg100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left(\sin re \cdot {im}^{4}\right)} \]
    8. Step-by-step derivation
      1. *-commutative82.6%

        \[\leadsto \color{blue}{\left(\sin re \cdot {im}^{4}\right) \cdot 0.041666666666666664} \]
      2. *-commutative82.6%

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

        \[\leadsto \color{blue}{{im}^{4} \cdot \left(\sin re \cdot 0.041666666666666664\right)} \]
    9. Simplified82.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 8.2 \cdot 10^{+15}:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \end{array} \]

Alternative 9: 61.8% accurate, 3.0× speedup?

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

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

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


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

    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. sub0-neg100.0%

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

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

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

    if 1.19999999999999998e25 < 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. sub0-neg100.0%

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

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

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

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

      \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
    7. Taylor expanded in re around 0 55.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.2 \cdot 10^{+25}:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im \cdot im + 2\right)\right)\\ \end{array} \]

Alternative 10: 29.2% accurate, 34.1× speedup?

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

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

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


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

    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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Step-by-step derivation
      1. distribute-rgt-in58.1%

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
      3. exp-neg58.1%

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity58.1%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{\color{blue}{re}}{e^{im}}\right) \]
    6. Simplified58.1%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(2 \cdot re\right)} \]
    8. Step-by-step derivation
      1. count-234.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left(re + re\right)} \]
    9. Simplified34.4%

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

    if 1.9e12 < 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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Step-by-step derivation
      1. distribute-rgt-in81.7%

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
      3. exp-neg81.7%

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity81.7%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{\color{blue}{re}}{e^{im}}\right) \]
    6. Simplified81.7%

      \[\leadsto \color{blue}{0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{re}{e^{im}}\right)} \]
    7. Applied egg-rr18.4%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(re + re\right) \cdot re + \left(re + re\right) \cdot re\right)} \]
    8. Step-by-step derivation
      1. distribute-lft-in18.4%

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

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

        \[\leadsto 0.5 \cdot \left(\left(2 \cdot re\right) \cdot \color{blue}{\left(2 \cdot re\right)}\right) \]
      4. swap-sqr18.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(2 \cdot 2\right) \cdot \left(re \cdot re\right)\right)} \]
      5. metadata-eval18.4%

        \[\leadsto 0.5 \cdot \left(\color{blue}{4} \cdot \left(re \cdot re\right)\right) \]
    9. Simplified18.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1900000000000:\\ \;\;\;\;0.5 \cdot \left(re + re\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(4 \cdot \left(re \cdot re\right)\right)\\ \end{array} \]

Alternative 11: 32.1% accurate, 34.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -7 \cdot 10^{+133}:\\
\;\;\;\;0.5 \cdot \left(4 \cdot \left(re \cdot re\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -6.9999999999999997e133

    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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Step-by-step derivation
      1. distribute-rgt-in19.1%

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
      3. exp-neg19.1%

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity19.1%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{\color{blue}{re}}{e^{im}}\right) \]
    6. Simplified19.1%

      \[\leadsto \color{blue}{0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{re}{e^{im}}\right)} \]
    7. Applied egg-rr26.2%

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

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

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

        \[\leadsto 0.5 \cdot \left(\left(2 \cdot re\right) \cdot \color{blue}{\left(2 \cdot re\right)}\right) \]
      4. swap-sqr26.2%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(2 \cdot 2\right) \cdot \left(re \cdot re\right)\right)} \]
      5. metadata-eval26.2%

        \[\leadsto 0.5 \cdot \left(\color{blue}{4} \cdot \left(re \cdot re\right)\right) \]
    9. Simplified26.2%

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

    if -6.9999999999999997e133 < 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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Step-by-step derivation
      1. distribute-rgt-in71.8%

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
      3. exp-neg71.8%

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity71.8%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{\color{blue}{re}}{e^{im}}\right) \]
    6. Simplified71.8%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -7 \cdot 10^{+133}:\\ \;\;\;\;0.5 \cdot \left(4 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(im + 2\right)\right)\\ \end{array} \]

Alternative 12: 48.6% accurate, 34.3× speedup?

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

\\
0.5 \cdot \left(re \cdot \left(im \cdot im + 2\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. sub0-neg100.0%

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

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

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

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

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
  7. Taylor expanded in re around 0 49.0%

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

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

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

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

    \[\leadsto 0.5 \cdot \left(re \cdot \left(im \cdot im + 2\right)\right) \]

Alternative 13: 29.4% accurate, 43.8× speedup?

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

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

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


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

    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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Step-by-step derivation
      1. distribute-rgt-in57.8%

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

        \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
      3. exp-neg57.8%

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity57.8%

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{\color{blue}{re}}{e^{im}}\right) \]
    6. Simplified57.8%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(2 \cdot re\right)} \]
    8. Step-by-step derivation
      1. count-234.6%

        \[\leadsto 0.5 \cdot \color{blue}{\left(re + re\right)} \]
    9. Simplified34.6%

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

    if 890 < 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. sub0-neg100.0%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(re \cdot \left(e^{im} + e^{-im}\right)\right)} \]
    5. Step-by-step derivation
      1. distribute-rgt-in82.0%

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

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

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

        \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
      5. *-lft-identity82.0%

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

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

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

      \[\leadsto \color{blue}{\frac{0.125}{{re}^{2}}} \]
    9. Step-by-step derivation
      1. unpow211.7%

        \[\leadsto \frac{0.125}{\color{blue}{re \cdot re}} \]
    10. Simplified11.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 890:\\ \;\;\;\;0.5 \cdot \left(re + re\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.125}{re \cdot re}\\ \end{array} \]

Alternative 14: 5.5% accurate, 61.8× speedup?

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

\\
0.001953125 \cdot \left(0.5 \cdot re\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. sub0-neg100.0%

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

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

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

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

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

    \[\leadsto \color{blue}{0.001953125} \cdot \left(0.5 \cdot re\right) \]
  8. Final simplification5.6%

    \[\leadsto 0.001953125 \cdot \left(0.5 \cdot re\right) \]

Alternative 15: 26.7% accurate, 61.8× speedup?

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

\\
0.5 \cdot \left(re + re\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. sub0-neg100.0%

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
    3. exp-neg63.6%

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

      \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
    5. *-lft-identity63.6%

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\left(2 \cdot re\right)} \]
  8. Step-by-step derivation
    1. count-227.0%

      \[\leadsto 0.5 \cdot \color{blue}{\left(re + re\right)} \]
  9. Simplified27.0%

    \[\leadsto 0.5 \cdot \color{blue}{\left(re + re\right)} \]
  10. Final simplification27.0%

    \[\leadsto 0.5 \cdot \left(re + re\right) \]

Alternative 16: 3.5% accurate, 309.0× speedup?

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

\\
1.9380669946781485 \cdot 10^{-10}
\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. sub0-neg100.0%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\sin re \cdot 1.9380669946781485 \cdot 10^{-10}}{\sin re + \left(\sin re \cdot 1.9380669946781485 \cdot 10^{-10} - \sin re \cdot 1.9380669946781485 \cdot 10^{-10}\right)}} \]
  8. Step-by-step derivation
    1. *-commutative3.3%

      \[\leadsto \frac{\color{blue}{1.9380669946781485 \cdot 10^{-10} \cdot \sin re}}{\sin re + \left(\sin re \cdot 1.9380669946781485 \cdot 10^{-10} - \sin re \cdot 1.9380669946781485 \cdot 10^{-10}\right)} \]
    2. +-inverses3.3%

      \[\leadsto \frac{1.9380669946781485 \cdot 10^{-10} \cdot \sin re}{\sin re + \color{blue}{0}} \]
    3. +-rgt-identity3.3%

      \[\leadsto \frac{1.9380669946781485 \cdot 10^{-10} \cdot \sin re}{\color{blue}{\sin re}} \]
    4. associate-/l*3.3%

      \[\leadsto \color{blue}{\frac{1.9380669946781485 \cdot 10^{-10}}{\frac{\sin re}{\sin re}}} \]
    5. *-inverses3.3%

      \[\leadsto \frac{1.9380669946781485 \cdot 10^{-10}}{\color{blue}{1}} \]
    6. metadata-eval3.3%

      \[\leadsto \color{blue}{1.9380669946781485 \cdot 10^{-10}} \]
  9. Simplified3.3%

    \[\leadsto \color{blue}{1.9380669946781485 \cdot 10^{-10}} \]
  10. Final simplification3.3%

    \[\leadsto 1.9380669946781485 \cdot 10^{-10} \]

Alternative 17: 4.6% 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. sub0-neg100.0%

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\mathsf{fma}\left(e^{im}, re, e^{-im} \cdot re\right)} \]
    3. exp-neg63.6%

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

      \[\leadsto 0.5 \cdot \mathsf{fma}\left(e^{im}, re, \color{blue}{\frac{1 \cdot re}{e^{im}}}\right) \]
    5. *-lft-identity63.6%

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

    \[\leadsto \color{blue}{0.5 \cdot \mathsf{fma}\left(e^{im}, re, \frac{re}{e^{im}}\right)} \]
  7. Applied egg-rr8.1%

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

      \[\leadsto 0.5 \cdot \color{blue}{\left({\left(re + re\right)}^{\left(\frac{-2}{2}\right)} \cdot {\left(re + re\right)}^{\left(\frac{-2}{2}\right)}\right)} \]
    2. pow-prod-down8.1%

      \[\leadsto 0.5 \cdot \color{blue}{{\left(\left(re + re\right) \cdot \left(re + re\right)\right)}^{\left(\frac{-2}{2}\right)}} \]
    3. flip-+0.0%

      \[\leadsto 0.5 \cdot {\left(\left(re + re\right) \cdot \color{blue}{\frac{re \cdot re - re \cdot re}{re - re}}\right)}^{\left(\frac{-2}{2}\right)} \]
    4. +-inverses0.0%

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

      \[\leadsto 0.5 \cdot {\left(\left(re + re\right) \cdot \frac{\color{blue}{re - re}}{re - re}\right)}^{\left(\frac{-2}{2}\right)} \]
    6. associate-*r/0.0%

      \[\leadsto 0.5 \cdot {\color{blue}{\left(\frac{\left(re + re\right) \cdot \left(re - re\right)}{re - re}\right)}}^{\left(\frac{-2}{2}\right)} \]
    7. difference-of-squares0.0%

      \[\leadsto 0.5 \cdot {\left(\frac{\color{blue}{re \cdot re - re \cdot re}}{re - re}\right)}^{\left(\frac{-2}{2}\right)} \]
    8. flip-+3.6%

      \[\leadsto 0.5 \cdot {\color{blue}{\left(re + re\right)}}^{\left(\frac{-2}{2}\right)} \]
    9. metadata-eval3.6%

      \[\leadsto 0.5 \cdot {\left(re + re\right)}^{\color{blue}{-1}} \]
    10. flip-+0.0%

      \[\leadsto 0.5 \cdot {\color{blue}{\left(\frac{re \cdot re - re \cdot re}{re - re}\right)}}^{-1} \]
    11. clear-num0.0%

      \[\leadsto 0.5 \cdot {\color{blue}{\left(\frac{1}{\frac{re - re}{re \cdot re - re \cdot re}}\right)}}^{-1} \]
    12. +-inverses0.0%

      \[\leadsto 0.5 \cdot {\left(\frac{1}{\frac{\color{blue}{0}}{re \cdot re - re \cdot re}}\right)}^{-1} \]
    13. +-inverses0.0%

      \[\leadsto 0.5 \cdot {\left(\frac{1}{\frac{\color{blue}{re \cdot re - re \cdot re}}{re \cdot re - re \cdot re}}\right)}^{-1} \]
    14. +-inverses0.0%

      \[\leadsto 0.5 \cdot {\left(\frac{1}{\frac{re \cdot re - re \cdot re}{\color{blue}{0}}}\right)}^{-1} \]
    15. +-inverses0.0%

      \[\leadsto 0.5 \cdot {\left(\frac{1}{\frac{re \cdot re - re \cdot re}{\color{blue}{re - re}}}\right)}^{-1} \]
    16. flip-+27.0%

      \[\leadsto 0.5 \cdot {\left(\frac{1}{\color{blue}{re + re}}\right)}^{-1} \]
    17. unpow-127.0%

      \[\leadsto 0.5 \cdot {\color{blue}{\left({\left(re + re\right)}^{-1}\right)}}^{-1} \]
    18. metadata-eval27.0%

      \[\leadsto 0.5 \cdot {\left({\left(re + re\right)}^{\color{blue}{\left(\frac{-2}{2}\right)}}\right)}^{-1} \]
    19. sqrt-pow114.0%

      \[\leadsto 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(re + re\right)}^{-2}}\right)}}^{-1} \]
    20. metadata-eval14.0%

      \[\leadsto 0.5 \cdot {\left(\sqrt{{\left(re + re\right)}^{-2}}\right)}^{\color{blue}{\left(-2 + 1\right)}} \]
    21. pow-prod-up7.9%

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

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

    \[\leadsto 0.5 \]

Reproduce

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