math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 8.0s
Alternatives: 15
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 15 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, 0.8× speedup?

\[\begin{array}{l} \\ \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (sin re) (fma 0.5 (exp im) (/ 0.5 (exp im)))))
double code(double re, double im) {
	return sin(re) * fma(0.5, exp(im), (0.5 / exp(im)));
}
function code(re, im)
	return Float64(sin(re) * fma(0.5, exp(im), Float64(0.5 / exp(im))))
end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Exp[im], $MachinePrecision] + N[(0.5 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right) \]

Alternative 2: 100.0% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 3: 74.9% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot e^{im}\right) \cdot \sin re} \]
  8. Final simplification73.9%

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

Alternative 4: 85.3% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ \mathbf{if}\;im \leq 4.8:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 3.1 \cdot 10^{+30}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+40}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left({re}^{3} \cdot -0.08333333333333333 + re \cdot 0.5\right)\\ \mathbf{elif}\;im \leq 1.28 \cdot 10^{+103}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* re (+ 0.5 (* 0.5 (exp im))))))
   (if (<= im 4.8)
     (* (* (sin re) 0.5) (+ 2.0 (* im im)))
     (if (<= im 3.1e+30)
       t_0
       (if (<= im 1.7e+40)
         (* (* im im) (+ (* (pow re 3.0) -0.08333333333333333) (* re 0.5)))
         (if (<= im 1.28e+103)
           t_0
           (*
            (sin re)
            (+ 1.0 (* im (+ 0.5 (* (* im im) 0.08333333333333333)))))))))))
