math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 7.6s
Alternatives: 14
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(\sin re \cdot \left(e^{-im} + e^{im}\right)\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(0.5 * Float64(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[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 68.4% accurate, 1.5× speedup?

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

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

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


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

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(2 \cdot \sin re\right)} \]
    5. Simplified69.7%

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

    if 5.8e-4 < 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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 65.2% accurate, 2.7× speedup?

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

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

\mathbf{elif}\;im \leq 8.5 \cdot 10^{+68}:\\
\;\;\;\;0.5 \cdot {re}^{-512}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(2 \cdot \sin re\right)} \]
    5. Simplified69.5%

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

    if 720 < im < 8.49999999999999966e68

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{{re}^{-512}} \]

    if 8.49999999999999966e68 < 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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(0.08333333333333333 \cdot \left(re \cdot {im}^{4}\right) + 2 \cdot re\right) + re \cdot {im}^{2}\right)} \]
      2. associate-+l+72.5%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 720:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot 2\right)\\ \mathbf{elif}\;im \leq 8.5 \cdot 10^{+68}:\\ \;\;\;\;0.5 \cdot {re}^{-512}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(0.08333333333333333 \cdot \left(re \cdot {im}^{4}\right) + re \cdot 2\right)\\ \end{array} \]

Alternative 4: 65.2% accurate, 2.8× speedup?

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

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

\mathbf{elif}\;im \leq 2.9 \cdot 10^{+69}:\\
\;\;\;\;0.5 \cdot {re}^{-512}\\

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


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

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(2 \cdot \sin re\right)} \]
    5. Simplified69.5%

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

    if 920 < im < 2.8999999999999998e69

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{{re}^{-512}} \]

    if 2.8999999999999998e69 < 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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(0.08333333333333333 \cdot \left(re \cdot {im}^{4}\right) + 2 \cdot re\right) + re \cdot {im}^{2}\right)} \]
      2. associate-+l+72.5%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 920:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot 2\right)\\ \mathbf{elif}\;im \leq 2.9 \cdot 10^{+69}:\\ \;\;\;\;0.5 \cdot {re}^{-512}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot \left(0.08333333333333333 \cdot {im}^{4}\right)\right)\\ \end{array} \]

Alternative 5: 48.6% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 800 \lor \neg \left(im \leq 4.8 \cdot 10^{+95}\right):\\ \;\;\;\;0.5 \cdot \left(re \cdot 2 + re \cdot \left(im \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {re}^{-512}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im 800.0) (not (<= im 4.8e+95)))
   (* 0.5 (+ (* re 2.0) (* re (* im im))))
   (* 0.5 (pow re -512.0))))
