math.sin on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 7.5s
Alternatives: 11
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 11 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} im_m = \left|im\right| \\ \sin re \cdot \mathsf{fma}\left(0.5, e^{im\_m}, \frac{0.5}{e^{im\_m}}\right) \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (* (sin re) (fma 0.5 (exp im_m) (/ 0.5 (exp im_m)))))
im_m = fabs(im);
double code(double re, double im_m) {
	return sin(re) * fma(0.5, exp(im_m), (0.5 / exp(im_m)));
}
im_m = abs(im)
function code(re, im_m)
	return Float64(sin(re) * fma(0.5, exp(im_m), Float64(0.5 / exp(im_m))))
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Exp[im$95$m], $MachinePrecision] + N[(0.5 / N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|

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

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

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

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

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

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

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

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

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

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

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

      \[\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/99.6%

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

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

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

    \[\leadsto \color{blue}{\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)} \]
  4. Add Preprocessing
  5. Final simplification99.6%

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

Alternative 2: 100.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.7% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/99.6%

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

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

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

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

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

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

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

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

Alternative 4: 95.1% accurate, 2.5× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \begin{array}{l} \mathbf{if}\;im\_m \leq 3.7:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im\_m \leq 1.3 \cdot 10^{+103}:\\ \;\;\;\;re \cdot \left(0.5 + 0.5 \cdot e^{im\_m}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin re \cdot \left(1 + im\_m \cdot \left(0.5 + im\_m \cdot \left(im\_m \cdot 0.08333333333333333 + 0.25\right)\right)\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (if (<= im_m 3.7)
   (sin re)
   (if (<= im_m 1.3e+103)
     (* re (+ 0.5 (* 0.5 (exp im_m))))
     (*
      (sin re)
      (+
       1.0
       (* im_m (+ 0.5 (* im_m (+ (* im_m 0.08333333333333333) 0.25)))))))))
im_m = fabs(im);
double code(double re, double im_m) {
	double tmp;
	if (im_m <= 3.7) {
		tmp = sin(re);
	} else if (im_m <= 1.3e+103) {
		tmp = re * (0.5 + (0.5 * exp(im_m)));
	} else {
		tmp = sin(re) * (1.0 + (im_m * (0.5 + (im_m * ((im_m * 0.08333333333333333) + 0.25)))));
	}
	return tmp;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 3.7d0) then
        tmp = sin(re)
    else if (im_m <= 1.3d+103) then
        tmp = re * (0.5d0 + (0.5d0 * exp(im_m)))
    else
        tmp = sin(re) * (1.0d0 + (im_m * (0.5d0 + (im_m * ((im_m * 0.08333333333333333d0) + 0.25d0)))))
    end if
    code = tmp
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	double tmp;
	if (im_m <= 3.7) {
		tmp = Math.sin(re);
	} else if (im_m <= 1.3e+103) {
		tmp = re * (0.5 + (0.5 * Math.exp(im_m)));
	} else {
		tmp = Math.sin(re) * (1.0 + (im_m * (0.5 + (im_m * ((im_m * 0.08333333333333333) + 0.25)))));
	}
	return tmp;
}
im_m = math.fabs(im)
def code(re, im_m):
	tmp = 0
	if im_m <= 3.7:
		tmp = math.sin(re)
	elif im_m <= 1.3e+103:
		tmp = re * (0.5 + (0.5 * math.exp(im_m)))
	else:
		tmp = math.sin(re) * (1.0 + (im_m * (0.5 + (im_m * ((im_m * 0.08333333333333333) + 0.25)))))
	return tmp
im_m = abs(im)
function code(re, im_m)
	tmp = 0.0
	if (im_m <= 3.7)
		tmp = sin(re);
	elseif (im_m <= 1.3e+103)
		tmp = Float64(re * Float64(0.5 + Float64(0.5 * exp(im_m))));
	else
		tmp = Float64(sin(re) * Float64(1.0 + Float64(im_m * Float64(0.5 + Float64(im_m * Float64(Float64(im_m * 0.08333333333333333) + 0.25))))));
	end
	return tmp
end
im_m = abs(im);
function tmp_2 = code(re, im_m)
	tmp = 0.0;
	if (im_m <= 3.7)
		tmp = sin(re);
	elseif (im_m <= 1.3e+103)
		tmp = re * (0.5 + (0.5 * exp(im_m)));
	else
		tmp = sin(re) * (1.0 + (im_m * (0.5 + (im_m * ((im_m * 0.08333333333333333) + 0.25)))));
	end
	tmp_2 = tmp;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := If[LessEqual[im$95$m, 3.7], N[Sin[re], $MachinePrecision], If[LessEqual[im$95$m, 1.3e+103], N[(re * N[(0.5 + N[(0.5 * N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(1.0 + N[(im$95$m * N[(0.5 + N[(im$95$m * N[(N[(im$95$m * 0.08333333333333333), $MachinePrecision] + 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
im_m = \left|im\right|

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.7000000000000002 < im < 1.3000000000000001e103

    1. Initial program 95.7%

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

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

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

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

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

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

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

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

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

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

        \[\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/95.7%

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

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

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

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

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

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

    if 1.3000000000000001e103 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \color{blue}{0.5}\right) \]
    6. Step-by-step derivation
      1. fma-undefine100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.7:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 1.3 \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 + im \cdot \left(im \cdot 0.08333333333333333 + 0.25\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 77.1% accurate, 2.8× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \begin{array}{l} \mathbf{if}\;im\_m \leq 860:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im\_m \leq 3.15 \cdot 10^{+102}:\\ \;\;\;\;{re}^{-2}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(1 + im\_m \cdot \left(0.5 + im\_m \cdot \left(im\_m \cdot 0.08333333333333333 + 0.25\right)\right)\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (if (<= im_m 860.0)
   (sin re)
   (if (<= im_m 3.15e+102)
     (pow re -2.0)
     (*
      re
      (+
       1.0
       (* im_m (+ 0.5 (* im_m (+ (* im_m 0.08333333333333333) 0.25)))))))))
im_m = fabs(im);
double code(double re, double im_m) {
	double tmp;
	if (im_m <= 860.0) {
		tmp = sin(re);
	} else if (im_m <= 3.15e+102) {
		tmp = pow(re, -2.0);
	} else {
		tmp = re * (1.0 + (im_m * (0.5 + (im_m * ((im_m * 0.08333333333333333) + 0.25)))));
	}
	return tmp;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 860.0d0) then
        tmp = sin(re)
    else if (im_m <= 3.15d+102) then
        tmp = re ** (-2.0d0)
    else
        tmp = re * (1.0d0 + (im_m * (0.5d0 + (im_m * ((im_m * 0.08333333333333333d0) + 0.25d0)))))
    end if
    code = tmp
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	double tmp;
	if (im_m <= 860.0) {
		tmp = Math.sin(re);
	} else if (im_m <= 3.15e+102) {
		tmp = Math.pow(re, -2.0);
	} else {
		tmp = re * (1.0 + (im_m * (0.5 + (im_m * ((im_m * 0.08333333333333333) + 0.25)))));
	}
	return tmp;
}
im_m = math.fabs(im)
def code(re, im_m):
	tmp = 0
	if im_m <= 860.0:
		tmp = math.sin(re)
	elif im_m <= 3.15e+102:
		tmp = math.pow(re, -2.0)
	else:
		tmp = re * (1.0 + (im_m * (0.5 + (im_m * ((im_m * 0.08333333333333333) + 0.25)))))
	return tmp
im_m = abs(im)
function code(re, im_m)
	tmp = 0.0
	if (im_m <= 860.0)
		tmp = sin(re);
	elseif (im_m <= 3.15e+102)
		tmp = re ^ -2.0;
	else
		tmp = Float64(re * Float64(1.0 + Float64(im_m * Float64(0.5 + Float64(im_m * Float64(Float64(im_m * 0.08333333333333333) + 0.25))))));
	end
	return tmp
end
im_m = abs(im);
function tmp_2 = code(re, im_m)
	tmp = 0.0;
	if (im_m <= 860.0)
		tmp = sin(re);
	elseif (im_m <= 3.15e+102)
		tmp = re ^ -2.0;
	else
		tmp = re * (1.0 + (im_m * (0.5 + (im_m * ((im_m * 0.08333333333333333) + 0.25)))));
	end
	tmp_2 = tmp;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := If[LessEqual[im$95$m, 860.0], N[Sin[re], $MachinePrecision], If[LessEqual[im$95$m, 3.15e+102], N[Power[re, -2.0], $MachinePrecision], N[(re * N[(1.0 + N[(im$95$m * N[(0.5 + N[(im$95$m * N[(N[(im$95$m * 0.08333333333333333), $MachinePrecision] + 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
im_m = \left|im\right|

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

\mathbf{elif}\;im\_m \leq 3.15 \cdot 10^{+102}:\\
\;\;\;\;{re}^{-2}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 860 < im < 3.15000000000000015e102

    1. Initial program 95.7%

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

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

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

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

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

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

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

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

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

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

        \[\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/95.7%

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

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

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

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

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

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

      \[\leadsto \color{blue}{{re}^{-2}} \]

    if 3.15000000000000015e102 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(re + \color{blue}{\left(0.08333333333333333 \cdot {im}^{3}\right) \cdot re}\right) + \left(0.25 \cdot \left({im}^{2} \cdot re\right) + 0.5 \cdot \left(im \cdot re\right)\right) \]
      3. distribute-rgt1-in80.5%

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

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

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

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

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

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

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

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

        \[\leadsto re \cdot \left(1 + \color{blue}{\left(\left(0.08333333333333333 \cdot {im}^{3} + 0.25 \cdot {im}^{2}\right) + 0.5 \cdot im\right)}\right) \]
      12. +-commutative80.5%

        \[\leadsto 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) \]
      13. *-commutative80.5%

        \[\leadsto 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) \]
    9. Simplified80.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 860:\\ \;\;\;\;\sin re\\ \mathbf{elif}\;im \leq 3.15 \cdot 10^{+102}:\\ \;\;\;\;{re}^{-2}\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(1 + im \cdot \left(0.5 + im \cdot \left(im \cdot 0.08333333333333333 + 0.25\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 87.1% accurate, 2.8× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.2000000000000002 < im

    1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

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

        \[\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/98.5%

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

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

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

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

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

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

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

Alternative 7: 76.7% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im\_m \leq 1.9 \cdot 10^{+53}:\\
\;\;\;\;\sin re\\

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

        \[\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/99.5%

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

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

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

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

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

    if 1.89999999999999999e53 < im

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 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) \]
      13. *-commutative67.3%

        \[\leadsto 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) \]
    9. Simplified67.3%

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

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

Alternative 8: 52.7% accurate, 20.6× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ re \cdot \left(1 + im\_m \cdot \left(0.5 + im\_m \cdot \left(im\_m \cdot 0.08333333333333333 + 0.25\right)\right)\right) \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (*
  re
  (+ 1.0 (* im_m (+ 0.5 (* im_m (+ (* im_m 0.08333333333333333) 0.25)))))))
im_m = fabs(im);
double code(double re, double im_m) {
	return re * (1.0 + (im_m * (0.5 + (im_m * ((im_m * 0.08333333333333333) + 0.25)))));
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = re * (1.0d0 + (im_m * (0.5d0 + (im_m * ((im_m * 0.08333333333333333d0) + 0.25d0)))))
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	return re * (1.0 + (im_m * (0.5 + (im_m * ((im_m * 0.08333333333333333) + 0.25)))));
}
im_m = math.fabs(im)
def code(re, im_m):
	return re * (1.0 + (im_m * (0.5 + (im_m * ((im_m * 0.08333333333333333) + 0.25)))))
im_m = abs(im)
function code(re, im_m)
	return Float64(re * Float64(1.0 + Float64(im_m * Float64(0.5 + Float64(im_m * Float64(Float64(im_m * 0.08333333333333333) + 0.25))))))
end
im_m = abs(im);
function tmp = code(re, im_m)
	tmp = re * (1.0 + (im_m * (0.5 + (im_m * ((im_m * 0.08333333333333333) + 0.25)))));
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := N[(re * N[(1.0 + N[(im$95$m * N[(0.5 + N[(im$95$m * N[(N[(im$95$m * 0.08333333333333333), $MachinePrecision] + 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|

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

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

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

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

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

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

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

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

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

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

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

      \[\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/99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 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) \]
    13. *-commutative42.8%

      \[\leadsto 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) \]
  9. Simplified44.8%

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

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

Alternative 9: 32.2% accurate, 44.1× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ re + 0.5 \cdot \left(re \cdot im\_m\right) \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m) :precision binary64 (+ re (* 0.5 (* re im_m))))
im_m = fabs(im);
double code(double re, double im_m) {
	return re + (0.5 * (re * im_m));
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = re + (0.5d0 * (re * im_m))
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	return re + (0.5 * (re * im_m));
}
im_m = math.fabs(im)
def code(re, im_m):
	return re + (0.5 * (re * im_m))
im_m = abs(im)
function code(re, im_m)
	return Float64(re + Float64(0.5 * Float64(re * im_m)))
end
im_m = abs(im);
function tmp = code(re, im_m)
	tmp = re + (0.5 * (re * im_m));
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := N[(re + N[(0.5 * N[(re * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|

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

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

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

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

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

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

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

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

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

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

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

      \[\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/99.6%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 2.9% accurate, 309.0× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ 0 \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m) :precision binary64 0.0)
im_m = fabs(im);
double code(double re, double im_m) {
	return 0.0;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = 0.0d0
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	return 0.0;
}
im_m = math.fabs(im)
def code(re, im_m):
	return 0.0
im_m = abs(im)
function code(re, im_m)
	return 0.0
end
im_m = abs(im);
function tmp = code(re, im_m)
	tmp = 0.0;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := 0.0
\begin{array}{l}
im_m = \left|im\right|

\\
0
\end{array}
Derivation
  1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

      \[\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/99.6%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\sin re \cdot -0.5\right) + \sin re \cdot -0.5} \]
    2. neg-mul-13.2%

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

      \[\leadsto \color{blue}{\sin re \cdot -0.5 + \left(-\sin re \cdot -0.5\right)} \]
    4. sub-neg3.2%

      \[\leadsto \color{blue}{\sin re \cdot -0.5 - \sin re \cdot -0.5} \]
    5. +-inverses3.2%

      \[\leadsto \color{blue}{0} \]
  7. Simplified3.2%

    \[\leadsto \color{blue}{0} \]
  8. Final simplification3.2%

    \[\leadsto 0 \]
  9. Add Preprocessing

Alternative 11: 26.5% accurate, 309.0× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ re \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m) :precision binary64 re)
im_m = fabs(im);
double code(double re, double im_m) {
	return re;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = re
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	return re;
}
im_m = math.fabs(im)
def code(re, im_m):
	return re
im_m = abs(im)
function code(re, im_m)
	return re
end
im_m = abs(im);
function tmp = code(re, im_m)
	tmp = re;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := re
\begin{array}{l}
im_m = \left|im\right|

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

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

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

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

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

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

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

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

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

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

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

      \[\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/99.6%

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

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

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

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

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

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

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

    \[\leadsto re \]
  9. Add Preprocessing

Reproduce

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