double code(double re, double im) {
	double t_0 = re * (0.5 + (0.5 * exp(im)));
	double tmp;
	if (im <= 4.8) {
		tmp = (sin(re) * 0.5) * (2.0 + (im * im));
	} else if (im <= 3.1e+30) {
		tmp = t_0;
	} else if (im <= 1.7e+40) {
		tmp = (im * im) * ((pow(re, 3.0) * -0.08333333333333333) + (re * 0.5));
	} else if (im <= 1.28e+103) {
		tmp = t_0;
	} else {
		tmp = sin(re) * (1.0 + (im * (0.5 + ((im * im) * 0.08333333333333333))));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = re * (0.5d0 + (0.5d0 * exp(im)))
    if (im <= 4.8d0) then
        tmp = (sin(re) * 0.5d0) * (2.0d0 + (im * im))
    else if (im <= 3.1d+30) then
        tmp = t_0
    else if (im <= 1.7d+40) then
        tmp = (im * im) * (((re ** 3.0d0) * (-0.08333333333333333d0)) + (re * 0.5d0))
    else if (im <= 1.28d+103) then
        tmp = t_0
    else
        tmp = sin(re) * (1.0d0 + (im * (0.5d0 + ((im * im) * 0.08333333333333333d0))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = re * (0.5 + (0.5 * Math.exp(im)));
	double tmp;
	if (im <= 4.8) {
		tmp = (Math.sin(re) * 0.5) * (2.0 + (im * im));
	} else if (im <= 3.1e+30) {
		tmp = t_0;
	} else if (im <= 1.7e+40) {
		tmp = (im * im) * ((Math.pow(re, 3.0) * -0.08333333333333333) + (re * 0.5));
	} else if (im <= 1.28e+103) {
		tmp = t_0;
	} else {
		tmp = Math.sin(re) * (1.0 + (im * (0.5 + ((im * im) * 0.08333333333333333))));
	}
	return tmp;
}
def code(re, im):
	t_0 = re * (0.5 + (0.5 * math.exp(im)))
	tmp = 0
	if im <= 4.8:
		tmp = (math.sin(re) * 0.5) * (2.0 + (im * im))
	elif im <= 3.1e+30:
		tmp = t_0
	elif im <= 1.7e+40:
		tmp = (im * im) * ((math.pow(re, 3.0) * -0.08333333333333333) + (re * 0.5))
	elif im <= 1.28e+103:
		tmp = t_0
	else:
		tmp = math.sin(re) * (1.0 + (im * (0.5 + ((im * im) * 0.08333333333333333))))
	return tmp
function code(re, im)
	t_0 = Float64(re * Float64(0.5 + Float64(0.5 * exp(im))))
	tmp = 0.0
	if (im <= 4.8)
		tmp = Float64(Float64(sin(re) * 0.5) * Float64(2.0 + Float64(im * im)));
	elseif (im <= 3.1e+30)
		tmp = t_0;
	elseif (im <= 1.7e+40)
		tmp = Float64(Float64(im * im) * Float64(Float64((re ^ 3.0) * -0.08333333333333333) + Float64(re * 0.5)));
	elseif (im <= 1.28e+103)
		tmp = t_0;
	else
		tmp = Float64(sin(re) * Float64(1.0 + Float64(im * Float64(0.5 + Float64(Float64(im * im) * 0.08333333333333333)))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = re * (0.5 + (0.5 * exp(im)));
	tmp = 0.0;
	if (im <= 4.8)
		tmp = (sin(re) * 0.5) * (2.0 + (im * im));
	elseif (im <= 3.1e+30)
		tmp = t_0;
	elseif (im <= 1.7e+40)
		tmp = (im * im) * (((re ^ 3.0) * -0.08333333333333333) + (re * 0.5));
	elseif (im <= 1.28e+103)
		tmp = t_0;
	else
		tmp = sin(re) * (1.0 + (im * (0.5 + ((im * im) * 0.08333333333333333))));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 4.8], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.1e+30], t$95$0, If[LessEqual[im, 1.7e+40], N[(N[(im * im), $MachinePrecision] * N[(N[(N[Power[re, 3.0], $MachinePrecision] * -0.08333333333333333), $MachinePrecision] + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.28e+103], t$95$0, N[(N[Sin[re], $MachinePrecision] * N[(1.0 + N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\
\mathbf{if}\;im \leq 4.8:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\

\mathbf{elif}\;im \leq 3.1 \cdot 10^{+30}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 1.7 \cdot 10^{+40}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left({re}^{3} \cdot -0.08333333333333333 + re \cdot 0.5\right)\\

\mathbf{elif}\;im \leq 1.28 \cdot 10^{+103}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

    if 4.79999999999999982 < im < 3.0999999999999998e30 or 1.69999999999999994e40 < im < 1.28e103

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.0999999999999998e30 < im < 1.69999999999999994e40

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(im \cdot im\right) \cdot \left(\color{blue}{{re}^{3} \cdot -0.08333333333333333} + 0.5 \cdot re\right) \]
      7. *-commutative80.6%

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

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

    if 1.28e103 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \left(1 + \color{blue}{\left(\left(0.5 \cdot im + 0.08333333333333333 \cdot {im}^{3}\right) + 0.25 \cdot {im}^{2}\right)}\right) \]
      2. associate-+l+100.0%

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \left(1 + \left(im \cdot 0.5 + \left(\left(0.08333333333333333 \cdot {im}^{2}\right) \cdot im + \color{blue}{\left(0.25 \cdot im\right) \cdot im}\right)\right)\right) \]
      9. distribute-rgt-out100.0%

        \[\leadsto \sin re \cdot \left(1 + \left(im \cdot 0.5 + \color{blue}{im \cdot \left(0.08333333333333333 \cdot {im}^{2} + 0.25 \cdot im\right)}\right)\right) \]
      10. distribute-lft-out100.0%

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

        \[\leadsto \sin re \cdot \left(1 + im \cdot \left(0.5 + \left(0.08333333333333333 \cdot \color{blue}{\left(im \cdot im\right)} + 0.25 \cdot im\right)\right)\right) \]
      12. associate-*r*100.0%

        \[\leadsto \sin re \cdot \left(1 + im \cdot \left(0.5 + \left(\color{blue}{\left(0.08333333333333333 \cdot im\right) \cdot im} + 0.25 \cdot im\right)\right)\right) \]
      13. distribute-rgt-out100.0%

        \[\leadsto \sin re \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot \left(0.08333333333333333 \cdot im + 0.25\right)}\right)\right) \]
      14. *-commutative100.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.8:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 3.1 \cdot 10^{+30}:\\ \;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+40}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left({re}^{3} \cdot -0.08333333333333333 + re \cdot 0.5\right)\\ \mathbf{elif}\;im \leq 1.28 \cdot 10^{+103}:\\ \;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(1 + im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\\ \end{array} \]

Alternative 5: 84.2% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ t_1 := \left(\sin re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{if}\;im \leq 4.8:\\ \;\;\;\;t_1\\ \mathbf{elif}\;im \leq 3.1 \cdot 10^{+30}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+41}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left({re}^{3} \cdot -0.08333333333333333 + re \cdot 0.5\right)\\ \mathbf{elif}\;im \leq 1.3 \cdot 10^{+152}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* re (+ 0.5 (* 0.5 (exp im)))))
        (t_1 (* (* (sin re) 0.5) (+ 2.0 (* im im)))))
   (if (<= im 4.8)
     t_1
     (if (<= im 3.1e+30)
       t_0
       (if (<= im 1.7e+41)
         (* (* im im) (+ (* (pow re 3.0) -0.08333333333333333) (* re 0.5)))
         (if (<= im 1.3e+152) t_0 t_1))))))