double code(double re, double im) {
	double tmp;
	if ((im <= 800.0) || !(im <= 4.8e+95)) {
		tmp = 0.5 * ((re * 2.0) + (re * (im * im)));
	} else {
		tmp = 0.5 * pow(re, -512.0);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= 800.0d0) .or. (.not. (im <= 4.8d+95))) then
        tmp = 0.5d0 * ((re * 2.0d0) + (re * (im * im)))
    else
        tmp = 0.5d0 * (re ** (-512.0d0))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= 800.0) || !(im <= 4.8e+95)) {
		tmp = 0.5 * ((re * 2.0) + (re * (im * im)));
	} else {
		tmp = 0.5 * Math.pow(re, -512.0);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= 800.0) or not (im <= 4.8e+95):
		tmp = 0.5 * ((re * 2.0) + (re * (im * im)))
	else:
		tmp = 0.5 * math.pow(re, -512.0)
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= 800.0) || !(im <= 4.8e+95))
		tmp = Float64(0.5 * Float64(Float64(re * 2.0) + Float64(re * Float64(im * im))));
	else
		tmp = Float64(0.5 * (re ^ -512.0));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= 800.0) || ~((im <= 4.8e+95)))
		tmp = 0.5 * ((re * 2.0) + (re * (im * im)));
	else
		tmp = 0.5 * (re ^ -512.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, 800.0], N[Not[LessEqual[im, 4.8e+95]], $MachinePrecision]], N[(0.5 * N[(N[(re * 2.0), $MachinePrecision] + N[(re * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Power[re, -512.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 800 \lor \neg \left(im \leq 4.8 \cdot 10^{+95}\right):\\
\;\;\;\;0.5 \cdot \left(re \cdot 2 + re \cdot \left(im \cdot im\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 800 or 4.8000000000000001e95 < 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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(re \cdot \mathsf{fma}\left(im, im, 2\right)\right)} \]
    8. Step-by-step derivation
      1. fma-udef48.8%

        \[\leadsto 0.5 \cdot \left(re \cdot \color{blue}{\left(im \cdot im + 2\right)}\right) \]
      2. distribute-rgt-in48.8%

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

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

    if 800 < im < 4.8000000000000001e95

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 800 \lor \neg \left(im \leq 4.8 \cdot 10^{+95}\right):\\ \;\;\;\;0.5 \cdot \left(re \cdot 2 + re \cdot \left(im \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {re}^{-512}\\ \end{array} \]

Alternative 6: 62.1% accurate, 2.9× speedup?

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

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

\mathbf{elif}\;im \leq 1.95 \cdot 10^{+95}:\\
\;\;\;\;0.5 \cdot {re}^{-512}\\

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


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

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(2 \cdot \sin re\right)} \]
    5. Simplified69.5%

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

    if 950 < im < 1.9499999999999999e95

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{{re}^{-512}} \]

    if 1.9499999999999999e95 < 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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(re \cdot \color{blue}{\left(im \cdot im + 2\right)}\right) \]
      2. distribute-rgt-in60.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 950:\\ \;\;\;\;0.5 \cdot \left(\sin re \cdot 2\right)\\ \mathbf{elif}\;im \leq 1.95 \cdot 10^{+95}:\\ \;\;\;\;0.5 \cdot {re}^{-512}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot 2 + re \cdot \left(im \cdot im\right)\right)\\ \end{array} \]

Alternative 7: 48.5% accurate, 16.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 5.6 \cdot 10^{+19} \lor \neg \left(im \leq 1.55 \cdot 10^{+149}\right):\\ \;\;\;\;0.5 \cdot \left(re \cdot 2 + re \cdot \left(im \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + \left(re \cdot re\right) \cdot 0.016666666666666666\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= im 5.6e+19) (not (<= im 1.55e+149)))
   (* 0.5 (+ (* re 2.0) (* re (* im im))))
   (*
    0.5
    (+
     0.08333333333333333
     (+ (/ 0.25 (* re re)) (* (* re re) 0.016666666666666666))))))