double code(double re, double im) {
	double t_0 = re * (0.5 + (0.5 * exp(im)));
	double t_1 = (sin(re) * 0.5) * (2.0 + (im * im));
	double tmp;
	if (im <= 4.8) {
		tmp = t_1;
	} else if (im <= 3.1e+30) {
		tmp = t_0;
	} else if (im <= 1.7e+41) {
		tmp = (im * im) * ((pow(re, 3.0) * -0.08333333333333333) + (re * 0.5));
	} else if (im <= 1.3e+152) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = re * (0.5d0 + (0.5d0 * exp(im)))
    t_1 = (sin(re) * 0.5d0) * (2.0d0 + (im * im))
    if (im <= 4.8d0) then
        tmp = t_1
    else if (im <= 3.1d+30) then
        tmp = t_0
    else if (im <= 1.7d+41) then
        tmp = (im * im) * (((re ** 3.0d0) * (-0.08333333333333333d0)) + (re * 0.5d0))
    else if (im <= 1.3d+152) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = re * (0.5 + (0.5 * Math.exp(im)));
	double t_1 = (Math.sin(re) * 0.5) * (2.0 + (im * im));
	double tmp;
	if (im <= 4.8) {
		tmp = t_1;
	} else if (im <= 3.1e+30) {
		tmp = t_0;
	} else if (im <= 1.7e+41) {
		tmp = (im * im) * ((Math.pow(re, 3.0) * -0.08333333333333333) + (re * 0.5));
	} else if (im <= 1.3e+152) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(re, im):
	t_0 = re * (0.5 + (0.5 * math.exp(im)))
	t_1 = (math.sin(re) * 0.5) * (2.0 + (im * im))
	tmp = 0
	if im <= 4.8:
		tmp = t_1
	elif im <= 3.1e+30:
		tmp = t_0
	elif im <= 1.7e+41:
		tmp = (im * im) * ((math.pow(re, 3.0) * -0.08333333333333333) + (re * 0.5))
	elif im <= 1.3e+152:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(re, im)
	t_0 = Float64(re * Float64(0.5 + Float64(0.5 * exp(im))))
	t_1 = Float64(Float64(sin(re) * 0.5) * Float64(2.0 + Float64(im * im)))
	tmp = 0.0
	if (im <= 4.8)
		tmp = t_1;
	elseif (im <= 3.1e+30)
		tmp = t_0;
	elseif (im <= 1.7e+41)
		tmp = Float64(Float64(im * im) * Float64(Float64((re ^ 3.0) * -0.08333333333333333) + Float64(re * 0.5)));
	elseif (im <= 1.3e+152)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = re * (0.5 + (0.5 * exp(im)));
	t_1 = (sin(re) * 0.5) * (2.0 + (im * im));
	tmp = 0.0;
	if (im <= 4.8)
		tmp = t_1;
	elseif (im <= 3.1e+30)
		tmp = t_0;
	elseif (im <= 1.7e+41)
		tmp = (im * im) * (((re ^ 3.0) * -0.08333333333333333) + (re * 0.5));
	elseif (im <= 1.3e+152)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(0.5 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 4.8], t$95$1, If[LessEqual[im, 3.1e+30], t$95$0, If[LessEqual[im, 1.7e+41], N[(N[(im * im), $MachinePrecision] * N[(N[(N[Power[re, 3.0], $MachinePrecision] * -0.08333333333333333), $MachinePrecision] + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.3e+152], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\
t_1 := \left(\sin re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\
\mathbf{if}\;im \leq 4.8:\\
\;\;\;\;t_1\\

\mathbf{elif}\;im \leq 3.1 \cdot 10^{+30}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;im \leq 1.7 \cdot 10^{+41}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left({re}^{3} \cdot -0.08333333333333333 + re \cdot 0.5\right)\\

\mathbf{elif}\;im \leq 1.3 \cdot 10^{+152}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 4.79999999999999982 or 1.3e152 < im

    1. Initial program 100.0%

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

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

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

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

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

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

    if 4.79999999999999982 < im < 3.0999999999999998e30 or 1.69999999999999999e41 < im < 1.3e152

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.0999999999999998e30 < im < 1.69999999999999999e41

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(im \cdot im\right) \cdot \left(\color{blue}{{re}^{3} \cdot -0.08333333333333333} + 0.5 \cdot re\right) \]
      7. *-commutative80.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.8:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 3.1 \cdot 10^{+30}:\\ \;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ \mathbf{elif}\;im \leq 1.7 \cdot 10^{+41}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left({re}^{3} \cdot -0.08333333333333333 + re \cdot 0.5\right)\\ \mathbf{elif}\;im \leq 1.3 \cdot 10^{+152}:\\ \;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \end{array} \]

Alternative 6: 84.9% accurate, 2.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 3.5 or 1.3e152 < im

    1. Initial program 100.0%

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

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

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

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

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

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

    if 3.5 < im < 1.3e152

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 68.3% accurate, 2.8× speedup?

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

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

\mathbf{elif}\;im \leq 1.3 \cdot 10^{+152}:\\
\;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.69999999999999994e40 < im < 1.3e152

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)} \]

    if 1.3e152 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.7 \cdot 10^{+40}:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.3 \cdot 10^{+152}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot {im}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(0.5 \cdot \left(im \cdot im\right)\right)\\ \end{array} \]

Alternative 8: 72.3% accurate, 2.8× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.5 < im < 1.3e152

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3e152 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 5.5:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.3 \cdot 10^{+152}:\\ \;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(0.5 \cdot \left(im \cdot im\right)\right)\\ \end{array} \]