double code(double re, double im) {
	double tmp;
	if ((im <= 5.6e+19) || !(im <= 1.55e+149)) {
		tmp = 0.5 * ((re * 2.0) + (re * (im * im)));
	} else {
		tmp = 0.5 * (0.08333333333333333 + ((0.25 / (re * re)) + ((re * re) * 0.016666666666666666)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((im <= 5.6d+19) .or. (.not. (im <= 1.55d+149))) then
        tmp = 0.5d0 * ((re * 2.0d0) + (re * (im * im)))
    else
        tmp = 0.5d0 * (0.08333333333333333d0 + ((0.25d0 / (re * re)) + ((re * re) * 0.016666666666666666d0)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((im <= 5.6e+19) || !(im <= 1.55e+149)) {
		tmp = 0.5 * ((re * 2.0) + (re * (im * im)));
	} else {
		tmp = 0.5 * (0.08333333333333333 + ((0.25 / (re * re)) + ((re * re) * 0.016666666666666666)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (im <= 5.6e+19) or not (im <= 1.55e+149):
		tmp = 0.5 * ((re * 2.0) + (re * (im * im)))
	else:
		tmp = 0.5 * (0.08333333333333333 + ((0.25 / (re * re)) + ((re * re) * 0.016666666666666666)))
	return tmp
function code(re, im)
	tmp = 0.0
	if ((im <= 5.6e+19) || !(im <= 1.55e+149))
		tmp = Float64(0.5 * Float64(Float64(re * 2.0) + Float64(re * Float64(im * im))));
	else
		tmp = Float64(0.5 * Float64(0.08333333333333333 + Float64(Float64(0.25 / Float64(re * re)) + Float64(Float64(re * re) * 0.016666666666666666))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((im <= 5.6e+19) || ~((im <= 1.55e+149)))
		tmp = 0.5 * ((re * 2.0) + (re * (im * im)));
	else
		tmp = 0.5 * (0.08333333333333333 + ((0.25 / (re * re)) + ((re * re) * 0.016666666666666666)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[im, 5.6e+19], N[Not[LessEqual[im, 1.55e+149]], $MachinePrecision]], N[(0.5 * N[(N[(re * 2.0), $MachinePrecision] + N[(re * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(0.08333333333333333 + N[(N[(0.25 / N[(re * re), $MachinePrecision]), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.6 \cdot 10^{+19} \lor \neg \left(im \leq 1.55 \cdot 10^{+149}\right):\\
\;\;\;\;0.5 \cdot \left(re \cdot 2 + re \cdot \left(im \cdot im\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + \left(re \cdot re\right) \cdot 0.016666666666666666\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 5.6e19 or 1.54999999999999993e149 < 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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(re \cdot \mathsf{fma}\left(im, im, 2\right)\right)} \]
    8. Step-by-step derivation
      1. fma-udef50.7%

        \[\leadsto 0.5 \cdot \left(re \cdot \color{blue}{\left(im \cdot im + 2\right)}\right) \]
      2. distribute-rgt-in50.7%

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

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

    if 5.6e19 < im < 1.54999999999999993e149

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(0.08333333333333333 + \left(0.25 \cdot \frac{1}{{re}^{2}} + 0.016666666666666666 \cdot {re}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r/36.5%

        \[\leadsto 0.5 \cdot \left(0.08333333333333333 + \left(\color{blue}{\frac{0.25 \cdot 1}{{re}^{2}}} + 0.016666666666666666 \cdot {re}^{2}\right)\right) \]
      2. metadata-eval36.5%

        \[\leadsto 0.5 \cdot \left(0.08333333333333333 + \left(\frac{\color{blue}{0.25}}{{re}^{2}} + 0.016666666666666666 \cdot {re}^{2}\right)\right) \]
      3. unpow236.5%

        \[\leadsto 0.5 \cdot \left(0.08333333333333333 + \left(\frac{0.25}{\color{blue}{re \cdot re}} + 0.016666666666666666 \cdot {re}^{2}\right)\right) \]
      4. unpow236.5%

        \[\leadsto 0.5 \cdot \left(0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + 0.016666666666666666 \cdot \color{blue}{\left(re \cdot re\right)}\right)\right) \]
    7. Simplified36.5%

      \[\leadsto 0.5 \cdot \color{blue}{\left(0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + 0.016666666666666666 \cdot \left(re \cdot re\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 5.6 \cdot 10^{+19} \lor \neg \left(im \leq 1.55 \cdot 10^{+149}\right):\\ \;\;\;\;0.5 \cdot \left(re \cdot 2 + re \cdot \left(im \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(0.08333333333333333 + \left(\frac{0.25}{re \cdot re} + \left(re \cdot re\right) \cdot 0.016666666666666666\right)\right)\\ \end{array} \]

Alternative 8: 47.5% accurate, 20.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.6 \cdot 10^{+19} \lor \neg \left(im \leq 1.15 \cdot 10^{+69}\right):\\
\;\;\;\;0.5 \cdot \left(re \cdot 2 + re \cdot \left(im \cdot im\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(0.08333333333333333 + \frac{0.25}{re \cdot re}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 5.6e19 or 1.15000000000000008e69 < 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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(re \cdot \mathsf{fma}\left(im, im, 2\right)\right)} \]
    8. Step-by-step derivation
      1. fma-udef47.3%

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

        \[\leadsto 0.5 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot re + 2 \cdot re\right)} \]
    9. Applied egg-rr47.3%

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

    if 5.6e19 < im < 1.15000000000000008e69

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(0.08333333333333333 + 0.25 \cdot \frac{1}{{re}^{2}}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/44.6%

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

        \[\leadsto 0.5 \cdot \left(0.08333333333333333 + \frac{\color{blue}{0.25}}{{re}^{2}}\right) \]
      3. unpow244.6%

        \[\leadsto 0.5 \cdot \left(0.08333333333333333 + \frac{0.25}{\color{blue}{re \cdot re}}\right) \]
    7. Simplified44.6%

      \[\leadsto 0.5 \cdot \color{blue}{\left(0.08333333333333333 + \frac{0.25}{re \cdot re}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification47.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 5.6 \cdot 10^{+19} \lor \neg \left(im \leq 1.15 \cdot 10^{+69}\right):\\ \;\;\;\;0.5 \cdot \left(re \cdot 2 + re \cdot \left(im \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(0.08333333333333333 + \frac{0.25}{re \cdot re}\right)\\ \end{array} \]

Alternative 9: 34.1% accurate, 23.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 5.6 \cdot 10^{+19}:\\ \;\;\;\;0.5 \cdot \left(re + re\right)\\ \mathbf{elif}\;im \leq 8.5 \cdot 10^{+69}:\\ \;\;\;\;0.5 \cdot \left(0.08333333333333333 + \frac{0.25}{re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= im 5.6e+19)
   (* 0.5 (+ re re))
   (if (<= im 8.5e+69)
     (* 0.5 (+ 0.08333333333333333 (/ 0.25 (* re re))))
     (* 0.5 (* im (* re im))))))
double code(double re, double im) {
	double tmp;
	if (im <= 5.6e+19) {
		tmp = 0.5 * (re + re);
	} else if (im <= 8.5e+69) {
		tmp = 0.5 * (0.08333333333333333 + (0.25 / (re * re)));
	} else {
		tmp = 0.5 * (im * (re * im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (im <= 5.6d+19) then
        tmp = 0.5d0 * (re + re)
    else if (im <= 8.5d+69) then
        tmp = 0.5d0 * (0.08333333333333333d0 + (0.25d0 / (re * re)))
    else
        tmp = 0.5d0 * (im * (re * im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (im <= 5.6e+19) {
		tmp = 0.5 * (re + re);
	} else if (im <= 8.5e+69) {
		tmp = 0.5 * (0.08333333333333333 + (0.25 / (re * re)));
	} else {
		tmp = 0.5 * (im * (re * im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if im <= 5.6e+19:
		tmp = 0.5 * (re + re)
	elif im <= 8.5e+69:
		tmp = 0.5 * (0.08333333333333333 + (0.25 / (re * re)))
	else:
		tmp = 0.5 * (im * (re * im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (im <= 5.6e+19)
		tmp = Float64(0.5 * Float64(re + re));
	elseif (im <= 8.5e+69)
		tmp = Float64(0.5 * Float64(0.08333333333333333 + Float64(0.25 / Float64(re * re))));
	else
		tmp = Float64(0.5 * Float64(im * Float64(re * im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (im <= 5.6e+19)
		tmp = 0.5 * (re + re);
	elseif (im <= 8.5e+69)
		tmp = 0.5 * (0.08333333333333333 + (0.25 / (re * re)));
	else
		tmp = 0.5 * (im * (re * im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[im, 5.6e+19], N[(0.5 * N[(re + re), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 8.5e+69], N[(0.5 * N[(0.08333333333333333 + N[(0.25 / N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;im \leq 8.5 \cdot 10^{+69}:\\
\;\;\;\;0.5 \cdot \left(0.08333333333333333 + \frac{0.25}{re \cdot re}\right)\\

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


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

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.6e19 < im < 8.5000000000000002e69

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\left(0.08333333333333333 + 0.25 \cdot \frac{1}{{re}^{2}}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/44.6%

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

        \[\leadsto 0.5 \cdot \left(0.08333333333333333 + \frac{\color{blue}{0.25}}{{re}^{2}}\right) \]
      3. unpow244.6%

        \[\leadsto 0.5 \cdot \left(0.08333333333333333 + \frac{0.25}{\color{blue}{re \cdot re}}\right) \]
    7. Simplified44.6%

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

    if 8.5000000000000002e69 < 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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 5.6 \cdot 10^{+19}:\\ \;\;\;\;0.5 \cdot \left(re + re\right)\\ \mathbf{elif}\;im \leq 8.5 \cdot 10^{+69}:\\ \;\;\;\;0.5 \cdot \left(0.08333333333333333 + \frac{0.25}{re \cdot re}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\ \end{array} \]

Alternative 10: 34.2% accurate, 27.8× speedup?

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

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

\mathbf{elif}\;im \leq 7.2 \cdot 10^{+68}:\\
\;\;\;\;0.5 \cdot \frac{0.25}{re \cdot re}\\

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


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

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.5e6 < im < 7.1999999999999998e68

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \color{blue}{\frac{0.25}{{re}^{2}}} \]
    6. Step-by-step derivation
      1. unpow241.6%

        \[\leadsto 0.5 \cdot \frac{0.25}{\color{blue}{re \cdot re}} \]
    7. Simplified41.6%

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

    if 7.1999999999999998e68 < 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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4500000:\\ \;\;\;\;0.5 \cdot \left(re + re\right)\\ \mathbf{elif}\;im \leq 7.2 \cdot 10^{+68}:\\ \;\;\;\;0.5 \cdot \frac{0.25}{re \cdot re}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\ \end{array} \]

Alternative 11: 33.9% accurate, 34.1× speedup?

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

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

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


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

    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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3999999999999999 < 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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 26.4% 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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\left(re + re\right)} \]
  8. Final simplification24.2%

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

Alternative 13: 6.8% accurate, 103.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\left|re\right|} \]
  6. Step-by-step derivation
    1. unpow14.5%

      \[\leadsto 0.5 \cdot \left|\color{blue}{{re}^{1}}\right| \]
    2. sqr-pow3.1%

      \[\leadsto 0.5 \cdot \left|\color{blue}{{re}^{\left(\frac{1}{2}\right)} \cdot {re}^{\left(\frac{1}{2}\right)}}\right| \]
    3. fabs-sqr3.1%

      \[\leadsto 0.5 \cdot \color{blue}{\left({re}^{\left(\frac{1}{2}\right)} \cdot {re}^{\left(\frac{1}{2}\right)}\right)} \]
    4. sqr-pow6.4%

      \[\leadsto 0.5 \cdot \color{blue}{{re}^{1}} \]
    5. unpow16.4%

      \[\leadsto 0.5 \cdot \color{blue}{re} \]
  7. Simplified6.4%

    \[\leadsto 0.5 \cdot \color{blue}{re} \]
  8. Final simplification6.4%

    \[\leadsto 0.5 \cdot re \]

Alternative 14: 4.1% accurate, 309.0× speedup?

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

\\
0.041666666666666664
\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. associate-*l*100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.5 \cdot \color{blue}{\left(0.08333333333333333 + 0.25 \cdot \frac{1}{{re}^{2}}\right)} \]
  6. Step-by-step derivation
    1. associate-*r/12.2%

      \[\leadsto 0.5 \cdot \left(0.08333333333333333 + \color{blue}{\frac{0.25 \cdot 1}{{re}^{2}}}\right) \]
    2. metadata-eval12.2%

      \[\leadsto 0.5 \cdot \left(0.08333333333333333 + \frac{\color{blue}{0.25}}{{re}^{2}}\right) \]
    3. unpow212.2%

      \[\leadsto 0.5 \cdot \left(0.08333333333333333 + \frac{0.25}{\color{blue}{re \cdot re}}\right) \]
  7. Simplified12.2%

    \[\leadsto 0.5 \cdot \color{blue}{\left(0.08333333333333333 + \frac{0.25}{re \cdot re}\right)} \]
  8. Taylor expanded in re around inf 4.2%

    \[\leadsto 0.5 \cdot \color{blue}{0.08333333333333333} \]
  9. Final simplification4.2%

    \[\leadsto 0.041666666666666664 \]

Reproduce

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