Alternative 9: 65.3% accurate, 2.9× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.69999999999999994e40 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 64.1% accurate, 3.0× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.69999999999999994e40 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin re \cdot \left(1 + \color{blue}{\left(\left(0.5 \cdot im + 0.08333333333333333 \cdot {im}^{3}\right) + 0.25 \cdot {im}^{2}\right)}\right) \]
      2. associate-+l+79.9%

        \[\leadsto \sin re \cdot \left(1 + \color{blue}{\left(0.5 \cdot im + \left(0.08333333333333333 \cdot {im}^{3} + 0.25 \cdot {im}^{2}\right)\right)}\right) \]
      3. *-commutative79.9%

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

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

        \[\leadsto \sin re \cdot \left(1 + \left(im \cdot 0.5 + \left(0.08333333333333333 \cdot \left(\color{blue}{{im}^{2}} \cdot im\right) + 0.25 \cdot {im}^{2}\right)\right)\right) \]
      6. associate-*r*79.9%

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

        \[\leadsto \sin re \cdot \left(1 + \left(im \cdot 0.5 + \left(\left(0.08333333333333333 \cdot {im}^{2}\right) \cdot im + 0.25 \cdot \color{blue}{\left(im \cdot im\right)}\right)\right)\right) \]
      8. associate-*r*79.9%

        \[\leadsto \sin re \cdot \left(1 + \left(im \cdot 0.5 + \left(\left(0.08333333333333333 \cdot {im}^{2}\right) \cdot im + \color{blue}{\left(0.25 \cdot im\right) \cdot im}\right)\right)\right) \]
      9. distribute-rgt-out79.9%

        \[\leadsto \sin re \cdot \left(1 + \left(im \cdot 0.5 + \color{blue}{im \cdot \left(0.08333333333333333 \cdot {im}^{2} + 0.25 \cdot im\right)}\right)\right) \]
      10. distribute-lft-out79.9%

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

        \[\leadsto \sin re \cdot \left(1 + im \cdot \left(0.5 + \left(0.08333333333333333 \cdot \color{blue}{\left(im \cdot im\right)} + 0.25 \cdot im\right)\right)\right) \]
      12. associate-*r*79.9%

        \[\leadsto \sin re \cdot \left(1 + im \cdot \left(0.5 + \left(\color{blue}{\left(0.08333333333333333 \cdot im\right) \cdot im} + 0.25 \cdot im\right)\right)\right) \]
      13. distribute-rgt-out79.9%

        \[\leadsto \sin re \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot \left(0.08333333333333333 \cdot im + 0.25\right)}\right)\right) \]
      14. *-commutative79.9%

        \[\leadsto \sin re \cdot \left(1 + im \cdot \left(0.5 + im \cdot \left(\color{blue}{im \cdot 0.08333333333333333} + 0.25\right)\right)\right) \]
    7. Simplified79.9%

      \[\leadsto \sin re \cdot \color{blue}{\left(1 + im \cdot \left(0.5 + im \cdot \left(im \cdot 0.08333333333333333 + 0.25\right)\right)\right)} \]
    8. Taylor expanded in re around 0 69.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.7 \cdot 10^{+40}:\\ \;\;\;\;\sin re\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(1 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)\right)\\ \end{array} \]

Alternative 11: 44.7% accurate, 20.6× speedup?

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

\\
re \cdot \left(1 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\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. distribute-lft-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin re \cdot \left(1 + \color{blue}{\left(\left(0.5 \cdot im + 0.08333333333333333 \cdot {im}^{3}\right) + 0.25 \cdot {im}^{2}\right)}\right) \]
    2. associate-+l+65.8%

      \[\leadsto \sin re \cdot \left(1 + \color{blue}{\left(0.5 \cdot im + \left(0.08333333333333333 \cdot {im}^{3} + 0.25 \cdot {im}^{2}\right)\right)}\right) \]
    3. *-commutative65.8%

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

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

      \[\leadsto \sin re \cdot \left(1 + \left(im \cdot 0.5 + \left(0.08333333333333333 \cdot \left(\color{blue}{{im}^{2}} \cdot im\right) + 0.25 \cdot {im}^{2}\right)\right)\right) \]
    6. associate-*r*65.8%

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

      \[\leadsto \sin re \cdot \left(1 + \left(im \cdot 0.5 + \left(\left(0.08333333333333333 \cdot {im}^{2}\right) \cdot im + 0.25 \cdot \color{blue}{\left(im \cdot im\right)}\right)\right)\right) \]
    8. associate-*r*65.8%

      \[\leadsto \sin re \cdot \left(1 + \left(im \cdot 0.5 + \left(\left(0.08333333333333333 \cdot {im}^{2}\right) \cdot im + \color{blue}{\left(0.25 \cdot im\right) \cdot im}\right)\right)\right) \]
    9. distribute-rgt-out65.8%

      \[\leadsto \sin re \cdot \left(1 + \left(im \cdot 0.5 + \color{blue}{im \cdot \left(0.08333333333333333 \cdot {im}^{2} + 0.25 \cdot im\right)}\right)\right) \]
    10. distribute-lft-out65.8%

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

      \[\leadsto \sin re \cdot \left(1 + im \cdot \left(0.5 + \left(0.08333333333333333 \cdot \color{blue}{\left(im \cdot im\right)} + 0.25 \cdot im\right)\right)\right) \]
    12. associate-*r*65.8%

      \[\leadsto \sin re \cdot \left(1 + im \cdot \left(0.5 + \left(\color{blue}{\left(0.08333333333333333 \cdot im\right) \cdot im} + 0.25 \cdot im\right)\right)\right) \]
    13. distribute-rgt-out65.8%

      \[\leadsto \sin re \cdot \left(1 + im \cdot \left(0.5 + \color{blue}{im \cdot \left(0.08333333333333333 \cdot im + 0.25\right)}\right)\right) \]
    14. *-commutative65.8%

      \[\leadsto \sin re \cdot \left(1 + im \cdot \left(0.5 + im \cdot \left(\color{blue}{im \cdot 0.08333333333333333} + 0.25\right)\right)\right) \]
  7. Simplified65.8%

    \[\leadsto \sin re \cdot \color{blue}{\left(1 + im \cdot \left(0.5 + im \cdot \left(im \cdot 0.08333333333333333 + 0.25\right)\right)\right)} \]
  8. Taylor expanded in re around 0 42.6%

    \[\leadsto \color{blue}{\left(\left(\left(0.25 + 0.08333333333333333 \cdot im\right) \cdot im + 0.5\right) \cdot im + 1\right) \cdot re} \]
  9. Final simplification42.6%

    \[\leadsto re \cdot \left(1 + im \cdot \left(0.5 + im \cdot \left(0.25 + im \cdot 0.08333333333333333\right)\right)\right) \]

Alternative 12: 37.1% accurate, 34.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left(im \cdot im\right) \cdot \left(re \cdot 0.5\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. distribute-lft-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto re \cdot \left(0.5 \cdot \color{blue}{\left(e^{im} + \frac{1}{e^{im}}\right)}\right) \]
      3. rec-exp50.5%

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

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

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

    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. distribute-lft-in100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto re \cdot \color{blue}{\left(1 + 0.5 \cdot \left(im \cdot im\right)\right)} \]
    8. Taylor expanded in im around inf 47.2%

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

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

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

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

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

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

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

Alternative 13: 47.8% accurate, 34.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 47.8% accurate, 34.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(im \cdot im\right) \cdot \left(0.5 \cdot re\right)} + 1 \cdot re \]
    5. *-un-lft-identity43.1%

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

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

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

Alternative 15: 26.4% accurate, 309.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{re} \]
  8. Final simplification22.5%

    \[\leadsto re \]

Reproduce

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